Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package android.provider; |
| 18 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 20 | import android.annotation.SdkConstant; |
| 21 | import android.annotation.SdkConstant.SdkConstantType; |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 23 | import android.annotation.UnsupportedAppUsage; |
Daniel Lehmann | e6d3d28 | 2011-07-13 15:35:05 -0700 | [diff] [blame] | 24 | import android.app.Activity; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 26 | import android.content.ComponentName; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 27 | import android.content.ContentProviderClient; |
| 28 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 29 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 30 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 31 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 32 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 33 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 34 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 35 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 36 | import android.content.EntityIterator; |
| 37 | import android.content.Intent; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 38 | import android.content.IntentFilter; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 39 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 40 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 41 | import android.database.Cursor; |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 42 | import android.database.CursorWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 43 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 44 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 45 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 46 | import android.os.RemoteException; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 47 | import android.telecom.PhoneAccountHandle; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 48 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 49 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 50 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 51 | import android.view.View; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 52 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 53 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 54 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 55 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 56 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 57 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 58 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 59 | * <p> |
| 60 | * The contract between the contacts provider and applications. Contains |
| 61 | * definitions for the supported URIs and columns. These APIs supersede |
| 62 | * {@link Contacts}. |
| 63 | * </p> |
| 64 | * <h3>Overview</h3> |
| 65 | * <p> |
| 66 | * ContactsContract defines an extensible database of contact-related |
| 67 | * information. Contact information is stored in a three-tier data model: |
| 68 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 69 | * <ul> |
| 70 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 71 | * A row in the {@link Data} table can store any kind of personal data, such |
| 72 | * as a phone number or email addresses. The set of data kinds that can be |
| 73 | * stored in this table is open-ended. There is a predefined set of common |
| 74 | * kinds, but any application can add its own data kinds. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 75 | * </li> |
| 76 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 77 | * A row in the {@link RawContacts} table represents a set of data describing a |
| 78 | * person and associated with a single account (for example, one of the user's |
| 79 | * Gmail accounts). |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 80 | * </li> |
| 81 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 82 | * A row in the {@link Contacts} table represents an aggregate of one or more |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 83 | * RawContacts presumably describing the same person. When data in or associated with |
| 84 | * the RawContacts table is changed, the affected aggregate contacts are updated as |
| 85 | * necessary. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 86 | * </li> |
| 87 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 88 | * <p> |
| 89 | * Other tables include: |
| 90 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 91 | * <ul> |
| 92 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 93 | * {@link Groups}, which contains information about raw contact groups |
| 94 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 95 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 96 | * </li> |
| 97 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 98 | * {@link StatusUpdates}, which contains social status updates including IM |
| 99 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 100 | * </li> |
| 101 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 102 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 103 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 104 | * </li> |
| 105 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 106 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 107 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 108 | * </li> |
| 109 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 110 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 111 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 112 | * </li> |
| 113 | * <li> |
| 114 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 115 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 116 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 117 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 118 | public final class ContactsContract { |
| 119 | /** The authority for the contacts provider */ |
| 120 | public static final String AUTHORITY = "com.android.contacts"; |
| 121 | /** A content:// style uri to the authority for the contacts provider */ |
| 122 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 123 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 124 | /** |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 125 | * Prefix for column names that are not visible to client apps. |
| 126 | * @hide |
| 127 | */ |
| 128 | public static final String HIDDEN_COLUMN_PREFIX = "x_"; |
| 129 | |
| 130 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 131 | * An optional URI parameter for insert, update, or delete queries |
| 132 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 133 | * to specify that it is a sync adapter. The default value is false. If true |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 134 | * {@link RawContacts#DIRTY} is not automatically set and the |
| 135 | * "syncToNetwork" parameter is set to false when calling |
| 136 | * {@link |
| 137 | * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 138 | * This prevents an unnecessary extra synchronization, see the discussion of |
| 139 | * the delete operation in {@link RawContacts}. |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 140 | */ |
| 141 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 142 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 143 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 144 | * Query parameter that should be used by the client to access a specific |
| 145 | * {@link Directory}. The parameter value should be the _ID of the corresponding |
| 146 | * directory, e.g. |
| 147 | * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 148 | */ |
| 149 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 150 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 151 | /** |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 152 | * A query parameter that limits the number of results returned for supported URIs. The |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 153 | * parameter value should be an integer. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 154 | * |
| 155 | * <p>This parameter is not supported by all URIs. Supported URIs include, but not limited to, |
| 156 | * {@link Contacts#CONTENT_URI}, |
| 157 | * {@link RawContacts#CONTENT_URI}, |
| 158 | * {@link Data#CONTENT_URI}, |
| 159 | * {@link CommonDataKinds.Phone#CONTENT_URI}, |
| 160 | * {@link CommonDataKinds.Callable#CONTENT_URI}, |
| 161 | * {@link CommonDataKinds.Email#CONTENT_URI}, |
| 162 | * {@link CommonDataKinds.Contactables#CONTENT_URI}, |
| 163 | * |
| 164 | * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a |
| 165 | * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods. |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 166 | */ |
| 167 | public static final String LIMIT_PARAM_KEY = "limit"; |
| 168 | |
| 169 | /** |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 170 | * A query parameter specifing a primary account. This parameter should be used with |
| 171 | * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on |
| 172 | * this information to optimize its query results. |
| 173 | * |
| 174 | * For example, in an email composition screen, its implementation can specify an account when |
| 175 | * obtaining possible recipients, letting the provider know which account is selected during |
| 176 | * the composition. The provider may use the "primary account" information to optimize |
| 177 | * the search result. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 178 | */ |
| 179 | public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account"; |
| 180 | |
| 181 | /** |
| 182 | * A query parameter specifing a primary account. This parameter should be used with |
| 183 | * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 184 | */ |
| 185 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 186 | |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 187 | /** |
| 188 | * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and |
| 189 | * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to |
| 190 | * return only phone-related results. For example, frequently contacted person list should |
| 191 | * include persons contacted via phone (not email, sms, etc.) |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 192 | */ |
| 193 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 194 | |
| 195 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 196 | * A key to a boolean in the "extras" bundle of the cursor. |
| 197 | * The boolean indicates that the provider did not create a snippet and that the client asking |
| 198 | * for the snippet should do it (true means the snippeting was deferred to the client). |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 199 | * |
| 200 | * @see SearchSnippets |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 201 | */ |
| 202 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 203 | |
| 204 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 205 | * Key to retrieve the original deferred snippeting from the cursor on the client side. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 206 | * |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 207 | * @see SearchSnippets |
| 208 | * @see #DEFERRED_SNIPPETING |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 209 | */ |
| 210 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 211 | |
| 212 | /** |
Yorke Lee | 1ca440b | 2014-06-04 18:01:46 -0700 | [diff] [blame] | 213 | * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI}, |
| 214 | * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and |
| 215 | * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 216 | * This enables a content provider to remove duplicate entries in results. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 217 | */ |
| 218 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 219 | |
| 220 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 221 | * <p> |
| 222 | * API for obtaining a pre-authorized version of a URI that normally requires special |
| 223 | * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI |
| 224 | * must already have the necessary permissions to access the URI; otherwise a |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 225 | * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission}, |
| 226 | * this can be used to grant permissions that aren't explicitly required for the URI inside |
| 227 | * AndroidManifest.xml. For example, permissions that are only required when reading URIs |
| 228 | * that refer to the user's profile. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 229 | * </p> |
| 230 | * <p> |
| 231 | * The authorized URI returned in the bundle contains an expiring token that allows the |
| 232 | * caller to execute the query without having the special permissions that would normally |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 233 | * be required. The token expires in five minutes. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 234 | * </p> |
| 235 | * <p> |
| 236 | * This API does not access disk, and should be safe to invoke from the UI thread. |
| 237 | * </p> |
| 238 | * <p> |
| 239 | * Example usage: |
| 240 | * <pre> |
| 241 | * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI; |
| 242 | * Bundle uriBundle = new Bundle(); |
| 243 | * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); |
| 244 | * Bundle authResponse = getContext().getContentResolver().call( |
| 245 | * ContactsContract.AUTHORITY_URI, |
| 246 | * ContactsContract.Authorization.AUTHORIZATION_METHOD, |
| 247 | * null, // String arg, not used. |
| 248 | * uriBundle); |
| 249 | * if (authResponse != null) { |
| 250 | * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable( |
| 251 | * ContactsContract.Authorization.KEY_AUTHORIZED_URI); |
| 252 | * // This pre-authorized URI can be queried by a caller without READ_PROFILE |
| 253 | * // permission. |
| 254 | * } |
| 255 | * </pre> |
| 256 | * </p> |
Brian Attwell | 7d383b9 | 2015-05-14 15:25:01 -0700 | [diff] [blame] | 257 | * |
| 258 | * @hide |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 259 | */ |
| 260 | public static final class Authorization { |
| 261 | /** |
| 262 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 263 | */ |
| 264 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 265 | |
| 266 | /** |
| 267 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 268 | */ |
| 269 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 270 | |
| 271 | /** |
| 272 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 273 | */ |
| 274 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 275 | } |
| 276 | |
Yorke Lee | 6355c8f | 2014-07-08 11:48:42 -0700 | [diff] [blame] | 277 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 278 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 279 | * Google Apps Global Address List or Corporate Global Address List. |
| 280 | * <p> |
| 281 | * A Directory is implemented as a content provider with its unique authority and |
| 282 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 283 | * every directory provider will implement this Contract in its entirety. If a |
| 284 | * directory provider does not have an implementation for a specific request, it |
| 285 | * should throw an UnsupportedOperationException. |
| 286 | * </p> |
| 287 | * <p> |
| 288 | * The most important use case for Directories is search. A Directory provider is |
Dmitri Plotnikov | 13e0357 | 2010-08-19 16:31:29 -0700 | [diff] [blame] | 289 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 290 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 291 | * in email and phone lookup functionalities, it should also implement |
| 292 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 293 | * and |
| 294 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 295 | * </p> |
| 296 | * <p> |
| 297 | * A directory provider should return NULL for every projection field it does not |
| 298 | * recognize, rather than throwing an exception. This way it will not be broken |
| 299 | * if ContactsContract is extended with new fields in the future. |
| 300 | * </p> |
| 301 | * <p> |
| 302 | * The client interacts with a directory via Contacts Provider by supplying an |
| 303 | * optional {@code directory=} query parameter. |
| 304 | * <p> |
| 305 | * <p> |
| 306 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 307 | * the request to the corresponding directory content provider. |
| 308 | * The URI is transformed in the following fashion: |
| 309 | * <ul> |
| 310 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 311 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 312 | * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 313 | * </ul> |
| 314 | * </p> |
| 315 | * <p> |
| 316 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 317 | * forward them to the respective providers rather than constructing |
| 318 | * directory provider URIs by themselves. This level of indirection allows |
| 319 | * Contacts Provider to implement additional system-level features and |
| 320 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 321 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 322 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 323 | * platform versions the provider should perform the following check to make sure the call |
| 324 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 325 | * <pre> |
| 326 | * private boolean isCallerAllowed() { |
| 327 | * PackageManager pm = getContext().getPackageManager(); |
| 328 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 329 | * if (packageName.equals("com.android.providers.contacts")) { |
| 330 | * return true; |
| 331 | * } |
| 332 | * } |
| 333 | * return false; |
| 334 | * } |
| 335 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 336 | * </p> |
| 337 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 338 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 339 | * automatically. |
| 340 | * </p> |
| 341 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 342 | * <ul> |
| 343 | * <li> |
| 344 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 345 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 346 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 347 | * parameter altogether. |
| 348 | * </li> |
| 349 | * <li> |
| 350 | * The local invisible contacts. The corresponding directory ID is |
| 351 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 352 | * </li> |
| 353 | * </ul> |
| 354 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 355 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 356 | * <ul> |
| 357 | * <li>It finds all installed content providers with meta data identifying them |
| 358 | * as directory providers in AndroidManifest.xml: |
| 359 | * <code> |
| 360 | * <meta-data android:name="android.content.ContactDirectory" |
| 361 | * android:value="true" /> |
| 362 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 363 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 364 | * This tag should be placed inside the corresponding content provider declaration. |
| 365 | * </p> |
| 366 | * </li> |
| 367 | * <li> |
| 368 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 369 | * query to each of the directory authorities. A directory provider must implement |
| 370 | * this query and return a list of directories. Each directory returned by |
| 371 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 372 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 373 | * automatically, the _ID field will not be part of the query projection. |
| 374 | * </li> |
| 375 | * <li>Contacts Provider compiles directory lists received from all directory |
| 376 | * providers into one, assigns each individual directory a globally unique ID and |
| 377 | * stores all directory records in the Directory table. |
| 378 | * </li> |
| 379 | * </ul> |
| 380 | * </p> |
| 381 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 382 | * Thus simply installing a package containing a directory provider is sufficient |
| 383 | * to have that provider registered. A package supplying a directory provider does |
| 384 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 385 | * </p> |
| 386 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 387 | * Every row in the Directory table is automatically associated with the corresponding package |
| 388 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 389 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 390 | * </p> |
| 391 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 392 | * When the list of directories handled by a directory provider changes |
| 393 | * (for instance when the user adds a new Directory account), the directory provider |
| 394 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 395 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 396 | * new list of directories. |
| 397 | * </p> |
| 398 | * <p> |
| 399 | * A directory row can be optionally associated with an existing account |
| 400 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 401 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 402 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 403 | */ |
| 404 | public static final class Directory implements BaseColumns { |
| 405 | |
| 406 | /** |
| 407 | * Not instantiable. |
| 408 | */ |
| 409 | private Directory() { |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * The content:// style URI for this table. Requests to this URI can be |
| 414 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 415 | */ |
| 416 | public static final Uri CONTENT_URI = |
| 417 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 418 | |
| 419 | /** |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 420 | * URI used for getting all directories from primary and managed profile. |
| 421 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns. |
| 422 | * If the device has no managed profile that is linked to the current profile, it behaves |
| 423 | * in the exact same way as {@link #CONTENT_URI}. |
| 424 | * If there is a managed profile linked to the current profile, it will merge |
| 425 | * managed profile and current profile's results and return. |
| 426 | * |
| 427 | * Note: this query returns primary profile results before managed profile results, |
| 428 | * and this order is not affected by sorting parameter. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 429 | * |
| 430 | */ |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 431 | public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 432 | "directories_enterprise"); |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 433 | |
| 434 | /** |
Victor Chang | dc0406d | 2016-01-14 21:02:06 +0000 | [diff] [blame] | 435 | * Access file provided by remote directory. It allows both personal and work remote |
| 436 | * directory, but not local and invisible diretory. |
| 437 | * |
| 438 | * It's supported only by a few specific places for referring to contact pictures in the |
| 439 | * remote directory. Contact picture URIs, e.g. |
| 440 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI. |
| 441 | * |
| 442 | * @hide |
| 443 | */ |
| 444 | public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 445 | "directory_file_enterprise"); |
| 446 | |
| 447 | |
| 448 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 449 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 450 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 451 | */ |
| 452 | public static final String CONTENT_TYPE = |
| 453 | "vnd.android.cursor.dir/contact_directories"; |
| 454 | |
| 455 | /** |
| 456 | * The MIME type of a {@link #CONTENT_URI} item. |
| 457 | */ |
| 458 | public static final String CONTENT_ITEM_TYPE = |
| 459 | "vnd.android.cursor.item/contact_directory"; |
| 460 | |
| 461 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 462 | * _ID of the default directory, which represents locally stored contacts. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 463 | * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and |
| 464 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}. |
| 465 | * Other URLs do not support the concept of "visible" or "invisible" contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 466 | */ |
| 467 | public static final long DEFAULT = 0; |
| 468 | |
| 469 | /** |
| 470 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 471 | */ |
| 472 | public static final long LOCAL_INVISIBLE = 1; |
| 473 | |
| 474 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 475 | * _ID of the work profile default directory, which represents locally stored contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 476 | */ |
| 477 | public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 478 | + DEFAULT; |
| 479 | |
| 480 | /** |
| 481 | * _ID of the work profile directory that represents locally stored invisible contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 482 | */ |
| 483 | public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 484 | + LOCAL_INVISIBLE; |
| 485 | |
| 486 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 487 | * The name of the package that owns this directory. Contacts Provider |
| 488 | * fill it in with the name of the package containing the directory provider. |
| 489 | * If the package is later uninstalled, the directories it owns are |
| 490 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 491 | * |
| 492 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 493 | */ |
| 494 | public static final String PACKAGE_NAME = "packageName"; |
| 495 | |
| 496 | /** |
| 497 | * The type of directory captured as a resource ID in the context of the |
| 498 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 499 | * |
| 500 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 501 | */ |
| 502 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 503 | |
| 504 | /** |
| 505 | * An optional name that can be used in the UI to represent this directory, |
| 506 | * e.g. "Acme Corp" |
| 507 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 508 | */ |
| 509 | public static final String DISPLAY_NAME = "displayName"; |
| 510 | |
| 511 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 512 | * <p> |
| 513 | * The authority of the Directory Provider. Contacts Provider will |
| 514 | * use this authority to forward requests to the directory provider. |
| 515 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 516 | * </p> |
| 517 | * <p> |
| 518 | * Clients of this API should not send requests directly to this authority. |
| 519 | * All directory requests must be routed through Contacts Provider. |
| 520 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 521 | * |
| 522 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 523 | */ |
| 524 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 525 | |
| 526 | /** |
| 527 | * The account type which this directory is associated. |
| 528 | * |
| 529 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 530 | */ |
| 531 | public static final String ACCOUNT_TYPE = "accountType"; |
| 532 | |
| 533 | /** |
| 534 | * The account with which this directory is associated. If the account is later |
| 535 | * removed, the directories it owns are automatically removed from this table. |
| 536 | * |
| 537 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 538 | */ |
| 539 | public static final String ACCOUNT_NAME = "accountName"; |
| 540 | |
| 541 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 542 | * Mimimal ID for corp directory returned from |
| 543 | * {@link Directory#CORP_CONTENT_URI}. |
| 544 | * |
| 545 | * @hide |
| 546 | */ |
| 547 | // slightly smaller than 2 ** 30 |
| 548 | public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000; |
| 549 | |
| 550 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 551 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 552 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 553 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 554 | */ |
| 555 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 556 | |
| 557 | /** |
| 558 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 559 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 560 | */ |
| 561 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 562 | |
| 563 | /** |
| 564 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 565 | * allow its data copied only to the account specified by |
| 566 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 567 | */ |
| 568 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 569 | |
| 570 | /** |
| 571 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 572 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 573 | */ |
| 574 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 575 | |
| 576 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 577 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 578 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 579 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 580 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 581 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 582 | |
| 583 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 584 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 585 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 586 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 587 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 588 | |
| 589 | /** |
| 590 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 591 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 592 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 593 | */ |
| 594 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 595 | |
| 596 | /** |
| 597 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 598 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 599 | */ |
| 600 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 601 | |
| 602 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 603 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 604 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 605 | * to which the directory supports contact photos. |
| 606 | */ |
| 607 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 608 | |
| 609 | /** |
| 610 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 611 | * does not provide any photos. |
| 612 | */ |
| 613 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 614 | |
| 615 | /** |
| 616 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 617 | * can only produce small size thumbnails of contact photos. |
| 618 | */ |
| 619 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 620 | |
| 621 | /** |
| 622 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 623 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 624 | */ |
| 625 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 626 | |
| 627 | /** |
| 628 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 629 | * can produce thumbnails as well as full-size contact photos. |
| 630 | */ |
| 631 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 632 | |
| 633 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 634 | * Return TRUE if it is a remote stored directory. |
| 635 | */ |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 636 | public static boolean isRemoteDirectoryId(long directoryId) { |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 637 | return directoryId != Directory.DEFAULT |
| 638 | && directoryId != Directory.LOCAL_INVISIBLE |
| 639 | && directoryId != Directory.ENTERPRISE_DEFAULT |
| 640 | && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE; |
| 641 | } |
| 642 | |
| 643 | /** |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 644 | * Return TRUE if it is a remote stored directory. TODO: Remove this method once all |
| 645 | * internal apps are not using this API. |
| 646 | * |
| 647 | * @hide |
| 648 | */ |
| 649 | public static boolean isRemoteDirectory(long directoryId) { |
| 650 | return isRemoteDirectoryId(directoryId); |
| 651 | } |
| 652 | |
| 653 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 654 | * Return TRUE if a directory ID is from the contacts provider on the enterprise profile. |
| 655 | * |
| 656 | */ |
| 657 | public static boolean isEnterpriseDirectoryId(long directoryId) { |
| 658 | return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE; |
| 659 | } |
| 660 | |
| 661 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 662 | * Notifies the system of a change in the list of directories handled by |
| 663 | * a particular directory provider. The Contacts provider will turn around |
| 664 | * and send a query to the directory provider for the full list of directories, |
| 665 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 666 | */ |
| 667 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 668 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 669 | // No data needs to be sent back, because the provider can infer the calling |
| 670 | // package from binder. |
| 671 | ContentValues contentValues = new ContentValues(); |
| 672 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 673 | } |
Makoto Onuki | 296a5fd | 2016-10-12 13:18:08 -0700 | [diff] [blame] | 674 | |
| 675 | /** |
| 676 | * A query parameter that's passed to directory providers which indicates the client |
| 677 | * package name that has made the query requests. |
| 678 | */ |
| 679 | public static final String CALLER_PACKAGE_PARAM_KEY = "callerPackage"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 683 | * @hide should be removed when users are updated to refer to SyncState |
| 684 | * @deprecated use SyncState instead |
| 685 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 686 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 687 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 688 | } |
| 689 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 690 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 691 | * A table provided for sync adapters to use for storing private sync state data for contacts. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 692 | * |
| 693 | * @see SyncStateContract |
| 694 | */ |
| 695 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 696 | /** |
| 697 | * This utility class cannot be instantiated |
| 698 | */ |
| 699 | private SyncState() {} |
| 700 | |
| 701 | public static final String CONTENT_DIRECTORY = |
| 702 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 703 | |
| 704 | /** |
| 705 | * The content:// style URI for this table |
| 706 | */ |
| 707 | public static final Uri CONTENT_URI = |
| 708 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 709 | |
| 710 | /** |
| 711 | * @see android.provider.SyncStateContract.Helpers#get |
| 712 | */ |
| 713 | public static byte[] get(ContentProviderClient provider, Account account) |
| 714 | throws RemoteException { |
| 715 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 716 | } |
| 717 | |
| 718 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 719 | * @see android.provider.SyncStateContract.Helpers#get |
| 720 | */ |
| 721 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 722 | throws RemoteException { |
| 723 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 724 | } |
| 725 | |
| 726 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 727 | * @see android.provider.SyncStateContract.Helpers#set |
| 728 | */ |
| 729 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 730 | throws RemoteException { |
| 731 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 732 | } |
| 733 | |
| 734 | /** |
| 735 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 736 | */ |
| 737 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 738 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 739 | } |
| 740 | } |
| 741 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 742 | |
| 743 | /** |
| 744 | * A table provided for sync adapters to use for storing private sync state data for the |
| 745 | * user's personal profile. |
| 746 | * |
| 747 | * @see SyncStateContract |
| 748 | */ |
| 749 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 750 | /** |
| 751 | * This utility class cannot be instantiated |
| 752 | */ |
| 753 | private ProfileSyncState() {} |
| 754 | |
| 755 | public static final String CONTENT_DIRECTORY = |
| 756 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 757 | |
| 758 | /** |
| 759 | * The content:// style URI for this table |
| 760 | */ |
| 761 | public static final Uri CONTENT_URI = |
| 762 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 763 | |
| 764 | /** |
| 765 | * @see android.provider.SyncStateContract.Helpers#get |
| 766 | */ |
| 767 | public static byte[] get(ContentProviderClient provider, Account account) |
| 768 | throws RemoteException { |
| 769 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 770 | } |
| 771 | |
| 772 | /** |
| 773 | * @see android.provider.SyncStateContract.Helpers#get |
| 774 | */ |
| 775 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 776 | throws RemoteException { |
| 777 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * @see android.provider.SyncStateContract.Helpers#set |
| 782 | */ |
| 783 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 784 | throws RemoteException { |
| 785 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 790 | */ |
| 791 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 792 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 793 | } |
| 794 | } |
| 795 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 796 | /** |
| 797 | * Generic columns for use by sync adapters. The specific functions of |
| 798 | * these columns are private to the sync adapter. Other clients of the API |
| 799 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 800 | * |
| 801 | * @see RawContacts |
| 802 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 803 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 804 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 805 | |
| 806 | /** Generic column for use by sync adapters. */ |
| 807 | public static final String SYNC1 = "sync1"; |
| 808 | /** Generic column for use by sync adapters. */ |
| 809 | public static final String SYNC2 = "sync2"; |
| 810 | /** Generic column for use by sync adapters. */ |
| 811 | public static final String SYNC3 = "sync3"; |
| 812 | /** Generic column for use by sync adapters. */ |
| 813 | public static final String SYNC4 = "sync4"; |
| 814 | } |
| 815 | |
| 816 | /** |
| 817 | * Columns that appear when each row of a table belongs to a specific |
| 818 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 819 | * |
| 820 | * @see RawContacts |
| 821 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 822 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 823 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 824 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 825 | * The name of the account instance to which this row belongs, which when paired with |
| 826 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 827 | * <P>Type: TEXT</P> |
| 828 | */ |
| 829 | public static final String ACCOUNT_NAME = "account_name"; |
| 830 | |
| 831 | /** |
| 832 | * The type of account to which this row belongs, which when paired with |
| 833 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 834 | * <P>Type: TEXT</P> |
| 835 | */ |
| 836 | public static final String ACCOUNT_TYPE = "account_type"; |
| 837 | |
| 838 | /** |
| 839 | * String that uniquely identifies this row to its source account. |
| 840 | * <P>Type: TEXT</P> |
| 841 | */ |
| 842 | public static final String SOURCE_ID = "sourceid"; |
| 843 | |
| 844 | /** |
| 845 | * Version number that is updated whenever this row or its related data |
| 846 | * changes. |
| 847 | * <P>Type: INTEGER</P> |
| 848 | */ |
| 849 | public static final String VERSION = "version"; |
| 850 | |
| 851 | /** |
| 852 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 853 | * to be synchronized by its owning account. |
| 854 | * <P>Type: INTEGER (boolean)</P> |
| 855 | */ |
| 856 | public static final String DIRTY = "dirty"; |
| 857 | } |
| 858 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 859 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 860 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 861 | * preferences for, or interactions with, the contact. |
| 862 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 863 | * @see Contacts |
| 864 | * @see RawContacts |
| 865 | * @see ContactsContract.Data |
| 866 | * @see PhoneLookup |
| 867 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 868 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 869 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 870 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 871 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 872 | * <P>Type: INTEGER</P> |
| 873 | */ |
| 874 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 875 | |
| 876 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 877 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 878 | * <P>Type: INTEGER</P> |
| 879 | */ |
| 880 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 881 | |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 882 | /** @hide Raw value. */ |
| 883 | public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED; |
| 884 | |
| 885 | /** @hide Raw value. */ |
| 886 | public static final String RAW_LAST_TIME_CONTACTED = |
| 887 | HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED; |
| 888 | |
| 889 | /** |
| 890 | * @hide |
| 891 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 892 | */ |
| 893 | public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED; |
| 894 | |
| 895 | /** |
| 896 | * @hide |
| 897 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 898 | */ |
| 899 | public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED; |
| 900 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 901 | /** |
| 902 | * Is the contact starred? |
| 903 | * <P>Type: INTEGER (boolean)</P> |
| 904 | */ |
| 905 | public static final String STARRED = "starred"; |
| 906 | |
| 907 | /** |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 908 | * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED}, |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 909 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 910 | * <P>Type: INTEGER </P> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 911 | */ |
| 912 | public static final String PINNED = "pinned"; |
| 913 | |
| 914 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 915 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 916 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 917 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 918 | */ |
| 919 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 920 | |
| 921 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 922 | * Whether the contact should always be sent to voicemail. If missing, |
| 923 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 924 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 925 | */ |
| 926 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 927 | } |
| 928 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 929 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 930 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 931 | * properties of the contact, as opposed to the user-specified options |
| 932 | * found in {@link ContactOptionsColumns}. |
| 933 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 934 | * @see Contacts |
| 935 | * @see ContactsContract.Data |
| 936 | * @see PhoneLookup |
| 937 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 938 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 939 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 940 | /** |
| 941 | * The display name for the contact. |
| 942 | * <P>Type: TEXT</P> |
| 943 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 944 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 945 | |
| 946 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 947 | * Reference to the row in the RawContacts table holding the contact name. |
| 948 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 949 | */ |
| 950 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 951 | |
| 952 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 953 | * Reference to the row in the data table holding the photo. A photo can |
| 954 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 955 | * and {@link #PHOTO_URI}). |
| 956 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 957 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 958 | * contacts returned by non-local directories (see {@link Directory}). |
| 959 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 960 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 961 | */ |
| 962 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 963 | |
| 964 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 965 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 966 | * {@link #PHOTO_URI}. The ID can also be used with |
| 967 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 968 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 969 | * |
| 970 | * <P>Type: INTEGER</P> |
| 971 | */ |
| 972 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 973 | |
| 974 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 975 | * 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] | 976 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 977 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 978 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 979 | * 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] | 980 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 981 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 982 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 983 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 984 | * |
| 985 | * <P>Type: TEXT</P> |
| 986 | */ |
| 987 | public static final String PHOTO_URI = "photo_uri"; |
| 988 | |
| 989 | /** |
| 990 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 991 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 992 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 993 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 994 | * If the content provider does not differentiate between full-size photos |
| 995 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 996 | * 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] | 997 | * |
| 998 | * <P>Type: TEXT</P> |
| 999 | */ |
| 1000 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 1001 | |
| 1002 | /** |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1003 | * Flag that reflects whether the contact exists inside the default directory. |
| 1004 | * Ie, whether the contact is designed to only be visible outside search. |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1005 | */ |
| 1006 | public static final String IN_DEFAULT_DIRECTORY = "in_default_directory"; |
| 1007 | |
| 1008 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1009 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 1010 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1011 | */ |
| 1012 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1013 | |
| 1014 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1015 | * Flag that reflects whether this contact represents the user's |
| 1016 | * personal profile entry. |
| 1017 | */ |
| 1018 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 1019 | |
| 1020 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1021 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 1022 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1023 | * <P>Type: INTEGER</P> |
| 1024 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1025 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1026 | |
| 1027 | /** |
| 1028 | * An opaque value that contains hints on how to find the contact if |
| 1029 | * its row id changed as a result of a sync or aggregation. |
| 1030 | */ |
| 1031 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 1032 | |
| 1033 | /** |
| 1034 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 1035 | * includes updates to all data associated with this contact including raw contacts. Any |
| 1036 | * modification (including deletes and inserts) of underlying contact data are also |
| 1037 | * reflected in this timestamp. |
| 1038 | */ |
| 1039 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 1040 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1041 | } |
| 1042 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1043 | /** |
| 1044 | * @see Contacts |
| 1045 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 1046 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1047 | /** |
| 1048 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 1049 | * definitions. |
| 1050 | * <p>Type: NUMBER</p> |
| 1051 | */ |
| 1052 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 1053 | |
| 1054 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 1055 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 1056 | * definitions. |
| 1057 | * <p>Type: NUMBER</p> |
| 1058 | */ |
| 1059 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 1060 | |
| 1061 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1062 | * Contact's latest status update. |
| 1063 | * <p>Type: TEXT</p> |
| 1064 | */ |
| 1065 | public static final String CONTACT_STATUS = "contact_status"; |
| 1066 | |
| 1067 | /** |
| 1068 | * The absolute time in milliseconds when the latest status was |
| 1069 | * inserted/updated. |
| 1070 | * <p>Type: NUMBER</p> |
| 1071 | */ |
| 1072 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 1073 | |
| 1074 | /** |
| 1075 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1076 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1077 | */ |
| 1078 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 1079 | |
| 1080 | /** |
| 1081 | * The resource ID of the label describing the source of contact |
| 1082 | * status, e.g. "Google Talk". This resource is scoped by the |
| 1083 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1084 | * <p>Type: NUMBER</p> |
| 1085 | */ |
| 1086 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 1087 | |
| 1088 | /** |
| 1089 | * The resource ID of the icon for the source of contact status. This |
| 1090 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1091 | * <p>Type: NUMBER</p> |
| 1092 | */ |
| 1093 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 1094 | } |
| 1095 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1096 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1097 | * Constants for various styles of combining given name, family name etc into |
| 1098 | * a full name. For example, the western tradition follows the pattern |
| 1099 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 1100 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 1101 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 1102 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1103 | */ |
| 1104 | public interface FullNameStyle { |
| 1105 | public static final int UNDEFINED = 0; |
| 1106 | public static final int WESTERN = 1; |
| 1107 | |
| 1108 | /** |
| 1109 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 1110 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 1111 | */ |
| 1112 | public static final int CJK = 2; |
| 1113 | |
| 1114 | public static final int CHINESE = 3; |
| 1115 | public static final int JAPANESE = 4; |
| 1116 | public static final int KOREAN = 5; |
| 1117 | } |
| 1118 | |
| 1119 | /** |
| 1120 | * 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] | 1121 | */ |
| 1122 | public interface PhoneticNameStyle { |
| 1123 | public static final int UNDEFINED = 0; |
| 1124 | |
| 1125 | /** |
| 1126 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 1127 | * shown in UIs, but used for searches and sorting. |
| 1128 | */ |
| 1129 | public static final int PINYIN = 3; |
| 1130 | |
| 1131 | /** |
| 1132 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1133 | * of a Japanese names. |
| 1134 | */ |
| 1135 | public static final int JAPANESE = 4; |
| 1136 | |
| 1137 | /** |
| 1138 | * Hangul is the Korean phonetic alphabet. |
| 1139 | */ |
| 1140 | public static final int KOREAN = 5; |
| 1141 | } |
| 1142 | |
| 1143 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1144 | * Types of data used to produce the display name for a contact. In the order |
| 1145 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1146 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME}, |
| 1147 | * {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1148 | */ |
| 1149 | public interface DisplayNameSources { |
| 1150 | public static final int UNDEFINED = 0; |
| 1151 | public static final int EMAIL = 10; |
| 1152 | public static final int PHONE = 20; |
| 1153 | public static final int ORGANIZATION = 30; |
| 1154 | public static final int NICKNAME = 35; |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1155 | /** Display name comes from a structured name that only has phonetic components. */ |
| 1156 | public static final int STRUCTURED_PHONETIC_NAME = 37; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1157 | public static final int STRUCTURED_NAME = 40; |
| 1158 | } |
| 1159 | |
| 1160 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1161 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1162 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1163 | * @see Contacts |
| 1164 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1165 | */ |
| 1166 | protected interface ContactNameColumns { |
| 1167 | |
| 1168 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1169 | * 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] | 1170 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1171 | */ |
| 1172 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1173 | |
| 1174 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1175 | * <p> |
| 1176 | * The standard text shown as the contact's display name, based on the best |
| 1177 | * available information for the contact (for example, it might be the email address |
| 1178 | * if the name is not available). |
| 1179 | * The information actually used to compute the name is stored in |
| 1180 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1181 | * </p> |
| 1182 | * <p> |
| 1183 | * A contacts provider is free to choose whatever representation makes most |
| 1184 | * sense for its target market. |
| 1185 | * For example in the default Android Open Source Project implementation, |
| 1186 | * if the display name is |
| 1187 | * based on the structured name and the structured name follows |
| 1188 | * the Western full-name style, then this field contains the "given name first" |
| 1189 | * version of the full name. |
| 1190 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1191 | * |
| 1192 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1193 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1194 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1195 | |
| 1196 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1197 | * <p> |
| 1198 | * An alternative representation of the display name, such as "family name first" |
| 1199 | * instead of "given name first" for Western names. If an alternative is not |
| 1200 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1201 | * </p> |
| 1202 | * <p> |
| 1203 | * A contacts provider is free to provide alternatives as necessary for |
| 1204 | * its target market. |
| 1205 | * For example the default Android Open Source Project contacts provider |
| 1206 | * currently provides an |
| 1207 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1208 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1209 | * the Western full name style, then the field contains the "family name first" |
| 1210 | * version of the full name. |
| 1211 | * Other cases may be added later. |
| 1212 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1213 | */ |
| 1214 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1215 | |
| 1216 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1217 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1218 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1219 | */ |
| 1220 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1221 | |
| 1222 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1223 | * <p> |
| 1224 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1225 | * {@link #PHONETIC_NAME_STYLE}. |
| 1226 | * </p> |
| 1227 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1228 | * The value may be set manually by the user. This capability is of |
| 1229 | * interest only in countries with commonly used phonetic alphabets, |
| 1230 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1231 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1232 | */ |
| 1233 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1234 | |
| 1235 | /** |
| 1236 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1237 | * names in address books. The default |
| 1238 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1239 | * 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] | 1240 | * it is the Hiragana version of the phonetic name. |
| 1241 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1242 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1243 | |
| 1244 | /** |
| 1245 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1246 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1247 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1248 | */ |
| 1249 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1250 | } |
| 1251 | |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1252 | interface ContactCounts { |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1253 | |
| 1254 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1255 | * Add this query parameter to a URI to get back row counts grouped by the address book |
| 1256 | * index as cursor extras. For most languages it is the first letter of the sort key. This |
| 1257 | * parameter does not affect the main content of the cursor. |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1258 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1259 | * <p> |
| 1260 | * <pre> |
| 1261 | * Example: |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1262 | * |
| 1263 | * import android.provider.ContactsContract.Contacts; |
| 1264 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1265 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1266 | * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1267 | * .build(); |
| 1268 | * Cursor cursor = getContentResolver().query(uri, |
| 1269 | * new String[] {Contacts.DISPLAY_NAME}, |
| 1270 | * null, null, null); |
| 1271 | * Bundle bundle = cursor.getExtras(); |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1272 | * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && |
| 1273 | * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1274 | * String sections[] = |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1275 | * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); |
| 1276 | * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1277 | * } |
| 1278 | * </pre> |
| 1279 | * </p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1280 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1281 | public static final String EXTRA_ADDRESS_BOOK_INDEX = |
| 1282 | "android.provider.extra.ADDRESS_BOOK_INDEX"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1283 | |
| 1284 | /** |
| 1285 | * The array of address book index titles, which are returned in the |
| 1286 | * same order as the data in the cursor. |
| 1287 | * <p>TYPE: String[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1288 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1289 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = |
| 1290 | "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1291 | |
| 1292 | /** |
| 1293 | * The array of group counts for the corresponding group. Contains the same number |
| 1294 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1295 | * <p>TYPE: int[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1296 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1297 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = |
| 1298 | "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1302 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1303 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1304 | * <h3>Operations</h3> |
| 1305 | * <dl> |
| 1306 | * <dt><b>Insert</b></dt> |
| 1307 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1308 | * inserted, the provider will first try to find a Contact representing the |
| 1309 | * same person. If one is found, the raw contact's |
| 1310 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1311 | * Contact. If no match is found, the provider automatically inserts a new |
| 1312 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1313 | * of the newly inserted raw contact.</dd> |
| 1314 | * <dt><b>Update</b></dt> |
| 1315 | * <dd>Only certain columns of Contact are modifiable: |
| 1316 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1317 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1318 | * these columns on the Contact also changes them on all constituent raw |
| 1319 | * contacts.</dd> |
| 1320 | * <dt><b>Delete</b></dt> |
| 1321 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1322 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1323 | * will notice the deletions of their respective raw contacts and remove |
| 1324 | * them from their back end storage.</dd> |
| 1325 | * <dt><b>Query</b></dt> |
| 1326 | * <dd> |
| 1327 | * <ul> |
| 1328 | * <li>If you need to read an individual contact, consider using |
| 1329 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1330 | * <li>If you need to look up a contact by the phone number, use |
| 1331 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1332 | * which is optimized for this purpose.</li> |
| 1333 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1334 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1335 | * <li>If you need to look up a contact by some data element like email |
| 1336 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1337 | * The result will contain contact ID, name etc. |
| 1338 | * </ul> |
| 1339 | * </dd> |
| 1340 | * </dl> |
| 1341 | * <h2>Columns</h2> |
| 1342 | * <table class="jd-sumtable"> |
| 1343 | * <tr> |
| 1344 | * <th colspan='4'>Contacts</th> |
| 1345 | * </tr> |
| 1346 | * <tr> |
| 1347 | * <td>long</td> |
| 1348 | * <td>{@link #_ID}</td> |
| 1349 | * <td>read-only</td> |
| 1350 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1351 | * </tr> |
| 1352 | * <tr> |
| 1353 | * <td>String</td> |
| 1354 | * <td>{@link #LOOKUP_KEY}</td> |
| 1355 | * <td>read-only</td> |
| 1356 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1357 | * row id changed as a result of a sync or aggregation.</td> |
| 1358 | * </tr> |
| 1359 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1360 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1361 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1362 | * <td>read-only</td> |
| 1363 | * <td>The ID of the raw contact that contributes the display name |
| 1364 | * to the aggregate contact. During aggregation one of the constituent |
| 1365 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1366 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1367 | * </tr> |
| 1368 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1369 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1370 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1371 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1372 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1373 | * 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] | 1374 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1375 | * </tr> |
| 1376 | * <tr> |
| 1377 | * <td>long</td> |
| 1378 | * <td>{@link #PHOTO_ID}</td> |
| 1379 | * <td>read-only</td> |
| 1380 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1381 | * That row has the mime type |
| 1382 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1383 | * is computed automatically based on the |
| 1384 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1385 | * that mime type.</td> |
| 1386 | * </tr> |
| 1387 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1388 | * <td>long</td> |
| 1389 | * <td>{@link #PHOTO_URI}</td> |
| 1390 | * <td>read-only</td> |
| 1391 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1392 | * column is the preferred method of retrieving the contact photo.</td> |
| 1393 | * </tr> |
| 1394 | * <tr> |
| 1395 | * <td>long</td> |
| 1396 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1397 | * <td>read-only</td> |
| 1398 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1399 | * column is the preferred method of retrieving the contact photo.</td> |
| 1400 | * </tr> |
| 1401 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1402 | * <td>int</td> |
| 1403 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1404 | * <td>read-only</td> |
| 1405 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1406 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1407 | * visible group; "0" otherwise.</td> |
| 1408 | * </tr> |
| 1409 | * <tr> |
| 1410 | * <td>int</td> |
| 1411 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1412 | * <td>read-only</td> |
| 1413 | * <td>An indicator of whether this contact has at least one phone number. |
| 1414 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1415 | * </tr> |
| 1416 | * <tr> |
| 1417 | * <td>int</td> |
| 1418 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1419 | * <td>read/write</td> |
| 1420 | * <td>The number of times the contact has been contacted. See |
| 1421 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1422 | * computed automatically as the maximum number of times contacted among all |
| 1423 | * constituent raw contacts. Setting this field automatically changes the |
| 1424 | * corresponding field on all constituent raw contacts.</td> |
| 1425 | * </tr> |
| 1426 | * <tr> |
| 1427 | * <td>long</td> |
| 1428 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1429 | * <td>read/write</td> |
| 1430 | * <td>The timestamp of the last time the contact was contacted. See |
| 1431 | * {@link #markAsContacted}. Setting this field also automatically |
| 1432 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1433 | * this field is computed automatically as the latest time contacted of all |
| 1434 | * constituent raw contacts. Setting this field automatically changes the |
| 1435 | * corresponding field on all constituent raw contacts.</td> |
| 1436 | * </tr> |
| 1437 | * <tr> |
| 1438 | * <td>int</td> |
| 1439 | * <td>{@link #STARRED}</td> |
| 1440 | * <td>read/write</td> |
| 1441 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1442 | * When raw contacts are aggregated, this field is automatically computed: |
| 1443 | * if any constituent raw contacts are starred, then this field is set to |
| 1444 | * '1'. Setting this field automatically changes the corresponding field on |
| 1445 | * all constituent raw contacts.</td> |
| 1446 | * </tr> |
| 1447 | * <tr> |
| 1448 | * <td>String</td> |
| 1449 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1450 | * <td>read/write</td> |
| 1451 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1452 | * URI returned by an activity launched with the |
| 1453 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1454 | * </tr> |
| 1455 | * <tr> |
| 1456 | * <td>int</td> |
| 1457 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1458 | * <td>read/write</td> |
| 1459 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1460 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1461 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1462 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1463 | * to '1'. Setting this field automatically changes the corresponding field |
| 1464 | * on all constituent raw contacts.</td> |
| 1465 | * </tr> |
| 1466 | * <tr> |
| 1467 | * <td>int</td> |
| 1468 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1469 | * <td>read-only</td> |
| 1470 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1471 | * status definitions. Automatically computed as the highest presence of all |
| 1472 | * constituent raw contacts. The provider may choose not to store this value |
| 1473 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1474 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1475 | * </tr> |
| 1476 | * <tr> |
| 1477 | * <td>String</td> |
| 1478 | * <td>{@link #CONTACT_STATUS}</td> |
| 1479 | * <td>read-only</td> |
| 1480 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1481 | * of all constituent raw contacts' status updates.</td> |
| 1482 | * </tr> |
| 1483 | * <tr> |
| 1484 | * <td>long</td> |
| 1485 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1486 | * <td>read-only</td> |
| 1487 | * <td>The absolute time in milliseconds when the latest status was |
| 1488 | * inserted/updated.</td> |
| 1489 | * </tr> |
| 1490 | * <tr> |
| 1491 | * <td>String</td> |
| 1492 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1493 | * <td>read-only</td> |
| 1494 | * <td> The package containing resources for this status: label and icon.</td> |
| 1495 | * </tr> |
| 1496 | * <tr> |
| 1497 | * <td>long</td> |
| 1498 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1499 | * <td>read-only</td> |
| 1500 | * <td>The resource ID of the label describing the source of contact status, |
| 1501 | * e.g. "Google Talk". This resource is scoped by the |
| 1502 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1503 | * </tr> |
| 1504 | * <tr> |
| 1505 | * <td>long</td> |
| 1506 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1507 | * <td>read-only</td> |
| 1508 | * <td>The resource ID of the icon for the source of contact status. This |
| 1509 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1510 | * </tr> |
| 1511 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1512 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1513 | public static class Contacts implements BaseColumns, ContactsColumns, |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1514 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1515 | /** |
| 1516 | * This utility class cannot be instantiated |
| 1517 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1518 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1519 | |
| 1520 | /** |
| 1521 | * The content:// style URI for this table |
| 1522 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1523 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1524 | |
| 1525 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1526 | * Special contacts URI to refer to contacts on the corp profile from the personal |
| 1527 | * profile. |
| 1528 | * |
| 1529 | * It's supported only by a few specific places for referring to contact pictures that |
| 1530 | * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from |
| 1531 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI. |
| 1532 | * |
| 1533 | * @hide |
| 1534 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 1535 | @UnsupportedAppUsage |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1536 | public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1537 | "contacts_corp"); |
| 1538 | |
| 1539 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1540 | * A content:// style URI for this table that should be used to create |
| 1541 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1542 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1543 | * It can optionally also have a "/" and last known contact ID appended after |
| 1544 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1545 | * <p> |
| 1546 | * As long as the contact's row ID remains the same, this URI is |
| 1547 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1548 | * as a result of a sync or aggregation, this URI will look up the |
| 1549 | * contact using indirect information (sync IDs or constituent raw |
| 1550 | * contacts). |
| 1551 | * <p> |
| 1552 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1553 | * form, ready for use in a URI. |
| 1554 | */ |
| 1555 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1556 | "lookup"); |
| 1557 | |
| 1558 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1559 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1560 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1561 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1562 | * {@link OpenableColumns} columns when queried, or returns the |
| 1563 | * referenced contact formatted as a vCard when opened through |
| 1564 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1565 | */ |
| 1566 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1567 | "as_vcard"); |
| 1568 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1569 | /** |
| 1570 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1571 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1572 | * vcard should not contain a photo. |
| 1573 | * |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1574 | * This is useful for obtaining a space efficient vcard. |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1575 | */ |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1576 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo"; |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1577 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1578 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1579 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1580 | * created by appending {@link #LOOKUP_KEY} using |
| 1581 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1582 | * joined with the colon (":") separator, and the resulting string encoded. |
| 1583 | * |
| 1584 | * Provides {@link OpenableColumns} columns when queried, or returns the |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1585 | * referenced contact formatted as a vCard when opened through |
| 1586 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1587 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1588 | * <p> |
| 1589 | * Usage example: |
| 1590 | * <dl> |
| 1591 | * <dt>The following code snippet creates a multi-vcard URI that references all the |
| 1592 | * contacts in a user's database.</dt> |
| 1593 | * <dd> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1594 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1595 | * <pre> |
| 1596 | * public Uri getAllContactsVcardUri() { |
| 1597 | * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, |
| 1598 | * new String[] {Contacts.LOOKUP_KEY}, null, null, null); |
| 1599 | * if (cursor == null) { |
| 1600 | * return null; |
| 1601 | * } |
| 1602 | * try { |
| 1603 | * StringBuilder uriListBuilder = new StringBuilder(); |
| 1604 | * int index = 0; |
| 1605 | * while (cursor.moveToNext()) { |
| 1606 | * if (index != 0) uriListBuilder.append(':'); |
| 1607 | * uriListBuilder.append(cursor.getString(0)); |
| 1608 | * index++; |
| 1609 | * } |
| 1610 | * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, |
| 1611 | * Uri.encode(uriListBuilder.toString())); |
| 1612 | * } finally { |
| 1613 | * cursor.close(); |
| 1614 | * } |
| 1615 | * } |
| 1616 | * </pre> |
| 1617 | * |
| 1618 | * </p> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1619 | */ |
| 1620 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1621 | "as_multi_vcard"); |
| 1622 | |
| 1623 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1624 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1625 | * requested {@link Contacts} entry. |
| 1626 | * |
| 1627 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1628 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1629 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1630 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1631 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1632 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1633 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1634 | if (c == null) { |
| 1635 | return null; |
| 1636 | } |
| 1637 | |
| 1638 | try { |
| 1639 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1640 | final String lookupKey = c.getString(0); |
| 1641 | final long contactId = c.getLong(1); |
| 1642 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1643 | } |
| 1644 | } finally { |
| 1645 | c.close(); |
| 1646 | } |
| 1647 | return null; |
| 1648 | } |
| 1649 | |
| 1650 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1651 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1652 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1653 | * <p> |
| 1654 | * Returns null if unable to construct a valid lookup URI from the |
| 1655 | * provided parameters. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1656 | */ |
| 1657 | public static Uri getLookupUri(long contactId, String lookupKey) { |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1658 | if (TextUtils.isEmpty(lookupKey)) { |
| 1659 | return null; |
| 1660 | } |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1661 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1662 | lookupKey), contactId); |
| 1663 | } |
| 1664 | |
| 1665 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1666 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1667 | * <p> |
| 1668 | * Returns null if the contact cannot be found. |
| 1669 | */ |
| 1670 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1671 | if (lookupUri == null) { |
| 1672 | return null; |
| 1673 | } |
| 1674 | |
| 1675 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1676 | if (c == null) { |
| 1677 | return null; |
| 1678 | } |
| 1679 | |
| 1680 | try { |
| 1681 | if (c.moveToFirst()) { |
| 1682 | long contactId = c.getLong(0); |
| 1683 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1684 | } |
| 1685 | } finally { |
| 1686 | c.close(); |
| 1687 | } |
| 1688 | return null; |
| 1689 | } |
| 1690 | |
| 1691 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1692 | * Mark a contact as having been contacted. Updates two fields: |
| 1693 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1694 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1695 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1696 | * |
| 1697 | * @param resolver the ContentResolver to use |
| 1698 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1699 | * |
| 1700 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1701 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1702 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1703 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1704 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1705 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1706 | ContentValues values = new ContentValues(); |
| 1707 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 1708 | values.put(LR_LAST_TIME_CONTACTED, System.currentTimeMillis()); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1709 | resolver.update(uri, values, null, null); |
| 1710 | } |
| 1711 | |
| 1712 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1713 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1714 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1715 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1716 | * as an additional path segment after this URI. |
| 1717 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1718 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1719 | CONTENT_URI, "filter"); |
| 1720 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1721 | /** |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1722 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 1723 | * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters, |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 1724 | * otherwise it will throw IllegalArgumentException. |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1725 | */ |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1726 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1727 | CONTENT_URI, "filter_enterprise"); |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1728 | |
| 1729 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1730 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1731 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1732 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1733 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1734 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1735 | CONTENT_URI, "strequent"); |
| 1736 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1737 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 1738 | * The content:// style URI for showing a list of frequently contacted people. |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1739 | */ |
| 1740 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1741 | CONTENT_URI, "frequent"); |
| 1742 | |
| 1743 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1744 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1745 | * {@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] | 1746 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1747 | * as an additional path segment after this URI. |
| 1748 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1749 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1750 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1751 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1752 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1753 | CONTENT_URI, "group"); |
| 1754 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1755 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1756 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1757 | * people. |
| 1758 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1759 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1760 | |
| 1761 | /** |
| 1762 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1763 | * person. |
| 1764 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1765 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1766 | |
| 1767 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1768 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1769 | * person. |
| 1770 | */ |
| 1771 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1772 | |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1773 | /** |
| 1774 | * Mimimal ID for corp contacts returned from |
| 1775 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1776 | * |
| 1777 | * @hide |
| 1778 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1779 | 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] | 1780 | |
| 1781 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 1782 | * Prefix for corp contacts returned from |
| 1783 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1784 | * |
| 1785 | * @hide |
| 1786 | */ |
| 1787 | public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-"; |
| 1788 | |
| 1789 | /** |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1790 | * 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] | 1791 | * |
| 1792 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. |
| 1793 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1794 | public static boolean isEnterpriseContactId(long contactId) { |
| 1795 | return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1796 | } |
| 1797 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1798 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1799 | * 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] | 1800 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1801 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1802 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1803 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1804 | /** |
| 1805 | * no public constructor since this is a utility class |
| 1806 | */ |
| 1807 | private Data() {} |
| 1808 | |
| 1809 | /** |
| 1810 | * The directory twig for this sub-table |
| 1811 | */ |
| 1812 | public static final String CONTENT_DIRECTORY = "data"; |
| 1813 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1814 | |
| 1815 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1816 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1817 | * A sub-directory of a contact that contains all of its |
| 1818 | * {@link ContactsContract.RawContacts} as well as |
| 1819 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1820 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1821 | * </p> |
| 1822 | * <p> |
| 1823 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1824 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1825 | * the data rows. Entity always contains at least one row per |
| 1826 | * constituent raw contact, even if there are no actual data rows. In |
| 1827 | * this case the {@link #DATA_ID} field will be null. |
| 1828 | * </p> |
| 1829 | * <p> |
| 1830 | * Entity reads all data for the entire contact in one transaction, to |
| 1831 | * guarantee consistency. There is significant data duplication |
| 1832 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1833 | * columns), so the benefits of transactional consistency should be weighed |
| 1834 | * against the cost of transferring large amounts of denormalized data |
| 1835 | * from the Provider. |
| 1836 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1837 | * <p> |
| 1838 | * To reduce the amount of data duplication the contacts provider and directory |
| 1839 | * providers implementing this protocol are allowed to provide common Contacts |
| 1840 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1841 | * leave them as null in subsequent rows. |
| 1842 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1843 | */ |
| 1844 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1845 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
Paul Soulos | 42cdda8 | 2014-06-19 16:13:38 -0700 | [diff] [blame] | 1846 | StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1847 | /** |
| 1848 | * no public constructor since this is a utility class |
| 1849 | */ |
| 1850 | private Entity() { |
| 1851 | } |
| 1852 | |
| 1853 | /** |
| 1854 | * The directory twig for this sub-table |
| 1855 | */ |
| 1856 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1857 | |
| 1858 | /** |
| 1859 | * The ID of the raw contact row. |
| 1860 | * <P>Type: INTEGER</P> |
| 1861 | */ |
| 1862 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1863 | |
| 1864 | /** |
| 1865 | * The ID of the data row. The value will be null if this raw contact has no |
| 1866 | * data rows. |
| 1867 | * <P>Type: INTEGER</P> |
| 1868 | */ |
| 1869 | public static final String DATA_ID = "data_id"; |
| 1870 | } |
| 1871 | |
| 1872 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1873 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1874 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1875 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1876 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1877 | * </p> |
| 1878 | * <p> |
| 1879 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1880 | * permission. |
| 1881 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1882 | * |
| 1883 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1884 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1885 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1886 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1887 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1888 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1889 | public static final class StreamItems implements StreamItemsColumns { |
| 1890 | /** |
| 1891 | * no public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1892 | * |
| 1893 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1894 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1895 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1896 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1897 | private StreamItems() {} |
| 1898 | |
| 1899 | /** |
| 1900 | * The directory twig for this sub-table |
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. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1904 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1905 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1906 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1907 | } |
| 1908 | |
| 1909 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1910 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1911 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1912 | * contains all aggregation suggestions (other contacts). The |
| 1913 | * aggregation suggestions are computed based on approximate data |
| 1914 | * matches with this contact. |
| 1915 | * </p> |
| 1916 | * <p> |
| 1917 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1918 | * make sure the user experience is acceptable when the query runs for a |
| 1919 | * long time.</i> |
| 1920 | * <p> |
| 1921 | * Usage example: |
| 1922 | * |
| 1923 | * <pre> |
| 1924 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1925 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1926 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1927 | * .appendQueryParameter("limit", "3") |
| 1928 | * .build() |
| 1929 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1930 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1931 | * null, null, null); |
| 1932 | * </pre> |
| 1933 | * |
| 1934 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1935 | * <p> |
| 1936 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1937 | * {@link #CONTENT_LOOKUP_URI}. |
| 1938 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1939 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1940 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1941 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1942 | /** |
| 1943 | * No public constructor since this is a utility class |
| 1944 | */ |
| 1945 | private AggregationSuggestions() {} |
| 1946 | |
| 1947 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1948 | * 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] | 1949 | * type-to-filter, similar to |
| 1950 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1951 | */ |
| 1952 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1953 | |
| 1954 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1955 | * 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] | 1956 | * |
| 1957 | * @hide |
| 1958 | */ |
| 1959 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1960 | |
| 1961 | /** |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1962 | * A convenience builder for aggregation suggestion content URIs. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1963 | */ |
| 1964 | public static final class Builder { |
| 1965 | private long mContactId; |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1966 | private final ArrayList<String> mValues = new ArrayList<String>(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1967 | private int mLimit; |
| 1968 | |
| 1969 | /** |
| 1970 | * Optional existing contact ID. If it is not provided, the search |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1971 | * will be based exclusively on the values supplied with {@link #addNameParameter}. |
| 1972 | * |
| 1973 | * @param contactId contact to find aggregation suggestions for |
| 1974 | * @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] | 1975 | */ |
| 1976 | public Builder setContactId(long contactId) { |
| 1977 | this.mContactId = contactId; |
| 1978 | return this; |
| 1979 | } |
| 1980 | |
| 1981 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1982 | * Add a name to be used when searching for aggregation suggestions. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1983 | * |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1984 | * @param name name to find aggregation suggestions for |
| 1985 | * @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] | 1986 | */ |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1987 | public Builder addNameParameter(String name) { |
| 1988 | mValues.add(name); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1989 | return this; |
| 1990 | } |
| 1991 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1992 | /** |
| 1993 | * Sets the Maximum number of suggested aggregations that should be returned. |
| 1994 | * @param limit The maximum number of suggested aggregations |
| 1995 | * |
| 1996 | * @return This Builder object to allow for chaining of calls to builder methods |
| 1997 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1998 | public Builder setLimit(int limit) { |
| 1999 | mLimit = limit; |
| 2000 | return this; |
| 2001 | } |
| 2002 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2003 | /** |
| 2004 | * Combine all of the options that have been set and return a new {@link Uri} |
| 2005 | * object for fetching aggregation suggestions. |
| 2006 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2007 | public Uri build() { |
| 2008 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 2009 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 2010 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 2011 | if (mLimit != 0) { |
| 2012 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 2013 | } |
| 2014 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2015 | int count = mValues.size(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2016 | for (int i = 0; i < count; i++) { |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2017 | builder.appendQueryParameter("query", PARAMETER_MATCH_NAME |
| 2018 | + ":" + mValues.get(i)); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2019 | } |
| 2020 | |
| 2021 | return builder.build(); |
| 2022 | } |
| 2023 | } |
| 2024 | |
| 2025 | /** |
| 2026 | * @hide |
| 2027 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 2028 | @UnsupportedAppUsage |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2029 | public static final Builder builder() { |
| 2030 | return new Builder(); |
| 2031 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 2032 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2033 | |
| 2034 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2035 | * 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] | 2036 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 2037 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 2038 | * row, while the "display photo", if present, is a larger version stored as |
| 2039 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2040 | * <p> |
| 2041 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2042 | * <dl> |
| 2043 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 2044 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2045 | * <pre> |
| 2046 | * public InputStream openPhoto(long contactId) { |
| 2047 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2048 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 2049 | * Cursor cursor = getContentResolver().query(photoUri, |
| 2050 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 2051 | * if (cursor == null) { |
| 2052 | * return null; |
| 2053 | * } |
| 2054 | * try { |
| 2055 | * if (cursor.moveToFirst()) { |
| 2056 | * byte[] data = cursor.getBlob(0); |
| 2057 | * if (data != null) { |
| 2058 | * return new ByteArrayInputStream(data); |
| 2059 | * } |
| 2060 | * } |
| 2061 | * } finally { |
| 2062 | * cursor.close(); |
| 2063 | * } |
| 2064 | * return null; |
| 2065 | * } |
| 2066 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2067 | * </dd> |
| 2068 | * <dt>Retrieving the larger photo version</dt> |
| 2069 | * <dd> |
| 2070 | * <pre> |
| 2071 | * public InputStream openDisplayPhoto(long contactId) { |
| 2072 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2073 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 2074 | * try { |
| 2075 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2076 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2077 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2078 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2079 | * return null; |
| 2080 | * } |
| 2081 | * } |
| 2082 | * </pre> |
| 2083 | * </dd> |
| 2084 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2085 | * |
| 2086 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2087 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2088 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 2089 | * 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] | 2090 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2091 | * <p> |
| 2092 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 2093 | * {@link #CONTENT_LOOKUP_URI}. |
| 2094 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2095 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2096 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2097 | /** |
| 2098 | * no public constructor since this is a utility class |
| 2099 | */ |
| 2100 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2101 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2102 | /** |
| 2103 | * The directory twig for this sub-table |
| 2104 | */ |
| 2105 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2106 | |
| 2107 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2108 | * The directory twig for retrieving the full-size display photo. |
| 2109 | */ |
| 2110 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 2111 | |
| 2112 | /** |
| 2113 | * Full-size photo file ID of the raw contact. |
| 2114 | * See {@link ContactsContract.DisplayPhoto}. |
| 2115 | * <p> |
| 2116 | * Type: NUMBER |
| 2117 | */ |
| 2118 | public static final String PHOTO_FILE_ID = DATA14; |
| 2119 | |
| 2120 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2121 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 2122 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 2123 | * <p> |
| 2124 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2125 | */ |
| 2126 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2127 | } |
| 2128 | |
| 2129 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2130 | * Opens an InputStream for the contacts's photo and returns the |
| 2131 | * photo as a byte stream. |
| 2132 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2133 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2134 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2135 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 2136 | * 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] | 2137 | * @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] | 2138 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2139 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 2140 | boolean preferHighres) { |
| 2141 | if (preferHighres) { |
| 2142 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 2143 | Contacts.Photo.DISPLAY_PHOTO); |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2144 | try { |
| 2145 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
Makoto Onuki | da072b3 | 2016-02-05 13:23:21 -0800 | [diff] [blame] | 2146 | if (fd != null) { |
| 2147 | return fd.createInputStream(); |
| 2148 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2149 | } catch (IOException e) { |
| 2150 | // fallback to the thumbnail code |
| 2151 | } |
| 2152 | } |
| 2153 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2154 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2155 | if (photoUri == null) { |
| 2156 | return null; |
| 2157 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2158 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2159 | new String[] { |
| 2160 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 2161 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2162 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2163 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2164 | return null; |
| 2165 | } |
| 2166 | byte[] data = cursor.getBlob(0); |
| 2167 | if (data == null) { |
| 2168 | return null; |
| 2169 | } |
| 2170 | return new ByteArrayInputStream(data); |
| 2171 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2172 | if (cursor != null) { |
| 2173 | cursor.close(); |
| 2174 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2175 | } |
| 2176 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2177 | |
| 2178 | /** |
| 2179 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2180 | * photo as a byte stream. |
| 2181 | * @param cr The content resolver to use for querying |
| 2182 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2183 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2184 | * @return an InputStream of the photo, or null if no photo is present |
| 2185 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2186 | * of the thumbnail the high-res picture is preferred |
| 2187 | */ |
| 2188 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2189 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2190 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2191 | } |
| 2192 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2193 | /** |
| 2194 | * <p> |
| 2195 | * Constants for the user's profile data, which is represented as a single contact on |
| 2196 | * the device that represents the user. The profile contact is not aggregated |
| 2197 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2198 | * account (including data set, if applicable) on the device may contribute a single |
| 2199 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2200 | * </p> |
| 2201 | * <p> |
| 2202 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2203 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2204 | * the read/write contact permissions required by the provider. Querying for profile |
| 2205 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2206 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2207 | * </p> |
| 2208 | * <h3>Operations</h3> |
| 2209 | * <dl> |
| 2210 | * <dt><b>Insert</b></dt> |
| 2211 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2212 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2213 | * provider will check for the existence of a profile on the device. If one is |
| 2214 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2215 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2216 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2217 | * inserted raw contact.</dd> |
| 2218 | * <dt><b>Update</b></dt> |
| 2219 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2220 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2221 | * <dt><b>Delete</b></dt> |
| 2222 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2223 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2224 | * <dt><b>Query</b></dt> |
| 2225 | * <dd> |
| 2226 | * <ul> |
| 2227 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2228 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2229 | * profile contact. |
| 2230 | * </li> |
| 2231 | * <li> |
| 2232 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2233 | * does - the content of the profile contact can be retrieved as entities or |
| 2234 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2235 | * the desired raw contact ID within the profile. |
| 2236 | * </li> |
| 2237 | * </ul> |
| 2238 | * </dd> |
| 2239 | * </dl> |
| 2240 | */ |
| 2241 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2242 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2243 | /** |
| 2244 | * This utility class cannot be instantiated |
| 2245 | */ |
| 2246 | private Profile() { |
| 2247 | } |
| 2248 | |
| 2249 | /** |
| 2250 | * The content:// style URI for this table, which requests the contact entry |
| 2251 | * representing the user's personal profile data. |
| 2252 | */ |
| 2253 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2254 | |
| 2255 | /** |
| 2256 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2257 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2258 | * user's profile contact formatted as a vCard when opened through |
| 2259 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2260 | */ |
| 2261 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2262 | "as_vcard"); |
| 2263 | |
| 2264 | /** |
| 2265 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2266 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2267 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2268 | * that specific raw contact can be requested by appending the entity or data |
| 2269 | * path as well. |
| 2270 | */ |
| 2271 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2272 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2273 | |
| 2274 | /** |
| 2275 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2276 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2277 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2278 | * to the profile data rather than general contacts data, along with all the special |
| 2279 | * permission checks that entails. |
| 2280 | * |
| 2281 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2282 | * the set of data intended for the profile. |
| 2283 | */ |
| 2284 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2285 | } |
| 2286 | |
| 2287 | /** |
| 2288 | * This method can be used to identify whether the given ID is associated with profile |
| 2289 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2290 | * that accessing data using this ID will result in profile access checks and will only |
| 2291 | * return data from the profile. |
| 2292 | * |
| 2293 | * @param id The ID to check. |
| 2294 | * @return Whether the ID is associated with profile data. |
| 2295 | */ |
| 2296 | public static boolean isProfileId(long id) { |
| 2297 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2300 | protected interface DeletedContactsColumns { |
| 2301 | |
| 2302 | /** |
| 2303 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2304 | * <P>Type: INTEGER</P> |
| 2305 | */ |
| 2306 | public static final String CONTACT_ID = "contact_id"; |
| 2307 | |
| 2308 | /** |
| 2309 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2310 | */ |
| 2311 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2312 | } |
| 2313 | |
| 2314 | /** |
| 2315 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2316 | * <p> |
| 2317 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2318 | */ |
| 2319 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2320 | |
| 2321 | /** |
| 2322 | * This utility class cannot be instantiated |
| 2323 | */ |
| 2324 | private DeletedContacts() { |
| 2325 | } |
| 2326 | |
| 2327 | /** |
| 2328 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2329 | * matching the selection criteria. |
| 2330 | */ |
| 2331 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2332 | "deleted_contacts"); |
| 2333 | |
| 2334 | /** |
| 2335 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2336 | * deleted. |
| 2337 | * |
| 2338 | * @hide |
| 2339 | */ |
| 2340 | private static final int DAYS_KEPT = 30; |
| 2341 | |
| 2342 | /** |
| 2343 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2344 | * deleted. |
| 2345 | */ |
| 2346 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2347 | } |
| 2348 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2349 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2350 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2351 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2352 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2353 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2354 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2355 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2356 | |
| 2357 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 2358 | * Persistent unique id for each raw_contact within its account. |
| 2359 | * This id is provided by its own data source, and can be used to backup metadata |
| 2360 | * to the server. |
| 2361 | * 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] | 2362 | */ |
| 2363 | public static final String BACKUP_ID = "backup_id"; |
| 2364 | |
| 2365 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2366 | * The data set within the account that this row belongs to. This allows |
| 2367 | * multiple sync adapters for the same account type to distinguish between |
| 2368 | * each others' data. |
| 2369 | * |
| 2370 | * This is empty by default, and is completely optional. It only needs to |
| 2371 | * be populated if multiple sync adapters are entering distinct data for |
| 2372 | * the same account type and account name. |
| 2373 | * <P>Type: TEXT</P> |
| 2374 | */ |
| 2375 | public static final String DATA_SET = "data_set"; |
| 2376 | |
| 2377 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2378 | * A concatenation of the account type and data set (delimited by a forward |
| 2379 | * slash) - if the data set is empty, this will be the same as the account |
| 2380 | * type. For applications that need to be aware of the data set, this can |
| 2381 | * be used instead of account type to distinguish sets of data. This is |
| 2382 | * never intended to be used for specifying accounts. |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 2383 | * <p> |
| 2384 | * This column does *not* escape forward slashes in the account type or the data set. |
| 2385 | * If this is an issue, consider using |
| 2386 | * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and |
| 2387 | * {@link ContactsContract.RawContacts#DATA_SET} directly. |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2388 | */ |
| 2389 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2390 | |
| 2391 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2392 | * The aggregation mode for this contact. |
| 2393 | * <P>Type: INTEGER</P> |
| 2394 | */ |
| 2395 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2396 | |
| 2397 | /** |
| 2398 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2399 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2400 | * 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] | 2401 | * 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] | 2402 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2403 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2404 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2405 | * <P>Type: INTEGER</P> |
| 2406 | */ |
| 2407 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2408 | |
| 2409 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2410 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2411 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2412 | * <P>Type: INTEGER</P> |
| 2413 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2414 | 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] | 2415 | |
| 2416 | /** |
| 2417 | * Flag that reflects whether this raw contact belongs to the user's |
| 2418 | * personal profile entry. |
| 2419 | */ |
| 2420 | 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] | 2421 | |
| 2422 | /** |
| 2423 | * Flag indicating that a raw contact's metadata has changed, and its metadata |
| 2424 | * needs to be synchronized by the server. |
| 2425 | * <P>Type: INTEGER (boolean)</P> |
| 2426 | */ |
| 2427 | public static final String METADATA_DIRTY = "metadata_dirty"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2428 | } |
| 2429 | |
| 2430 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2431 | * Constants for the raw contacts table, which contains one row of contact |
| 2432 | * information for each person in each synced account. Sync adapters and |
| 2433 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2434 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2435 | * |
| 2436 | * <h3>Aggregation</h3> |
| 2437 | * <p> |
| 2438 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2439 | * changes, the provider will check if the raw contact matches other |
| 2440 | * existing raw contacts and if so will aggregate it with those. The |
| 2441 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2442 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2443 | * </p> |
| 2444 | * <p> |
| 2445 | * Changes to the structured name, organization, phone number, email address, |
| 2446 | * or nickname trigger a re-aggregation. |
| 2447 | * </p> |
| 2448 | * <p> |
| 2449 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2450 | * aggregation programmatically. |
| 2451 | * </p> |
| 2452 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2453 | * <h3>Operations</h3> |
| 2454 | * <dl> |
| 2455 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2456 | * <dd> |
| 2457 | * <p> |
| 2458 | * Raw contacts can be inserted incrementally or in a batch. |
| 2459 | * The incremental method is more traditional but less efficient. |
| 2460 | * It should be used |
| 2461 | * 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] | 2462 | * <pre> |
| 2463 | * ContentValues values = new ContentValues(); |
| 2464 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2465 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2466 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2467 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2468 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2469 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2470 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2471 | * Once {@link Data} values become available, insert those. |
| 2472 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2473 | * |
| 2474 | * <pre> |
| 2475 | * values.clear(); |
| 2476 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2477 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2478 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2479 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2480 | * </pre> |
| 2481 | * </p> |
| 2482 | * <p> |
| 2483 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2484 | * constituent data rows in a single database transaction |
| 2485 | * and causes at most one aggregation pass. |
| 2486 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2487 | * ArrayList<ContentProviderOperation> ops = |
| 2488 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2489 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2490 | * int rawContactInsertIndex = ops.size(); |
| 2491 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2492 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2493 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2494 | * .build()); |
| 2495 | * |
| 2496 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2497 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2498 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2499 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2500 | * .build()); |
| 2501 | * |
| 2502 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2503 | * </pre> |
| 2504 | * </p> |
| 2505 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2506 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2507 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2508 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2509 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2510 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2511 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2512 | * <dd><p> |
| 2513 | * Raw contacts can be updated incrementally or in a batch. |
| 2514 | * Batch mode should be used whenever possible. |
| 2515 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2516 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2517 | * <dt><b>Delete</b></dt> |
| 2518 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2519 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2520 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2521 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2522 | * </p> |
| 2523 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2524 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2525 | * a raw contacts row. |
| 2526 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2527 | * removes the raw contact from its aggregate contact. |
| 2528 | * The sync adapter then deletes the raw contact from the server and |
| 2529 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2530 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2531 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2532 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2533 | * is marked for deletion, it will remain on the phone. However it will be |
| 2534 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2535 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2536 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2537 | * <dt><b>Query</b></dt> |
| 2538 | * <dd> |
| 2539 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2540 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2541 | * <pre> |
| 2542 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2543 | * new String[]{RawContacts._ID}, |
| 2544 | * RawContacts.CONTACT_ID + "=?", |
| 2545 | * new String[]{String.valueOf(contactId)}, null); |
| 2546 | * </pre> |
| 2547 | * </p> |
| 2548 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2549 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2550 | * you can either put the account name and type in the selection or pass them as query |
| 2551 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2552 | * URI: |
| 2553 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2554 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2555 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2556 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2557 | * .build(); |
| 2558 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2559 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2560 | * ... |
| 2561 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2562 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2563 | * </pre> |
| 2564 | * </p> |
| 2565 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2566 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2567 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2568 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2569 | * <pre> |
| 2570 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2571 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2572 | * Cursor c = getContentResolver().query(entityUri, |
| 2573 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2574 | * null, null, null); |
| 2575 | * try { |
| 2576 | * while (c.moveToNext()) { |
| 2577 | * String sourceId = c.getString(0); |
| 2578 | * if (!c.isNull(1)) { |
| 2579 | * String mimeType = c.getString(2); |
| 2580 | * String data = c.getString(3); |
| 2581 | * ... |
| 2582 | * } |
| 2583 | * } |
| 2584 | * } finally { |
| 2585 | * c.close(); |
| 2586 | * } |
| 2587 | * </pre> |
| 2588 | * </p> |
| 2589 | * </dd> |
| 2590 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2591 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2592 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2593 | * <table class="jd-sumtable"> |
| 2594 | * <tr> |
| 2595 | * <th colspan='4'>RawContacts</th> |
| 2596 | * </tr> |
| 2597 | * <tr> |
| 2598 | * <td>long</td> |
| 2599 | * <td>{@link #_ID}</td> |
| 2600 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2601 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2602 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2603 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2604 | * </tr> |
| 2605 | * <tr> |
| 2606 | * <td>long</td> |
| 2607 | * <td>{@link #CONTACT_ID}</td> |
| 2608 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2609 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2610 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2611 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2612 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2613 | * </tr> |
| 2614 | * <tr> |
| 2615 | * <td>int</td> |
| 2616 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2617 | * <td>read/write</td> |
| 2618 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2619 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2620 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2621 | * </tr> |
| 2622 | * <tr> |
| 2623 | * <td>int</td> |
| 2624 | * <td>{@link #DELETED}</td> |
| 2625 | * <td>read/write</td> |
| 2626 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2627 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2628 | * called on a raw contact, it is marked for deletion and removed from its |
| 2629 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2630 | * then calls ContactResolver.delete once more, this time passing the |
| 2631 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2632 | * the data removal.</td> |
| 2633 | * </tr> |
| 2634 | * <tr> |
| 2635 | * <td>int</td> |
| 2636 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2637 | * <td>read/write</td> |
| 2638 | * <td>The number of times the contact has been contacted. To have an effect |
| 2639 | * on the corresponding value of the aggregate contact, this field |
| 2640 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2641 | * After that, this value is typically updated via |
| 2642 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2643 | * </tr> |
| 2644 | * <tr> |
| 2645 | * <td>long</td> |
| 2646 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2647 | * <td>read/write</td> |
| 2648 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2649 | * on the corresponding value of the aggregate contact, this field |
| 2650 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2651 | * After that, this value is typically updated via |
| 2652 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2653 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2654 | * </tr> |
| 2655 | * <tr> |
| 2656 | * <td>int</td> |
| 2657 | * <td>{@link #STARRED}</td> |
| 2658 | * <td>read/write</td> |
| 2659 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2660 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2661 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2662 | * itself is marked as starred.</td> |
| 2663 | * </tr> |
| 2664 | * <tr> |
| 2665 | * <td>String</td> |
| 2666 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2667 | * <td>read/write</td> |
| 2668 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2669 | * URI returned by an activity launched with the |
| 2670 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2671 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2672 | * 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] | 2673 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2674 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2675 | * instead.</td> |
| 2676 | * </tr> |
| 2677 | * <tr> |
| 2678 | * <td>int</td> |
| 2679 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2680 | * <td>read/write</td> |
| 2681 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2682 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2683 | * on the corresponding value of the aggregate contact, this field |
| 2684 | * should be set at the time the raw contact is inserted.</td> |
| 2685 | * </tr> |
| 2686 | * <tr> |
| 2687 | * <td>String</td> |
| 2688 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2689 | * <td>read/write-once</td> |
| 2690 | * <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] | 2691 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2692 | * 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] | 2693 | * It should be set at the time the raw contact is inserted and never |
| 2694 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2695 | * </tr> |
| 2696 | * <tr> |
| 2697 | * <td>String</td> |
| 2698 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2699 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2700 | * <td> |
| 2701 | * <p> |
| 2702 | * The type of account to which this row belongs, which when paired with |
| 2703 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2704 | * It should be set at the time the raw contact is inserted and never |
| 2705 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2706 | * </p> |
| 2707 | * <p> |
| 2708 | * To ensure uniqueness, new account types should be chosen according to the |
| 2709 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2710 | * </p> |
| 2711 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2712 | * </tr> |
| 2713 | * <tr> |
| 2714 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2715 | * <td>{@link #DATA_SET}</td> |
| 2716 | * <td>read/write-once</td> |
| 2717 | * <td> |
| 2718 | * <p> |
| 2719 | * The data set within the account that this row belongs to. This allows |
| 2720 | * multiple sync adapters for the same account type to distinguish between |
| 2721 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2722 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2723 | * that is associated with a single sync adapter. |
| 2724 | * </p> |
| 2725 | * <p> |
| 2726 | * This is empty by default, and is completely optional. It only needs to |
| 2727 | * be populated if multiple sync adapters are entering distinct data for |
| 2728 | * the same account type and account name. |
| 2729 | * </p> |
| 2730 | * <p> |
| 2731 | * It should be set at the time the raw contact is inserted and never |
| 2732 | * changed afterwards. |
| 2733 | * </p> |
| 2734 | * </td> |
| 2735 | * </tr> |
| 2736 | * <tr> |
| 2737 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2738 | * <td>{@link #SOURCE_ID}</td> |
| 2739 | * <td>read/write</td> |
| 2740 | * <td>String that uniquely identifies this row to its source account. |
| 2741 | * Typically it is set at the time the raw contact is inserted and never |
| 2742 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2743 | * will have an account name and type (and possibly a data set), but no |
| 2744 | * source id. This indicates to the sync adapter that a new contact needs |
| 2745 | * to be created server-side and its ID stored in the corresponding |
| 2746 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2747 | * </td> |
| 2748 | * </tr> |
| 2749 | * <tr> |
| 2750 | * <td>int</td> |
| 2751 | * <td>{@link #VERSION}</td> |
| 2752 | * <td>read-only</td> |
| 2753 | * <td>Version number that is updated whenever this row or its related data |
| 2754 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2755 | * </td> |
| 2756 | * </tr> |
| 2757 | * <tr> |
| 2758 | * <td>int</td> |
| 2759 | * <td>{@link #DIRTY}</td> |
| 2760 | * <td>read/write</td> |
| 2761 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2762 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2763 | * whenever the raw contact changes, unless the URI has the |
| 2764 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2765 | * The sync adapter should always supply this query parameter to prevent |
| 2766 | * unnecessary synchronization: user changes some data on the server, |
| 2767 | * the sync adapter updates the contact on the phone (without the |
| 2768 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2769 | * which triggers a sync to bring the changes to the server. |
| 2770 | * </td> |
| 2771 | * </tr> |
| 2772 | * <tr> |
| 2773 | * <td>String</td> |
| 2774 | * <td>{@link #SYNC1}</td> |
| 2775 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2776 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2777 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2778 | * stores this information on behalf of the sync adapter but does not |
| 2779 | * interpret it in any way. |
| 2780 | * </td> |
| 2781 | * </tr> |
| 2782 | * <tr> |
| 2783 | * <td>String</td> |
| 2784 | * <td>{@link #SYNC2}</td> |
| 2785 | * <td>read/write</td> |
| 2786 | * <td>Generic column for use by sync adapters. |
| 2787 | * </td> |
| 2788 | * </tr> |
| 2789 | * <tr> |
| 2790 | * <td>String</td> |
| 2791 | * <td>{@link #SYNC3}</td> |
| 2792 | * <td>read/write</td> |
| 2793 | * <td>Generic column for use by sync adapters. |
| 2794 | * </td> |
| 2795 | * </tr> |
| 2796 | * <tr> |
| 2797 | * <td>String</td> |
| 2798 | * <td>{@link #SYNC4}</td> |
| 2799 | * <td>read/write</td> |
| 2800 | * <td>Generic column for use by sync adapters. |
| 2801 | * </td> |
| 2802 | * </tr> |
| 2803 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2804 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2805 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2806 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2807 | /** |
| 2808 | * This utility class cannot be instantiated |
| 2809 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2810 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2811 | } |
| 2812 | |
| 2813 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2814 | * The content:// style URI for this table, which requests a directory of |
| 2815 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2816 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2817 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2818 | |
| 2819 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2820 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2821 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2822 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2823 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2824 | |
| 2825 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2826 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2827 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2828 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2829 | 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] | 2830 | |
| 2831 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2832 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2833 | */ |
| 2834 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2835 | |
| 2836 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2837 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2838 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2839 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2840 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2841 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2842 | |
| 2843 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2844 | * <p> |
| 2845 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2846 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2847 | * result in any change in how the contact is aggregated. Similar to |
| 2848 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2849 | * {@link Contacts} aggregate. |
| 2850 | * </p> |
| 2851 | * <p> |
| 2852 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2853 | * performance and/or user experience. |
| 2854 | * </p> |
| 2855 | * <p> |
| 2856 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2857 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2858 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2859 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2860 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2861 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2862 | */ |
| 2863 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2864 | |
| 2865 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2866 | * <p> |
| 2867 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2868 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2869 | * {@link Contacts} query results. |
| 2870 | * </p> |
| 2871 | * <p> |
| 2872 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2873 | * waiting for the deletion to occur on the server side. |
| 2874 | * </p> |
| 2875 | * |
| 2876 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2877 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2878 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2879 | |
| 2880 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2881 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2882 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2883 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2884 | */ |
| 2885 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2886 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2887 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2888 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2889 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2890 | }, null, null, null); |
| 2891 | |
| 2892 | Uri lookupUri = null; |
| 2893 | try { |
| 2894 | if (cursor != null && cursor.moveToFirst()) { |
| 2895 | final long contactId = cursor.getLong(0); |
| 2896 | final String lookupKey = cursor.getString(1); |
| 2897 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2898 | } |
| 2899 | } finally { |
| 2900 | if (cursor != null) cursor.close(); |
| 2901 | } |
| 2902 | return lookupUri; |
| 2903 | } |
| 2904 | |
| 2905 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2906 | * 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] | 2907 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2908 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2909 | */ |
| 2910 | public static final class Data implements BaseColumns, DataColumns { |
| 2911 | /** |
| 2912 | * no public constructor since this is a utility class |
| 2913 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2914 | private Data() { |
| 2915 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2916 | |
| 2917 | /** |
| 2918 | * The directory twig for this sub-table |
| 2919 | */ |
| 2920 | public static final String CONTENT_DIRECTORY = "data"; |
| 2921 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2922 | |
| 2923 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2924 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2925 | * 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] | 2926 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2927 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2928 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2929 | * data. |
| 2930 | * </p> |
| 2931 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2932 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2933 | * and {@link #DATA_ID} for the data rows. |
| 2934 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2935 | * 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] | 2936 | * null. |
| 2937 | * </p> |
| 2938 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2939 | * Using Entity should be preferred to using two separate queries: |
| 2940 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2941 | * data for a raw contact in one transaction, so there is no possibility |
| 2942 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2943 | */ |
| 2944 | public static final class Entity implements BaseColumns, DataColumns { |
| 2945 | /** |
| 2946 | * no public constructor since this is a utility class |
| 2947 | */ |
| 2948 | private Entity() { |
| 2949 | } |
| 2950 | |
| 2951 | /** |
| 2952 | * The directory twig for this sub-table |
| 2953 | */ |
| 2954 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2955 | |
| 2956 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2957 | * 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] | 2958 | * data rows. |
| 2959 | * <P>Type: INTEGER</P> |
| 2960 | */ |
| 2961 | public static final String DATA_ID = "data_id"; |
| 2962 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2963 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2964 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2965 | * <p> |
| 2966 | * A sub-directory of a single raw contact that contains all of its |
| 2967 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2968 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2969 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2970 | * same data. |
| 2971 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2972 | * <p> |
| 2973 | * Access to the social stream through this sub-directory requires additional permissions |
| 2974 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2975 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2976 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2977 | * permission. |
| 2978 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2979 | * |
| 2980 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2981 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 2982 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 2983 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2984 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2985 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2986 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2987 | /** |
| 2988 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2989 | * |
| 2990 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2991 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2992 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2993 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2994 | private StreamItems() { |
| 2995 | } |
| 2996 | |
| 2997 | /** |
| 2998 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2999 | * |
| 3000 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3001 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3002 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3003 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3004 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 3005 | } |
| 3006 | |
| 3007 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3008 | * <p> |
| 3009 | * A sub-directory of a single raw contact that represents its primary |
| 3010 | * display photo. To access this directory append |
| 3011 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 3012 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3013 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3014 | * <p> |
| 3015 | * <p> |
| 3016 | * Note that this sub-directory also supports opening the photo as an asset file |
| 3017 | * in write mode. Callers can create or replace the primary photo associated |
| 3018 | * with this raw contact by opening the asset file and writing the full-size |
| 3019 | * photo contents into it. When the file is closed, the image will be parsed, |
| 3020 | * sized down if necessary for the full-size display photo and thumbnail |
| 3021 | * dimensions, and stored. |
| 3022 | * </p> |
| 3023 | * <p> |
| 3024 | * Usage example: |
| 3025 | * <pre> |
| 3026 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 3027 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 3028 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3029 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 3030 | * try { |
| 3031 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3032 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3033 | * OutputStream os = fd.createOutputStream(); |
| 3034 | * os.write(photo); |
| 3035 | * os.close(); |
| 3036 | * fd.close(); |
| 3037 | * } catch (IOException e) { |
| 3038 | * // Handle error cases. |
| 3039 | * } |
| 3040 | * } |
| 3041 | * </pre> |
| 3042 | * </p> |
| 3043 | */ |
| 3044 | public static final class DisplayPhoto { |
| 3045 | /** |
| 3046 | * No public constructor since this is a utility class |
| 3047 | */ |
| 3048 | private DisplayPhoto() { |
| 3049 | } |
| 3050 | |
| 3051 | /** |
| 3052 | * The directory twig for this sub-table |
| 3053 | */ |
| 3054 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 3055 | } |
| 3056 | |
| 3057 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 3058 | * TODO: javadoc |
| 3059 | * @param cursor |
| 3060 | * @return |
| 3061 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3062 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 3063 | return new EntityIteratorImpl(cursor); |
| 3064 | } |
| 3065 | |
| 3066 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 3067 | private static final String[] DATA_KEYS = new String[]{ |
| 3068 | Data.DATA1, |
| 3069 | Data.DATA2, |
| 3070 | Data.DATA3, |
| 3071 | Data.DATA4, |
| 3072 | Data.DATA5, |
| 3073 | Data.DATA6, |
| 3074 | Data.DATA7, |
| 3075 | Data.DATA8, |
| 3076 | Data.DATA9, |
| 3077 | Data.DATA10, |
| 3078 | Data.DATA11, |
| 3079 | Data.DATA12, |
| 3080 | Data.DATA13, |
| 3081 | Data.DATA14, |
| 3082 | Data.DATA15, |
| 3083 | Data.SYNC1, |
| 3084 | Data.SYNC2, |
| 3085 | Data.SYNC3, |
| 3086 | Data.SYNC4}; |
| 3087 | |
| 3088 | public EntityIteratorImpl(Cursor cursor) { |
| 3089 | super(cursor); |
| 3090 | } |
| 3091 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 3092 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3093 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 3094 | throws RemoteException { |
| 3095 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 3096 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 3097 | |
| 3098 | // we expect the cursor is already at the row we need to read from |
| 3099 | ContentValues cv = new ContentValues(); |
| 3100 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 3101 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 3102 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3103 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 3104 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 3105 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 3106 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 3107 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 3108 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 3109 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 3110 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 3111 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 3112 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 3113 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3114 | android.content.Entity contact = new android.content.Entity(cv); |
| 3115 | |
| 3116 | // read data rows until the contact id changes |
| 3117 | do { |
| 3118 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 3119 | break; |
| 3120 | } |
| 3121 | // add the data to to the contact |
| 3122 | cv = new ContentValues(); |
| 3123 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 3124 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3125 | Data.RES_PACKAGE); |
| 3126 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 3127 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 3128 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 3129 | Data.IS_SUPER_PRIMARY); |
| 3130 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 3131 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3132 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 3133 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3134 | Data.DATA_VERSION); |
| 3135 | for (String key : DATA_KEYS) { |
| 3136 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3137 | switch (cursor.getType(columnIndex)) { |
| 3138 | case Cursor.FIELD_TYPE_NULL: |
| 3139 | // don't put anything |
| 3140 | break; |
| 3141 | case Cursor.FIELD_TYPE_INTEGER: |
| 3142 | case Cursor.FIELD_TYPE_FLOAT: |
| 3143 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3144 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3145 | break; |
| 3146 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3147 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3148 | break; |
| 3149 | default: |
| 3150 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3151 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3152 | } |
| 3153 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 3154 | } while (cursor.moveToNext()); |
| 3155 | |
| 3156 | return contact; |
| 3157 | } |
| 3158 | |
| 3159 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3160 | } |
| 3161 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3162 | /** |
| 3163 | * Social status update columns. |
| 3164 | * |
| 3165 | * @see StatusUpdates |
| 3166 | * @see ContactsContract.Data |
| 3167 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3168 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3169 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 3170 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3171 | * <P>Type: INTEGER (one of the values below)</P> |
| 3172 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3173 | public static final String PRESENCE = "mode"; |
| 3174 | |
| 3175 | /** |
| 3176 | * @deprecated use {@link #PRESENCE} |
| 3177 | */ |
| 3178 | @Deprecated |
| 3179 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3180 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3181 | /** |
| 3182 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3183 | */ |
| 3184 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3185 | |
| 3186 | /** |
| 3187 | * An allowed value of {@link #PRESENCE}. |
| 3188 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3189 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3190 | |
| 3191 | /** |
| 3192 | * An allowed value of {@link #PRESENCE}. |
| 3193 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3194 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3195 | |
| 3196 | /** |
| 3197 | * An allowed value of {@link #PRESENCE}. |
| 3198 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3199 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3200 | |
| 3201 | /** |
| 3202 | * An allowed value of {@link #PRESENCE}. |
| 3203 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3204 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3205 | |
| 3206 | /** |
| 3207 | * An allowed value of {@link #PRESENCE}. |
| 3208 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3209 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3210 | |
| 3211 | /** |
| 3212 | * Contact latest status update. |
| 3213 | * <p>Type: TEXT</p> |
| 3214 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3215 | public static final String STATUS = "status"; |
| 3216 | |
| 3217 | /** |
| 3218 | * @deprecated use {@link #STATUS} |
| 3219 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3220 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3221 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3222 | |
| 3223 | /** |
| 3224 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3225 | * <p>Type: NUMBER</p> |
| 3226 | */ |
| 3227 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3228 | |
| 3229 | /** |
| 3230 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3231 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3232 | */ |
| 3233 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3234 | |
| 3235 | /** |
| 3236 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3237 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3238 | * <p>Type: NUMBER</p> |
| 3239 | */ |
| 3240 | public static final String STATUS_LABEL = "status_label"; |
| 3241 | |
| 3242 | /** |
| 3243 | * The resource ID of the icon for the source of the status update. |
| 3244 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3245 | * <p>Type: NUMBER</p> |
| 3246 | */ |
| 3247 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3248 | |
| 3249 | /** |
| 3250 | * Contact's audio/video chat capability level. |
| 3251 | * <P>Type: INTEGER (one of the values below)</P> |
| 3252 | */ |
| 3253 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3254 | |
| 3255 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3256 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3257 | * and speaker) |
| 3258 | */ |
| 3259 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3260 | |
| 3261 | /** |
| 3262 | * 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] | 3263 | * display a video feed. |
| 3264 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3265 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3266 | |
| 3267 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3268 | * 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] | 3269 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3270 | */ |
| 3271 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3272 | } |
| 3273 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3274 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3275 | * <p> |
| 3276 | * Constants for the stream_items table, which contains social stream updates from |
| 3277 | * the user's contact list. |
| 3278 | * </p> |
| 3279 | * <p> |
| 3280 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3281 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3282 | * determine this limit, and should restrict the number of items inserted in any given |
| 3283 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3284 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3285 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3286 | * <p> |
| 3287 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3288 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3289 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3290 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3291 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3292 | * <h3>Account check</h3> |
| 3293 | * <p> |
| 3294 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3295 | * information matching that of the owning raw contact as query parameters, namely |
| 3296 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3297 | * {@link RawContacts#DATA_SET} isn't required. |
| 3298 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3299 | * <h3>Operations</h3> |
| 3300 | * <dl> |
| 3301 | * <dt><b>Insert</b></dt> |
| 3302 | * <dd> |
| 3303 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3304 | * of ways to insert these entries. |
| 3305 | * <dl> |
| 3306 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3307 | * <dd> |
| 3308 | * <pre> |
| 3309 | * ContentValues values = new ContentValues(); |
| 3310 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3311 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3312 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3313 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3314 | * ContentUris.appendId(builder, rawContactId); |
| 3315 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3316 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3317 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3318 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3319 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3320 | * </pre> |
| 3321 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3322 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3323 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3324 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3325 | * ContentValues values = new ContentValues(); |
| 3326 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3327 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3328 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3329 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3330 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3331 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3332 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3333 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3334 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3335 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3336 | * </dd> |
| 3337 | * </dl> |
| 3338 | * </dd> |
| 3339 | * </p> |
| 3340 | * <p> |
| 3341 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3342 | * social update can be inserted. For example, after one of the insertions above, |
| 3343 | * photos could be added to the stream item in one of the following ways: |
| 3344 | * <dl> |
| 3345 | * <dt>Via a URI including the stream item ID:</dt> |
| 3346 | * <dd> |
| 3347 | * <pre> |
| 3348 | * values.clear(); |
| 3349 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3350 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3351 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3352 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3353 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3354 | * </pre> |
| 3355 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3356 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3357 | * <dd> |
| 3358 | * <pre> |
| 3359 | * values.clear(); |
| 3360 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3361 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3362 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3363 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3364 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3365 | * <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] | 3366 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3367 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3368 | * </dd> |
| 3369 | * </dl> |
| 3370 | * </p> |
| 3371 | * </dd> |
| 3372 | * <dt><b>Update</b></dt> |
| 3373 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3374 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3375 | * created by the calling package can be updated.</dd> |
| 3376 | * <dt><b>Delete</b></dt> |
| 3377 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3378 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3379 | * created by the calling package can be deleted.</dd> |
| 3380 | * <dt><b>Query</b></dt> |
| 3381 | * <dl> |
| 3382 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3383 | * <dd>By Contact ID: |
| 3384 | * <pre> |
| 3385 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3386 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3387 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3388 | * null, null, null, null); |
| 3389 | * </pre> |
| 3390 | * </dd> |
| 3391 | * <dd>By lookup key: |
| 3392 | * <pre> |
| 3393 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3394 | * .appendPath(lookupKey) |
| 3395 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3396 | * null, null, null, null); |
| 3397 | * </pre> |
| 3398 | * </dd> |
| 3399 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3400 | * <dd> |
| 3401 | * <pre> |
| 3402 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3403 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3404 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3405 | * null, null, null, null); |
| 3406 | * </pre> |
| 3407 | * </dd> |
| 3408 | * <dt>Querying for a specific stream item by ID</dt> |
| 3409 | * <dd> |
| 3410 | * <pre> |
| 3411 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3412 | * StreamItems.CONTENT_URI, streamItemId), |
| 3413 | * null, null, null, null); |
| 3414 | * </pre> |
| 3415 | * </dd> |
| 3416 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3417 | * |
| 3418 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3419 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3420 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3421 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3422 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3423 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3424 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3425 | /** |
| 3426 | * This utility class cannot be instantiated |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3427 | * |
| 3428 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3429 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3430 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3431 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3432 | private StreamItems() { |
| 3433 | } |
| 3434 | |
| 3435 | /** |
| 3436 | * The content:// style URI for this table, which handles social network stream |
| 3437 | * updates for the user's contacts. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3438 | * |
| 3439 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3440 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3441 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3442 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3443 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3444 | |
| 3445 | /** |
| 3446 | * <p> |
| 3447 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3448 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3449 | * for photos should be performed by appending |
| 3450 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3451 | * specific stream item. |
| 3452 | * </p> |
| 3453 | * <p> |
| 3454 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3455 | * in the {@link ContentValues} passed in. |
| 3456 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3457 | * |
| 3458 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3459 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3460 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3461 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3462 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3463 | |
| 3464 | /** |
| 3465 | * 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] | 3466 | * that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3467 | * |
| 3468 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3469 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3470 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3471 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3472 | public static final Uri CONTENT_LIMIT_URI = |
| 3473 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3474 | |
| 3475 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3476 | * The MIME type of a directory of stream items. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3477 | * |
| 3478 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3479 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3480 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3481 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3482 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3483 | |
| 3484 | /** |
| 3485 | * The MIME type of a single stream item. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3486 | * |
| 3487 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3488 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3489 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3490 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3491 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3492 | |
| 3493 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3494 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3495 | * contain this column, with the value indicating the maximum number of |
| 3496 | * stream items that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3497 | * |
| 3498 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3499 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3500 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3501 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3502 | public static final String MAX_ITEMS = "max_items"; |
| 3503 | |
| 3504 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3505 | * <p> |
| 3506 | * A sub-directory of a single stream item entry that contains all of its |
| 3507 | * photo rows. To access this |
| 3508 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3509 | * an individual stream item URI. |
| 3510 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3511 | * <p> |
| 3512 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3513 | * contact permissions required by the provider. Querying for social stream photos |
| 3514 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3515 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3516 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3517 | * |
| 3518 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3519 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3520 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3521 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3522 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3523 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3524 | public static final class StreamItemPhotos |
| 3525 | implements BaseColumns, StreamItemPhotosColumns { |
| 3526 | /** |
| 3527 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3528 | * |
| 3529 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3530 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3531 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3532 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3533 | private StreamItemPhotos() { |
| 3534 | } |
| 3535 | |
| 3536 | /** |
| 3537 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3538 | * |
| 3539 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3540 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3541 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3542 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3543 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3544 | |
| 3545 | /** |
| 3546 | * The MIME type of a directory of stream item photos. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3547 | * |
| 3548 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3549 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3550 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3551 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3552 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3553 | |
| 3554 | /** |
| 3555 | * The MIME type of a single stream item photo. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3556 | * |
| 3557 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3558 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3559 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3560 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3561 | public static final String CONTENT_ITEM_TYPE |
| 3562 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3563 | } |
| 3564 | } |
| 3565 | |
| 3566 | /** |
| 3567 | * Columns in the StreamItems table. |
| 3568 | * |
| 3569 | * @see ContactsContract.StreamItems |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3570 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3571 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3572 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3573 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3574 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3575 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3576 | protected interface StreamItemsColumns { |
| 3577 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3578 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3579 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3580 | * |
| 3581 | * <p>Type: INTEGER</p> |
| 3582 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3583 | * |
| 3584 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3585 | * cursors returned from related queries will be empty. |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3586 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3587 | @Deprecated |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3588 | public static final String CONTACT_ID = "contact_id"; |
| 3589 | |
| 3590 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3591 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3592 | * that this stream item belongs to. |
| 3593 | * |
| 3594 | * <p>Type: TEXT</p> |
| 3595 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3596 | * |
| 3597 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3598 | * cursors returned from related queries will be empty. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3599 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3600 | @Deprecated |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3601 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3602 | |
| 3603 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3604 | * A reference to the {@link RawContacts#_ID} |
| 3605 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3606 | * <p>Type: INTEGER</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3607 | * |
| 3608 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3609 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3610 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3611 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3612 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3613 | |
| 3614 | /** |
| 3615 | * The package name to use when creating {@link Resources} objects for |
| 3616 | * this stream item. This value is only designed for use when building |
| 3617 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3618 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3619 | * |
| 3620 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3621 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3622 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3623 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3624 | public static final String RES_PACKAGE = "res_package"; |
| 3625 | |
| 3626 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3627 | * The account type to which the raw_contact of this item is associated. See |
| 3628 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3629 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3630 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3631 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3632 | * |
| 3633 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3634 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3635 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3636 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3637 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3638 | |
| 3639 | /** |
| 3640 | * The account name to which the raw_contact of this item is associated. See |
| 3641 | * {@link RawContacts#ACCOUNT_NAME} |
| 3642 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3643 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3644 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3645 | * |
| 3646 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3647 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3648 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3649 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3650 | public static final String ACCOUNT_NAME = "account_name"; |
| 3651 | |
| 3652 | /** |
| 3653 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3654 | * multiple sync adapters for the same account type to distinguish between |
| 3655 | * each others' data. |
| 3656 | * {@link RawContacts#DATA_SET} |
| 3657 | * |
| 3658 | * <P>Type: TEXT</P> |
| 3659 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3660 | * |
| 3661 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3662 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3663 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3664 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3665 | public static final String DATA_SET = "data_set"; |
| 3666 | |
| 3667 | /** |
| 3668 | * The source_id of the raw_contact that this row belongs to. |
| 3669 | * {@link RawContacts#SOURCE_ID} |
| 3670 | * |
| 3671 | * <P>Type: TEXT</P> |
| 3672 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3673 | * |
| 3674 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3675 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3676 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3677 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3678 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3679 | |
| 3680 | /** |
| 3681 | * The resource name of the icon for the source of the stream item. |
| 3682 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3683 | * drawables, the "@drawable/" prefix must be omitted. |
| 3684 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3685 | * |
| 3686 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3687 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3688 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3689 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3690 | public static final String RES_ICON = "icon"; |
| 3691 | |
| 3692 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3693 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3694 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3695 | * reference strings, the "@string/" prefix must be omitted. |
| 3696 | * <p>Type: TEXT</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3697 | * |
| 3698 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3699 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3700 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3701 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3702 | public static final String RES_LABEL = "label"; |
| 3703 | |
| 3704 | /** |
| 3705 | * <P> |
| 3706 | * The main textual contents of the item. Typically this is content |
| 3707 | * that was posted by the source of this stream item, but it can also |
| 3708 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3709 | * This text is displayed to the user and allows formatting and embedded |
| 3710 | * resource images via HTML (as parseable via |
| 3711 | * {@link android.text.Html#fromHtml}). |
| 3712 | * </P> |
| 3713 | * <P> |
| 3714 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3715 | * is unspecified, but it should not break tags. |
| 3716 | * </P> |
| 3717 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3718 | * |
| 3719 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3720 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3721 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3722 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3723 | public static final String TEXT = "text"; |
| 3724 | |
| 3725 | /** |
| 3726 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3727 | * inserted/updated. |
| 3728 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3729 | * |
| 3730 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3731 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3732 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3733 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3734 | public static final String TIMESTAMP = "timestamp"; |
| 3735 | |
| 3736 | /** |
| 3737 | * <P> |
| 3738 | * Summary information about the stream item, for example to indicate how |
| 3739 | * many people have reshared it, how many have liked it, how many thumbs |
| 3740 | * up and/or thumbs down it has, what the original source was, etc. |
| 3741 | * </P> |
| 3742 | * <P> |
| 3743 | * This text is displayed to the user and allows simple formatting via |
| 3744 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3745 | * </P> |
| 3746 | * <P> |
| 3747 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3748 | * is unspecified, but it should not break tags. |
| 3749 | * </P> |
| 3750 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3751 | * |
| 3752 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3753 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3754 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3755 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3756 | public static final String COMMENTS = "comments"; |
| 3757 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3758 | /** |
| 3759 | * Generic column for use by sync adapters. |
| 3760 | * |
| 3761 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3762 | * cursors returned from related queries will be empty. |
| 3763 | */ |
| 3764 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3765 | public static final String SYNC1 = "stream_item_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3766 | /** |
| 3767 | * Generic column for use by sync adapters. |
| 3768 | * |
| 3769 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3770 | * cursors returned from related queries will be empty. |
| 3771 | */ |
| 3772 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3773 | public static final String SYNC2 = "stream_item_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3774 | /** |
| 3775 | * Generic column for use by sync adapters. |
| 3776 | * |
| 3777 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3778 | * cursors returned from related queries will be empty. |
| 3779 | */ |
| 3780 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3781 | public static final String SYNC3 = "stream_item_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3782 | /** |
| 3783 | * Generic column for use by sync adapters. |
| 3784 | * |
| 3785 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3786 | * cursors returned from related queries will be empty. |
| 3787 | */ |
| 3788 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3789 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | /** |
| 3793 | * <p> |
| 3794 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3795 | * social stream updates. |
| 3796 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3797 | * <p> |
| 3798 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3799 | * contact permissions required by the provider. Querying for social stream photos |
| 3800 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3801 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3802 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3803 | * <h3>Account check</h3> |
| 3804 | * <p> |
| 3805 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3806 | * information matching that of the owning raw contact as query parameters, namely |
| 3807 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3808 | * {@link RawContacts#DATA_SET} isn't required. |
| 3809 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3810 | * <h3>Operations</h3> |
| 3811 | * <dl> |
| 3812 | * <dt><b>Insert</b></dt> |
| 3813 | * <dd> |
| 3814 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3815 | * can be inserted into a social stream item in a couple of ways: |
| 3816 | * <dl> |
| 3817 | * <dt> |
| 3818 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3819 | * stream item: |
| 3820 | * </dt> |
| 3821 | * <dd> |
| 3822 | * <pre> |
| 3823 | * ContentValues values = new ContentValues(); |
| 3824 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3825 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3826 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3827 | * ContentUris.appendId(builder, streamItemId); |
| 3828 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3829 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3830 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3831 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3832 | * long photoId = ContentUris.parseId(photoUri); |
| 3833 | * </pre> |
| 3834 | * </dd> |
| 3835 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3836 | * <dd> |
| 3837 | * <pre> |
| 3838 | * ContentValues values = new ContentValues(); |
| 3839 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3840 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3841 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3842 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3843 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3844 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3845 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3846 | * long photoId = ContentUris.parseId(photoUri); |
| 3847 | * </pre> |
| 3848 | * </dd> |
| 3849 | * </dl> |
| 3850 | * </p> |
| 3851 | * </dd> |
| 3852 | * <dt><b>Update</b></dt> |
| 3853 | * <dd> |
| 3854 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3855 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3856 | * This can be specified in two ways. |
| 3857 | * <dl> |
| 3858 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3859 | * stream item: |
| 3860 | * </dt> |
| 3861 | * <dd> |
| 3862 | * <pre> |
| 3863 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3864 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3865 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3866 | * ContentUris.appendId(builder, streamItemId); |
| 3867 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3868 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3869 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3870 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3871 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3872 | * </pre> |
| 3873 | * </dd> |
| 3874 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3875 | * <dd> |
| 3876 | * <pre> |
| 3877 | * ContentValues values = new ContentValues(); |
| 3878 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3879 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3880 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3881 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3882 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3883 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3884 | * </pre> |
| 3885 | * </dd> |
| 3886 | * </dl> |
| 3887 | * </p> |
| 3888 | * </dd> |
| 3889 | * <dt><b>Delete</b></dt> |
| 3890 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3891 | * against all or a selected subset of photo items under a stream item. |
| 3892 | * For example: |
| 3893 | * <dl> |
| 3894 | * <dt>Deleting a single photo via the |
| 3895 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3896 | * </dt> |
| 3897 | * <dd> |
| 3898 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3899 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3900 | * ContentUris.appendId(builder, streamItemId); |
| 3901 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3902 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3903 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3904 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3905 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3906 | * </pre> |
| 3907 | * </dd> |
| 3908 | * <dt>Deleting all photos under a stream item</dt> |
| 3909 | * <dd> |
| 3910 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3911 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3912 | * ContentUris.appendId(builder, streamItemId); |
| 3913 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3914 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3915 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3916 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3917 | * </pre> |
| 3918 | * </dd> |
| 3919 | * </dl> |
| 3920 | * </dd> |
| 3921 | * <dt><b>Query</b></dt> |
| 3922 | * <dl> |
| 3923 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3924 | * <dd> |
| 3925 | * <pre> |
| 3926 | * Cursor c = getContentResolver().query( |
| 3927 | * ContentUris.withAppendedId( |
| 3928 | * Uri.withAppendedPath( |
| 3929 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3930 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3931 | * streamItemPhotoId), null, null, null, null); |
| 3932 | * </pre> |
| 3933 | * </dd> |
| 3934 | * <dt>Querying for all photos in a stream item</dt> |
| 3935 | * <dd> |
| 3936 | * <pre> |
| 3937 | * Cursor c = getContentResolver().query( |
| 3938 | * Uri.withAppendedPath( |
| 3939 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3940 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3941 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3942 | * </pre> |
| 3943 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3944 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3945 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3946 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3947 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3948 | * an asset file, as follows: |
| 3949 | * <pre> |
| 3950 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3951 | * try { |
| 3952 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3953 | * return fd.createInputStream(); |
| 3954 | * } catch (IOException e) { |
| 3955 | * return null; |
| 3956 | * } |
| 3957 | * } |
| 3958 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3959 | * </dd> |
| 3960 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3961 | * |
| 3962 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3963 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3964 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3965 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3966 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3967 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3968 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3969 | /** |
| 3970 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3971 | * |
| 3972 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3973 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3974 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3975 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3976 | private StreamItemPhotos() { |
| 3977 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3978 | |
| 3979 | /** |
| 3980 | * <p> |
| 3981 | * The binary representation of the photo. Any size photo can be inserted; |
| 3982 | * the provider will resize it appropriately for storage and display. |
| 3983 | * </p> |
| 3984 | * <p> |
| 3985 | * This is only intended for use when inserting or updating a stream item photo. |
| 3986 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3987 | * as an asset file. |
| 3988 | * </p> |
| 3989 | * <P>Type: BLOB</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3990 | * |
| 3991 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3992 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3993 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3994 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3995 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3996 | } |
| 3997 | |
| 3998 | /** |
| 3999 | * Columns in the StreamItemPhotos table. |
| 4000 | * |
| 4001 | * @see ContactsContract.StreamItemPhotos |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4002 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4003 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4004 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4005 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4006 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4007 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4008 | protected interface StreamItemPhotosColumns { |
| 4009 | /** |
| 4010 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 4011 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4012 | * |
| 4013 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4014 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4015 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4016 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4017 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 4018 | |
| 4019 | /** |
| 4020 | * An integer to use for sort order for photos in the stream item. If not |
| 4021 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 4022 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4023 | * |
| 4024 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4025 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4026 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4027 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4028 | public static final String SORT_INDEX = "sort_index"; |
| 4029 | |
| 4030 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4031 | * Photo file ID for the photo. |
| 4032 | * See {@link ContactsContract.DisplayPhoto}. |
| 4033 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4034 | * |
| 4035 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4036 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4037 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4038 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4039 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 4040 | |
| 4041 | /** |
| 4042 | * URI for retrieving the photo content, automatically populated. Callers |
| 4043 | * may retrieve the photo content by opening this URI as an asset file. |
| 4044 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4045 | * |
| 4046 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4047 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4048 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4049 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4050 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4051 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4052 | /** |
| 4053 | * Generic column for use by sync adapters. |
| 4054 | * |
| 4055 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4056 | * cursors returned from related queries will be empty. |
| 4057 | */ |
| 4058 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4059 | public static final String SYNC1 = "stream_item_photo_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4060 | /** |
| 4061 | * Generic column for use by sync adapters. |
| 4062 | * |
| 4063 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4064 | * cursors returned from related queries will be empty. |
| 4065 | */ |
| 4066 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4067 | public static final String SYNC2 = "stream_item_photo_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4068 | /** |
| 4069 | * Generic column for use by sync adapters. |
| 4070 | * |
| 4071 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4072 | * cursors returned from related queries will be empty. |
| 4073 | */ |
| 4074 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4075 | public static final String SYNC3 = "stream_item_photo_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4076 | /** |
| 4077 | * Generic column for use by sync adapters. |
| 4078 | * |
| 4079 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4080 | * cursors returned from related queries will be empty. |
| 4081 | */ |
| 4082 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4083 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4084 | } |
| 4085 | |
| 4086 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 4087 | * <p> |
| 4088 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 4089 | * stored in the file system. |
| 4090 | * </p> |
| 4091 | * |
| 4092 | * @hide |
| 4093 | */ |
| 4094 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 4095 | /** |
| 4096 | * No public constructor since this is a utility class |
| 4097 | */ |
| 4098 | private PhotoFiles() { |
| 4099 | } |
| 4100 | } |
| 4101 | |
| 4102 | /** |
| 4103 | * Columns in the PhotoFiles table. |
| 4104 | * |
| 4105 | * @see ContactsContract.PhotoFiles |
| 4106 | * |
| 4107 | * @hide |
| 4108 | */ |
| 4109 | protected interface PhotoFilesColumns { |
| 4110 | |
| 4111 | /** |
| 4112 | * The height, in pixels, of the photo this entry is associated with. |
| 4113 | * <P>Type: NUMBER</P> |
| 4114 | */ |
| 4115 | public static final String HEIGHT = "height"; |
| 4116 | |
| 4117 | /** |
| 4118 | * The width, in pixels, of the photo this entry is associated with. |
| 4119 | * <P>Type: NUMBER</P> |
| 4120 | */ |
| 4121 | public static final String WIDTH = "width"; |
| 4122 | |
| 4123 | /** |
| 4124 | * The size, in bytes, of the photo stored on disk. |
| 4125 | * <P>Type: NUMBER</P> |
| 4126 | */ |
| 4127 | public static final String FILESIZE = "filesize"; |
| 4128 | } |
| 4129 | |
| 4130 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4131 | * Columns in the Data table. |
| 4132 | * |
| 4133 | * @see ContactsContract.Data |
| 4134 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4135 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4136 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4137 | * The package name to use when creating {@link Resources} objects for |
| 4138 | * this data row. This value is only designed for use when building user |
| 4139 | * interfaces, and should not be used to infer the owner. |
| 4140 | */ |
| 4141 | public static final String RES_PACKAGE = "res_package"; |
| 4142 | |
| 4143 | /** |
| 4144 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4145 | */ |
| 4146 | public static final String MIMETYPE = "mimetype"; |
| 4147 | |
| 4148 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 4149 | * Hash id on the data fields, used for backup and restore. |
| 4150 | * |
| 4151 | * @hide |
| 4152 | */ |
| 4153 | public static final String HASH_ID = "hash_id"; |
| 4154 | |
| 4155 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4156 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4157 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4158 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 4159 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 4160 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4161 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4162 | * 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] | 4163 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4164 | */ |
| 4165 | public static final String IS_PRIMARY = "is_primary"; |
| 4166 | |
| 4167 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4168 | * Whether this is the primary entry of its kind for the aggregate |
| 4169 | * contact it belongs to. Any data record that is "super primary" must |
| 4170 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4171 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4172 | */ |
| 4173 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 4174 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 4175 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 4176 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 4177 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 4178 | * <P>Type: INTEGER</P> |
| 4179 | */ |
| 4180 | public static final String IS_READ_ONLY = "is_read_only"; |
| 4181 | |
| 4182 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 4183 | * The version of this data record. This is a read-only value. The data column is |
| 4184 | * guaranteed to not change without the version going up. This value is monotonically |
| 4185 | * increasing. |
| 4186 | * <P>Type: INTEGER</P> |
| 4187 | */ |
| 4188 | public static final String DATA_VERSION = "data_version"; |
| 4189 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4190 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4191 | public static final String DATA1 = "data1"; |
| 4192 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4193 | public static final String DATA2 = "data2"; |
| 4194 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4195 | public static final String DATA3 = "data3"; |
| 4196 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4197 | public static final String DATA4 = "data4"; |
| 4198 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4199 | public static final String DATA5 = "data5"; |
| 4200 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4201 | public static final String DATA6 = "data6"; |
| 4202 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4203 | public static final String DATA7 = "data7"; |
| 4204 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4205 | public static final String DATA8 = "data8"; |
| 4206 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4207 | public static final String DATA9 = "data9"; |
| 4208 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4209 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4210 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4211 | public static final String DATA11 = "data11"; |
| 4212 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4213 | public static final String DATA12 = "data12"; |
| 4214 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4215 | public static final String DATA13 = "data13"; |
| 4216 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4217 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4218 | /** |
| 4219 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 4220 | * this field is used to store BLOBs (binary data). |
| 4221 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4222 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 4223 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4224 | /** Generic column for use by sync adapters. */ |
| 4225 | public static final String SYNC1 = "data_sync1"; |
| 4226 | /** Generic column for use by sync adapters. */ |
| 4227 | public static final String SYNC2 = "data_sync2"; |
| 4228 | /** Generic column for use by sync adapters. */ |
| 4229 | public static final String SYNC3 = "data_sync3"; |
| 4230 | /** Generic column for use by sync adapters. */ |
| 4231 | public static final String SYNC4 = "data_sync4"; |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4232 | |
| 4233 | /** |
| 4234 | * Carrier presence information. |
| 4235 | * <P> |
| 4236 | * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields) |
| 4237 | * </P> |
| 4238 | */ |
| 4239 | public static final String CARRIER_PRESENCE = "carrier_presence"; |
| 4240 | |
| 4241 | /** |
Etan Cohen | e4dc7e1 | 2015-06-08 13:02:44 -0700 | [diff] [blame] | 4242 | * Indicates that the entry is Video Telephony (VT) capable on the |
| 4243 | * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4244 | */ |
| 4245 | public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4246 | |
| 4247 | /** |
| 4248 | * The flattened {@link android.content.ComponentName} of a {@link |
| 4249 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4250 | * call the contact with. |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4251 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4252 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4253 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4254 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4255 | * every time. |
| 4256 | * |
| 4257 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4258 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4259 | * set to the {@link PhoneAccountHandle} using the {@link ComponentName} from this field. |
| 4260 | * |
| 4261 | * @see #PREFERRED_PHONE_ACCOUNT_ID |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4262 | * @see PhoneAccountHandle#getComponentName() |
| 4263 | * @see ComponentName#flattenToString() |
| 4264 | */ |
| 4265 | String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME = "preferred_phone_account_component_name"; |
| 4266 | |
| 4267 | /** |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4268 | * The ID of a {@link |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4269 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
| 4270 | * call the contact with. Used by {@link CommonDataKinds.Phone}. |
| 4271 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4272 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4273 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4274 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4275 | * every time. |
| 4276 | * |
| 4277 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4278 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4279 | * set to the {@link PhoneAccountHandle} using the id from this field. |
| 4280 | * |
| 4281 | * @see #PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME |
| 4282 | * @see PhoneAccountHandle#getId() |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4283 | */ |
| 4284 | String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4285 | } |
| 4286 | |
| 4287 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4288 | * Columns in the Data_Usage_Stat table |
| 4289 | */ |
| 4290 | protected interface DataUsageStatColumns { |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4291 | /** The last time (in milliseconds) this {@link Data} was used. */ |
| 4292 | public static final String LAST_TIME_USED = "last_time_used"; |
| 4293 | |
Yorke Lee | 5a53d70 | 2013-03-29 18:08:47 -0700 | [diff] [blame] | 4294 | /** The number of times the referenced {@link Data} has been used. */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4295 | public static final String TIMES_USED = "times_used"; |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 4296 | |
| 4297 | /** @hide Raw value. */ |
| 4298 | public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED; |
| 4299 | |
| 4300 | /** @hide Raw value. */ |
| 4301 | public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED; |
| 4302 | |
| 4303 | /** |
| 4304 | * @hide |
| 4305 | * Low res version. Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification. |
| 4306 | */ |
| 4307 | public static final String LR_LAST_TIME_USED = LAST_TIME_USED; |
| 4308 | |
| 4309 | /** |
| 4310 | * @hide |
| 4311 | * Low res version. Same as {@link #TIMES_USED} but use it in CP2 for clarification. |
| 4312 | */ |
| 4313 | public static final String LR_TIMES_USED = TIMES_USED; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4314 | } |
| 4315 | |
| 4316 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4317 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 4318 | * |
| 4319 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4320 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4321 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4322 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4323 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4324 | } |
| 4325 | |
| 4326 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4327 | * <p> |
| 4328 | * 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] | 4329 | * contact. Each row of the data table is typically used to store a single |
| 4330 | * piece of contact |
| 4331 | * information (such as a phone number) and its |
| 4332 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4333 | * </p> |
| 4334 | * <h3>Data kinds</h3> |
| 4335 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4336 | * Data is a generic table that can hold any kind of contact data. |
| 4337 | * The kind of data stored in a given row is specified by the row's |
| 4338 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 4339 | * generic columns {@link #DATA1} through |
| 4340 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4341 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4342 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 4343 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4344 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4345 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 4346 | * stores the email address. |
| 4347 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4348 | * </p> |
| 4349 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4350 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4351 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 4352 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 4353 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 4354 | * {@link ContactsContract.Data Data.DATA1}. |
| 4355 | * </p> |
| 4356 | * <p> |
| 4357 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 4358 | * expected to be most frequently used in query selections. For example, in the |
| 4359 | * case of a row representing email addresses {@link #DATA1} should probably |
| 4360 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 4361 | * used for auxiliary information like type of email address. |
| 4362 | * <p> |
| 4363 | * <p> |
| 4364 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 4365 | * </p> |
| 4366 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 4367 | * The sync adapter for a given account type must correctly handle every data type |
| 4368 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 4369 | * corrupted data. |
| 4370 | * </p> |
| 4371 | * <p> |
| 4372 | * 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] | 4373 | * 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] | 4374 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 4375 | * get synced to the server, because the Google sync adapter does not know |
| 4376 | * how to handle this data kind. Thus new data kinds are typically |
| 4377 | * introduced along with new account types, i.e. new sync adapters. |
| 4378 | * </p> |
| 4379 | * <h3>Batch operations</h3> |
| 4380 | * <p> |
| 4381 | * Data rows can be inserted/updated/deleted using the traditional |
| 4382 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 4383 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 4384 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 4385 | * choice in almost all cases. All operations in a batch are executed in a |
| 4386 | * single transaction, which ensures that the phone-side and server-side |
| 4387 | * state of a raw contact are always consistent. Also, the batch-based |
| 4388 | * approach is far more efficient: not only are the database operations |
| 4389 | * faster when executed in a single transaction, but also sending a batch of |
| 4390 | * commands to the content provider saves a lot of time on context switching |
| 4391 | * between your process and the process in which the content provider runs. |
| 4392 | * </p> |
| 4393 | * <p> |
| 4394 | * The flip side of using batched operations is that a large batch may lock |
| 4395 | * up the database for a long time preventing other applications from |
| 4396 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 4397 | * dialogs.) |
| 4398 | * </p> |
| 4399 | * <p> |
| 4400 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 4401 | * in the batch. A yield point indicates to the content provider that before |
| 4402 | * executing the next operation it can commit the changes that have already |
| 4403 | * been made, yield to other requests, open another transaction and continue |
| 4404 | * processing operations. A yield point will not automatically commit the |
| 4405 | * transaction, but only if there is another request waiting on the |
| 4406 | * database. Normally a sync adapter should insert a yield point at the |
| 4407 | * beginning of each raw contact operation sequence in the batch. See |
| 4408 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 4409 | * </p> |
| 4410 | * <h3>Operations</h3> |
| 4411 | * <dl> |
| 4412 | * <dt><b>Insert</b></dt> |
| 4413 | * <dd> |
| 4414 | * <p> |
| 4415 | * An individual data row can be inserted using the traditional |
| 4416 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 4417 | * should always be inserted as a batch. |
| 4418 | * </p> |
| 4419 | * <p> |
| 4420 | * An example of a traditional insert: |
| 4421 | * <pre> |
| 4422 | * ContentValues values = new ContentValues(); |
| 4423 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 4424 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 4425 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 4426 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 4427 | * values.put(Phone.LABEL, "free directory assistance"); |
| 4428 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 4429 | * </pre> |
| 4430 | * <p> |
| 4431 | * The same done using ContentProviderOperations: |
| 4432 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4433 | * ArrayList<ContentProviderOperation> ops = |
| 4434 | * new ArrayList<ContentProviderOperation>(); |
| 4435 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4436 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4437 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4438 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 4439 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 4440 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 4441 | * .withValue(Phone.LABEL, "free directory assistance") |
| 4442 | * .build()); |
| 4443 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4444 | * </pre> |
| 4445 | * </p> |
| 4446 | * <dt><b>Update</b></dt> |
| 4447 | * <dd> |
| 4448 | * <p> |
| 4449 | * Just as with insert, update can be done incrementally or as a batch, |
| 4450 | * the batch mode being the preferred method: |
| 4451 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4452 | * ArrayList<ContentProviderOperation> ops = |
| 4453 | * new ArrayList<ContentProviderOperation>(); |
| 4454 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4455 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4456 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4457 | * .withValue(Email.DATA, "somebody@android.com") |
| 4458 | * .build()); |
| 4459 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4460 | * </pre> |
| 4461 | * </p> |
| 4462 | * </dd> |
| 4463 | * <dt><b>Delete</b></dt> |
| 4464 | * <dd> |
| 4465 | * <p> |
| 4466 | * Just as with insert and update, deletion can be done either using the |
| 4467 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4468 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4469 | * ArrayList<ContentProviderOperation> ops = |
| 4470 | * new ArrayList<ContentProviderOperation>(); |
| 4471 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4472 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4473 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4474 | * .build()); |
| 4475 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4476 | * </pre> |
| 4477 | * </p> |
| 4478 | * </dd> |
| 4479 | * <dt><b>Query</b></dt> |
| 4480 | * <dd> |
| 4481 | * <p> |
| 4482 | * <dl> |
| 4483 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4484 | * <dd> |
| 4485 | * <pre> |
| 4486 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4487 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4488 | * Data.CONTACT_ID + "=?" + " AND " |
| 4489 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4490 | * new String[] {String.valueOf(contactId)}, null); |
| 4491 | * </pre> |
| 4492 | * </p> |
| 4493 | * <p> |
| 4494 | * </dd> |
| 4495 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4496 | * <dd> |
| 4497 | * <pre> |
| 4498 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4499 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4500 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4501 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4502 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4503 | * </pre> |
| 4504 | * </dd> |
| 4505 | * <dt>Finding all Data for a given raw contact</dt> |
| 4506 | * <dd> |
| 4507 | * Most sync adapters will want to read all data rows for a raw contact |
| 4508 | * along with the raw contact itself. For that you should use the |
| 4509 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4510 | * </dd> |
| 4511 | * </dl> |
| 4512 | * </p> |
| 4513 | * </dd> |
| 4514 | * </dl> |
| 4515 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4516 | * <p> |
| 4517 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4518 | * should explicitly specify a projection to only those columns that you need. |
| 4519 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4520 | * <table class="jd-sumtable"> |
| 4521 | * <tr> |
| 4522 | * <th colspan='4'>Data</th> |
| 4523 | * </tr> |
| 4524 | * <tr> |
| 4525 | * <td style="width: 7em;">long</td> |
| 4526 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4527 | * <td style="width: 5em;">read-only</td> |
| 4528 | * <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] | 4529 | * 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] | 4530 | * always do an update instead.</td> |
| 4531 | * </tr> |
| 4532 | * <tr> |
| 4533 | * <td>String</td> |
| 4534 | * <td>{@link #MIMETYPE}</td> |
| 4535 | * <td>read/write-once</td> |
| 4536 | * <td> |
| 4537 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4538 | * MIME types are: |
| 4539 | * <ul> |
| 4540 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4541 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4542 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4543 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4544 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4545 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4546 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4547 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4548 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4549 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4550 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4551 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4552 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4553 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4554 | * </ul> |
| 4555 | * </p> |
| 4556 | * </td> |
| 4557 | * </tr> |
| 4558 | * <tr> |
| 4559 | * <td>long</td> |
| 4560 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4561 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4562 | * <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] | 4563 | * </tr> |
| 4564 | * <tr> |
| 4565 | * <td>int</td> |
| 4566 | * <td>{@link #IS_PRIMARY}</td> |
| 4567 | * <td>read/write</td> |
| 4568 | * <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] | 4569 | * "1" if true, "0" if false. |
| 4570 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4571 | * </tr> |
| 4572 | * <tr> |
| 4573 | * <td>int</td> |
| 4574 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4575 | * <td>read/write</td> |
| 4576 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4577 | * 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] | 4578 | * also be "primary". For example, the super-primary entry may be |
| 4579 | * interpreted as the default contact value of its kind (for example, |
| 4580 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4581 | * </tr> |
| 4582 | * <tr> |
| 4583 | * <td>int</td> |
| 4584 | * <td>{@link #DATA_VERSION}</td> |
| 4585 | * <td>read-only</td> |
| 4586 | * <td>The version of this data record. Whenever the data row changes |
| 4587 | * the version goes up. This value is monotonically increasing.</td> |
| 4588 | * </tr> |
| 4589 | * <tr> |
| 4590 | * <td>Any type</td> |
| 4591 | * <td> |
| 4592 | * {@link #DATA1}<br> |
| 4593 | * {@link #DATA2}<br> |
| 4594 | * {@link #DATA3}<br> |
| 4595 | * {@link #DATA4}<br> |
| 4596 | * {@link #DATA5}<br> |
| 4597 | * {@link #DATA6}<br> |
| 4598 | * {@link #DATA7}<br> |
| 4599 | * {@link #DATA8}<br> |
| 4600 | * {@link #DATA9}<br> |
| 4601 | * {@link #DATA10}<br> |
| 4602 | * {@link #DATA11}<br> |
| 4603 | * {@link #DATA12}<br> |
| 4604 | * {@link #DATA13}<br> |
| 4605 | * {@link #DATA14}<br> |
| 4606 | * {@link #DATA15} |
| 4607 | * </td> |
| 4608 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4609 | * <td> |
| 4610 | * <p> |
| 4611 | * Generic data columns. The meaning of each column is determined by the |
| 4612 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4613 | * BLOBs (binary data). |
| 4614 | * </p> |
| 4615 | * <p> |
| 4616 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4617 | * should not be used. There is no guarantee that any sync adapter will |
| 4618 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4619 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4620 | * </p> |
| 4621 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4622 | * </tr> |
| 4623 | * <tr> |
| 4624 | * <td>Any type</td> |
| 4625 | * <td> |
| 4626 | * {@link #SYNC1}<br> |
| 4627 | * {@link #SYNC2}<br> |
| 4628 | * {@link #SYNC3}<br> |
| 4629 | * {@link #SYNC4} |
| 4630 | * </td> |
| 4631 | * <td>read/write</td> |
| 4632 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4633 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4634 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4635 | * </tr> |
| 4636 | * </table> |
| 4637 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4638 | * <p> |
| 4639 | * Some columns from the most recent associated status update are also available |
| 4640 | * through an implicit join. |
| 4641 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4642 | * <table class="jd-sumtable"> |
| 4643 | * <tr> |
| 4644 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4645 | * </tr> |
| 4646 | * <tr> |
| 4647 | * <td style="width: 7em;">int</td> |
| 4648 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4649 | * <td style="width: 5em;">read-only</td> |
| 4650 | * <td>IM presence status linked to this data row. Compare with |
| 4651 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4652 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4653 | * The provider may choose not to store this value |
| 4654 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4655 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4656 | * </td> |
| 4657 | * </tr> |
| 4658 | * <tr> |
| 4659 | * <td>String</td> |
| 4660 | * <td>{@link #STATUS}</td> |
| 4661 | * <td>read-only</td> |
| 4662 | * <td>Latest status update linked with this data row.</td> |
| 4663 | * </tr> |
| 4664 | * <tr> |
| 4665 | * <td>long</td> |
| 4666 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4667 | * <td>read-only</td> |
| 4668 | * <td>The absolute time in milliseconds when the latest status was |
| 4669 | * inserted/updated for this data row.</td> |
| 4670 | * </tr> |
| 4671 | * <tr> |
| 4672 | * <td>String</td> |
| 4673 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4674 | * <td>read-only</td> |
| 4675 | * <td>The package containing resources for this status: label and icon.</td> |
| 4676 | * </tr> |
| 4677 | * <tr> |
| 4678 | * <td>long</td> |
| 4679 | * <td>{@link #STATUS_LABEL}</td> |
| 4680 | * <td>read-only</td> |
| 4681 | * <td>The resource ID of the label describing the source of status update linked |
| 4682 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4683 | * </tr> |
| 4684 | * <tr> |
| 4685 | * <td>long</td> |
| 4686 | * <td>{@link #STATUS_ICON}</td> |
| 4687 | * <td>read-only</td> |
| 4688 | * <td>The resource ID of the icon for the source of the status update linked |
| 4689 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4690 | * </tr> |
| 4691 | * </table> |
| 4692 | * |
| 4693 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4694 | * Some columns from the associated raw contact are also available through an |
| 4695 | * implicit join. The other columns are excluded as uninteresting in this |
| 4696 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4697 | * </p> |
| 4698 | * |
| 4699 | * <table class="jd-sumtable"> |
| 4700 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4701 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4702 | * </tr> |
| 4703 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4704 | * <td style="width: 7em;">long</td> |
| 4705 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4706 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4707 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4708 | * to.</td> |
| 4709 | * </tr> |
| 4710 | * <tr> |
| 4711 | * <td>int</td> |
| 4712 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4713 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4714 | * <td>See {@link RawContacts}.</td> |
| 4715 | * </tr> |
| 4716 | * <tr> |
| 4717 | * <td>int</td> |
| 4718 | * <td>{@link #DELETED}</td> |
| 4719 | * <td>read-only</td> |
| 4720 | * <td>See {@link RawContacts}.</td> |
| 4721 | * </tr> |
| 4722 | * </table> |
| 4723 | * |
| 4724 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4725 | * The ID column for the associated aggregated contact table |
| 4726 | * {@link ContactsContract.Contacts} is available |
| 4727 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4728 | * The remaining columns from this table are also |
| 4729 | * available, through an implicit join. This |
| 4730 | * facilitates lookup by |
| 4731 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4732 | * </p> |
| 4733 | * |
| 4734 | * <table class="jd-sumtable"> |
| 4735 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4736 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4737 | * </tr> |
| 4738 | * <tr> |
| 4739 | * <td style="width: 7em;">String</td> |
| 4740 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4741 | * <td style="width: 5em;">read-only</td> |
| 4742 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4743 | * </tr> |
| 4744 | * <tr> |
| 4745 | * <td>String</td> |
| 4746 | * <td>{@link #DISPLAY_NAME}</td> |
| 4747 | * <td>read-only</td> |
| 4748 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4749 | * </tr> |
| 4750 | * <tr> |
| 4751 | * <td>long</td> |
| 4752 | * <td>{@link #PHOTO_ID}</td> |
| 4753 | * <td>read-only</td> |
| 4754 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4755 | * </tr> |
| 4756 | * <tr> |
| 4757 | * <td>int</td> |
| 4758 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4759 | * <td>read-only</td> |
| 4760 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4761 | * </tr> |
| 4762 | * <tr> |
| 4763 | * <td>int</td> |
| 4764 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4765 | * <td>read-only</td> |
| 4766 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4767 | * </tr> |
| 4768 | * <tr> |
| 4769 | * <td>int</td> |
| 4770 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4771 | * <td>read-only</td> |
| 4772 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4773 | * </tr> |
| 4774 | * <tr> |
| 4775 | * <td>long</td> |
| 4776 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4777 | * <td>read-only</td> |
| 4778 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4779 | * </tr> |
| 4780 | * <tr> |
| 4781 | * <td>int</td> |
| 4782 | * <td>{@link #STARRED}</td> |
| 4783 | * <td>read-only</td> |
| 4784 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4785 | * </tr> |
| 4786 | * <tr> |
| 4787 | * <td>String</td> |
| 4788 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4789 | * <td>read-only</td> |
| 4790 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4791 | * </tr> |
| 4792 | * <tr> |
| 4793 | * <td>int</td> |
| 4794 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4795 | * <td>read-only</td> |
| 4796 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4797 | * </tr> |
| 4798 | * <tr> |
| 4799 | * <td>int</td> |
| 4800 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4801 | * <td>read-only</td> |
| 4802 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4803 | * </tr> |
| 4804 | * <tr> |
| 4805 | * <td>String</td> |
| 4806 | * <td>{@link #CONTACT_STATUS}</td> |
| 4807 | * <td>read-only</td> |
| 4808 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4809 | * </tr> |
| 4810 | * <tr> |
| 4811 | * <td>long</td> |
| 4812 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4813 | * <td>read-only</td> |
| 4814 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4815 | * </tr> |
| 4816 | * <tr> |
| 4817 | * <td>String</td> |
| 4818 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4819 | * <td>read-only</td> |
| 4820 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4821 | * </tr> |
| 4822 | * <tr> |
| 4823 | * <td>long</td> |
| 4824 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4825 | * <td>read-only</td> |
| 4826 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4827 | * </tr> |
| 4828 | * <tr> |
| 4829 | * <td>long</td> |
| 4830 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4831 | * <td>read-only</td> |
| 4832 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4833 | * </tr> |
| 4834 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4835 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 4836 | public final static class Data implements DataColumnsWithJoins, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4837 | /** |
| 4838 | * This utility class cannot be instantiated |
| 4839 | */ |
| 4840 | private Data() {} |
| 4841 | |
| 4842 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4843 | * The content:// style URI for this table, which requests a directory |
| 4844 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4845 | */ |
| 4846 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4847 | |
| 4848 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 4849 | * The content:// style URI for this table in managed profile, which requests a directory |
| 4850 | * of data rows matching the selection criteria. |
| 4851 | * |
| 4852 | * @hide |
| 4853 | */ |
| 4854 | static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4855 | "data_enterprise"); |
| 4856 | |
| 4857 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4858 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4859 | * This specifies whether or not the returned data items should be filtered to show |
| 4860 | * data items belonging to visible contacts only. |
| 4861 | */ |
| 4862 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4863 | |
| 4864 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4865 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4866 | */ |
| 4867 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4868 | |
| 4869 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4870 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4871 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4872 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4873 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4874 | * </p> |
| 4875 | * <p> |
| 4876 | * Returns the Uri for the contact in the first entry returned by |
| 4877 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4878 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4879 | * results, silently returns null. |
| 4880 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4881 | */ |
| 4882 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4883 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4884 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4885 | }, null, null, null); |
| 4886 | |
| 4887 | Uri lookupUri = null; |
| 4888 | try { |
| 4889 | if (cursor != null && cursor.moveToFirst()) { |
| 4890 | final long contactId = cursor.getLong(0); |
| 4891 | final String lookupKey = cursor.getString(1); |
| 4892 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4893 | } |
| 4894 | } finally { |
| 4895 | if (cursor != null) cursor.close(); |
| 4896 | } |
| 4897 | return lookupUri; |
| 4898 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4899 | } |
| 4900 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4901 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4902 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4903 | * 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] | 4904 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4905 | * read-only table. |
| 4906 | * </p> |
| 4907 | * <p> |
| 4908 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4909 | * a one row for each data row. If the raw contact has no data rows, the |
| 4910 | * cursor will still contain one row with the raw contact-level information |
| 4911 | * and nulls for data columns. |
| 4912 | * |
| 4913 | * <pre> |
| 4914 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4915 | * Cursor c = getContentResolver().query(entityUri, |
| 4916 | * new String[]{ |
| 4917 | * RawContactsEntity.SOURCE_ID, |
| 4918 | * RawContactsEntity.DATA_ID, |
| 4919 | * RawContactsEntity.MIMETYPE, |
| 4920 | * RawContactsEntity.DATA1 |
| 4921 | * }, null, null, null); |
| 4922 | * try { |
| 4923 | * while (c.moveToNext()) { |
| 4924 | * String sourceId = c.getString(0); |
| 4925 | * if (!c.isNull(1)) { |
| 4926 | * String mimeType = c.getString(2); |
| 4927 | * String data = c.getString(3); |
| 4928 | * ... |
| 4929 | * } |
| 4930 | * } |
| 4931 | * } finally { |
| 4932 | * c.close(); |
| 4933 | * } |
| 4934 | * </pre> |
| 4935 | * |
| 4936 | * <h3>Columns</h3> |
| 4937 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4938 | * |
| 4939 | * <table class="jd-sumtable"> |
| 4940 | * <tr> |
| 4941 | * <th colspan='4'>RawContacts</th> |
| 4942 | * </tr> |
| 4943 | * <tr> |
| 4944 | * <td style="width: 7em;">long</td> |
| 4945 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4946 | * <td style="width: 5em;">read-only</td> |
| 4947 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4948 | * </tr> |
| 4949 | * <tr> |
| 4950 | * <td>long</td> |
| 4951 | * <td>{@link #CONTACT_ID}</td> |
| 4952 | * <td>read-only</td> |
| 4953 | * <td>See {@link RawContacts}.</td> |
| 4954 | * </tr> |
| 4955 | * <tr> |
| 4956 | * <td>int</td> |
| 4957 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4958 | * <td>read-only</td> |
| 4959 | * <td>See {@link RawContacts}.</td> |
| 4960 | * </tr> |
| 4961 | * <tr> |
| 4962 | * <td>int</td> |
| 4963 | * <td>{@link #DELETED}</td> |
| 4964 | * <td>read-only</td> |
| 4965 | * <td>See {@link RawContacts}.</td> |
| 4966 | * </tr> |
| 4967 | * </table> |
| 4968 | * |
| 4969 | * <table class="jd-sumtable"> |
| 4970 | * <tr> |
| 4971 | * <th colspan='4'>Data</th> |
| 4972 | * </tr> |
| 4973 | * <tr> |
| 4974 | * <td style="width: 7em;">long</td> |
| 4975 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4976 | * <td style="width: 5em;">read-only</td> |
| 4977 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4978 | * </tr> |
| 4979 | * <tr> |
| 4980 | * <td>String</td> |
| 4981 | * <td>{@link #MIMETYPE}</td> |
| 4982 | * <td>read-only</td> |
| 4983 | * <td>See {@link ContactsContract.Data}.</td> |
| 4984 | * </tr> |
| 4985 | * <tr> |
| 4986 | * <td>int</td> |
| 4987 | * <td>{@link #IS_PRIMARY}</td> |
| 4988 | * <td>read-only</td> |
| 4989 | * <td>See {@link ContactsContract.Data}.</td> |
| 4990 | * </tr> |
| 4991 | * <tr> |
| 4992 | * <td>int</td> |
| 4993 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4994 | * <td>read-only</td> |
| 4995 | * <td>See {@link ContactsContract.Data}.</td> |
| 4996 | * </tr> |
| 4997 | * <tr> |
| 4998 | * <td>int</td> |
| 4999 | * <td>{@link #DATA_VERSION}</td> |
| 5000 | * <td>read-only</td> |
| 5001 | * <td>See {@link ContactsContract.Data}.</td> |
| 5002 | * </tr> |
| 5003 | * <tr> |
| 5004 | * <td>Any type</td> |
| 5005 | * <td> |
| 5006 | * {@link #DATA1}<br> |
| 5007 | * {@link #DATA2}<br> |
| 5008 | * {@link #DATA3}<br> |
| 5009 | * {@link #DATA4}<br> |
| 5010 | * {@link #DATA5}<br> |
| 5011 | * {@link #DATA6}<br> |
| 5012 | * {@link #DATA7}<br> |
| 5013 | * {@link #DATA8}<br> |
| 5014 | * {@link #DATA9}<br> |
| 5015 | * {@link #DATA10}<br> |
| 5016 | * {@link #DATA11}<br> |
| 5017 | * {@link #DATA12}<br> |
| 5018 | * {@link #DATA13}<br> |
| 5019 | * {@link #DATA14}<br> |
| 5020 | * {@link #DATA15} |
| 5021 | * </td> |
| 5022 | * <td>read-only</td> |
| 5023 | * <td>See {@link ContactsContract.Data}.</td> |
| 5024 | * </tr> |
| 5025 | * <tr> |
| 5026 | * <td>Any type</td> |
| 5027 | * <td> |
| 5028 | * {@link #SYNC1}<br> |
| 5029 | * {@link #SYNC2}<br> |
| 5030 | * {@link #SYNC3}<br> |
| 5031 | * {@link #SYNC4} |
| 5032 | * </td> |
| 5033 | * <td>read-only</td> |
| 5034 | * <td>See {@link ContactsContract.Data}.</td> |
| 5035 | * </tr> |
| 5036 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5037 | */ |
| 5038 | public final static class RawContactsEntity |
| 5039 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 5040 | /** |
| 5041 | * This utility class cannot be instantiated |
| 5042 | */ |
| 5043 | private RawContactsEntity() {} |
| 5044 | |
| 5045 | /** |
| 5046 | * The content:// style URI for this table |
| 5047 | */ |
| 5048 | public static final Uri CONTENT_URI = |
| 5049 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 5050 | |
| 5051 | /** |
Ricky Wai | 9aaaa1e | 2015-03-08 00:53:20 +0000 | [diff] [blame] | 5052 | * The content:// style URI for this table in corp profile |
| 5053 | * |
| 5054 | * @hide |
| 5055 | */ |
| 5056 | public static final Uri CORP_CONTENT_URI = |
| 5057 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp"); |
| 5058 | |
| 5059 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 5060 | * The content:// style URI for this table, specific to the user's profile. |
| 5061 | */ |
| 5062 | public static final Uri PROFILE_CONTENT_URI = |
| 5063 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 5064 | |
| 5065 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5066 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 5067 | */ |
| 5068 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 5069 | |
| 5070 | /** |
| 5071 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 5072 | * Data.CONTENT_URI contains only exportable data. |
| 5073 | * |
| 5074 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 5075 | * needs to exclude "un-exportable" data from available data to export, while |
| 5076 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 5077 | * ones and providers return all of them regardless of the callers' intention. |
| 5078 | * <P>Type: INTEGER</p> |
| 5079 | * |
| 5080 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 5081 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 5082 | * we only use this flag in queryEntities(), not query(). |
| 5083 | */ |
| 5084 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 5085 | |
| 5086 | /** |
| 5087 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 5088 | * <P>Type: INTEGER</P> |
| 5089 | */ |
| 5090 | public static final String DATA_ID = "data_id"; |
| 5091 | } |
| 5092 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5093 | /** |
| 5094 | * @see PhoneLookup |
| 5095 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5096 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5097 | /** |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5098 | * The ID of the data row. |
| 5099 | * <P>Type: INTEGER</P> |
| 5100 | */ |
| 5101 | public static final String DATA_ID = "data_id"; |
| 5102 | /** |
| 5103 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
| 5104 | * data belongs to. |
| 5105 | * <P>Type: INTEGER</P> |
| 5106 | */ |
| 5107 | public static final String CONTACT_ID = "contact_id"; |
| 5108 | /** |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5109 | * The phone number as the user entered it. |
| 5110 | * <P>Type: TEXT</P> |
| 5111 | */ |
| 5112 | public static final String NUMBER = "number"; |
| 5113 | |
| 5114 | /** |
| 5115 | * The type of phone number, for example Home or Work. |
| 5116 | * <P>Type: INTEGER</P> |
| 5117 | */ |
| 5118 | public static final String TYPE = "type"; |
| 5119 | |
| 5120 | /** |
| 5121 | * The user defined label for the phone number. |
| 5122 | * <P>Type: TEXT</P> |
| 5123 | */ |
| 5124 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5125 | |
| 5126 | /** |
| 5127 | * The phone number's E164 representation. |
| 5128 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5129 | */ |
| 5130 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5131 | } |
| 5132 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5133 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5134 | * 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] | 5135 | * 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] | 5136 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 5137 | * optimized. |
| 5138 | * <pre> |
| 5139 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 5140 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 5141 | * </pre> |
| 5142 | * |
| 5143 | * <h3>Columns</h3> |
| 5144 | * |
| 5145 | * <table class="jd-sumtable"> |
| 5146 | * <tr> |
| 5147 | * <th colspan='4'>PhoneLookup</th> |
| 5148 | * </tr> |
| 5149 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5150 | * <td>String</td> |
| 5151 | * <td>{@link #NUMBER}</td> |
| 5152 | * <td>read-only</td> |
| 5153 | * <td>Phone number.</td> |
| 5154 | * </tr> |
| 5155 | * <tr> |
| 5156 | * <td>String</td> |
| 5157 | * <td>{@link #TYPE}</td> |
| 5158 | * <td>read-only</td> |
| 5159 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 5160 | * </tr> |
| 5161 | * <tr> |
| 5162 | * <td>String</td> |
| 5163 | * <td>{@link #LABEL}</td> |
| 5164 | * <td>read-only</td> |
| 5165 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 5166 | * </tr> |
| 5167 | * </table> |
| 5168 | * <p> |
| 5169 | * Columns from the Contacts table are also available through a join. |
| 5170 | * </p> |
| 5171 | * <table class="jd-sumtable"> |
| 5172 | * <tr> |
| 5173 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 5174 | * </tr> |
| 5175 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 5176 | * <td>long</td> |
| 5177 | * <td>{@link #_ID}</td> |
| 5178 | * <td>read-only</td> |
| 5179 | * <td>Contact ID.</td> |
| 5180 | * </tr> |
| 5181 | * <tr> |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5182 | * <td>long</td> |
| 5183 | * <td>{@link #CONTACT_ID}</td> |
| 5184 | * <td>read-only</td> |
| 5185 | * <td>Contact ID.</td> |
| 5186 | * </tr> |
| 5187 | * <tr> |
| 5188 | * <td>long</td> |
| 5189 | * <td>{@link #DATA_ID}</td> |
| 5190 | * <td>read-only</td> |
| 5191 | * <td>Data ID.</td> |
| 5192 | * </tr> |
| 5193 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5194 | * <td>String</td> |
| 5195 | * <td>{@link #LOOKUP_KEY}</td> |
| 5196 | * <td>read-only</td> |
| 5197 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5198 | * </tr> |
| 5199 | * <tr> |
| 5200 | * <td>String</td> |
| 5201 | * <td>{@link #DISPLAY_NAME}</td> |
| 5202 | * <td>read-only</td> |
| 5203 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5204 | * </tr> |
| 5205 | * <tr> |
| 5206 | * <td>long</td> |
| 5207 | * <td>{@link #PHOTO_ID}</td> |
| 5208 | * <td>read-only</td> |
| 5209 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5210 | * </tr> |
| 5211 | * <tr> |
| 5212 | * <td>int</td> |
| 5213 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 5214 | * <td>read-only</td> |
| 5215 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5216 | * </tr> |
| 5217 | * <tr> |
| 5218 | * <td>int</td> |
| 5219 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 5220 | * <td>read-only</td> |
| 5221 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5222 | * </tr> |
| 5223 | * <tr> |
| 5224 | * <td>int</td> |
| 5225 | * <td>{@link #TIMES_CONTACTED}</td> |
| 5226 | * <td>read-only</td> |
| 5227 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5228 | * </tr> |
| 5229 | * <tr> |
| 5230 | * <td>long</td> |
| 5231 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 5232 | * <td>read-only</td> |
| 5233 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5234 | * </tr> |
| 5235 | * <tr> |
| 5236 | * <td>int</td> |
| 5237 | * <td>{@link #STARRED}</td> |
| 5238 | * <td>read-only</td> |
| 5239 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5240 | * </tr> |
| 5241 | * <tr> |
| 5242 | * <td>String</td> |
| 5243 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 5244 | * <td>read-only</td> |
| 5245 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5246 | * </tr> |
| 5247 | * <tr> |
| 5248 | * <td>int</td> |
| 5249 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 5250 | * <td>read-only</td> |
| 5251 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5252 | * </tr> |
| 5253 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5254 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5255 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
Suprabh Shukla | 2c3fb3f | 2016-09-06 15:30:53 -0700 | [diff] [blame] | 5256 | ContactsColumns, ContactOptionsColumns, ContactNameColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5257 | /** |
| 5258 | * This utility class cannot be instantiated |
| 5259 | */ |
| 5260 | private PhoneLookup() {} |
| 5261 | |
| 5262 | /** |
| 5263 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 5264 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5265 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 5266 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 5267 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5268 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5269 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5270 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5271 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5272 | |
| 5273 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5274 | * <p>URI used for the "enterprise caller-id".</p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5275 | * |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5276 | * <p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5277 | * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 5278 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5279 | * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile |
| 5280 | * linked to the current profile, it first queries against the personal contact database, |
| 5281 | * and if no matching contacts are found there, then queries against the |
| 5282 | * corp contacts database. |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5283 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5284 | * <p> |
| 5285 | * If a result is from the corp profile, it makes the following changes to the data: |
| 5286 | * <ul> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5287 | * <li> |
| 5288 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 5289 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 5290 | * load pictures from them. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 5291 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. |
| 5292 | * </li> |
| 5293 | * <li> |
| 5294 | * 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] | 5295 | * is from the corp profile, use |
| 5296 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5297 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5298 | * <li> |
| 5299 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 5300 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 5301 | * <li> |
| 5302 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 5303 | * explicitly say to accept them. |
| 5304 | * </li> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5305 | * </ul> |
Makoto Onuki | 95a9cfb | 2014-07-08 17:11:54 -0700 | [diff] [blame] | 5306 | * <p> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5307 | * A contact lookup URL built by |
| 5308 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 5309 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 5310 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 5311 | * corp profile. |
| 5312 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5313 | * |
| 5314 | * <pre> |
| 5315 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, |
| 5316 | * Uri.encode(phoneNumber)); |
| 5317 | * </pre> |
| 5318 | */ |
| 5319 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5320 | "phone_lookup_enterprise"); |
| 5321 | |
| 5322 | /** |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5323 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 5324 | * |
| 5325 | * @hide |
| 5326 | */ |
| 5327 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5328 | |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 5329 | /** |
| 5330 | * If this boolean parameter is set to true, then the appended query is treated as a |
| 5331 | * SIP address and the lookup will be performed against SIP addresses in the user's |
| 5332 | * contacts. |
| 5333 | */ |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5334 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5335 | } |
| 5336 | |
| 5337 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5338 | * Additional data mixed in with {@link StatusColumns} to link |
| 5339 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5340 | * |
| 5341 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5342 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5343 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 5344 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5345 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5346 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5347 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5348 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5349 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5350 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5351 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5352 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5353 | * <p>Type: NUMBER</p> |
| 5354 | */ |
| 5355 | public static final String PROTOCOL = "protocol"; |
| 5356 | |
| 5357 | /** |
| 5358 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5359 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5360 | * omitted if {@link #PROTOCOL} value is not |
| 5361 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 5362 | * |
| 5363 | * <p>Type: NUMBER</p> |
| 5364 | */ |
| 5365 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 5366 | |
| 5367 | /** |
| 5368 | * The IM handle the presence item is for. The handle is scoped to |
| 5369 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5370 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5371 | */ |
| 5372 | public static final String IM_HANDLE = "im_handle"; |
| 5373 | |
| 5374 | /** |
| 5375 | * 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] | 5376 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5377 | */ |
| 5378 | public static final String IM_ACCOUNT = "im_account"; |
| 5379 | } |
| 5380 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5381 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5382 | * <p> |
| 5383 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 5384 | * the user's latest status update via the corresponding source, e.g. |
| 5385 | * "Having lunch" via "Google Talk". |
| 5386 | * </p> |
| 5387 | * <p> |
| 5388 | * There are two ways a status update can be inserted: by explicitly linking |
| 5389 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 5390 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5391 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 5392 | * either. |
| 5393 | * </p> |
| 5394 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5395 | * Inserting or updating a status update for the user's profile requires either using |
| 5396 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 5397 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 5398 | * profile. |
| 5399 | * </p> |
| 5400 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5401 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 5402 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 5403 | * exists. |
| 5404 | * </p> |
| 5405 | * <p> |
| 5406 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 5407 | * for multiple contacts at once. |
| 5408 | * </p> |
| 5409 | * |
| 5410 | * <h3>Columns</h3> |
| 5411 | * <table class="jd-sumtable"> |
| 5412 | * <tr> |
| 5413 | * <th colspan='4'>StatusUpdates</th> |
| 5414 | * </tr> |
| 5415 | * <tr> |
| 5416 | * <td>long</td> |
| 5417 | * <td>{@link #DATA_ID}</td> |
| 5418 | * <td>read/write</td> |
| 5419 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 5420 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 5421 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5422 | * {@link #IM_HANDLE} columns. |
| 5423 | * </td> |
| 5424 | * </tr> |
| 5425 | * <tr> |
| 5426 | * <td>long</td> |
| 5427 | * <td>{@link #PROTOCOL}</td> |
| 5428 | * <td>read/write</td> |
| 5429 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 5430 | * </tr> |
| 5431 | * <tr> |
| 5432 | * <td>String</td> |
| 5433 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 5434 | * <td>read/write</td> |
| 5435 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5436 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5437 | * omitted if {@link #PROTOCOL} value is not |
| 5438 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 5439 | * </tr> |
| 5440 | * <tr> |
| 5441 | * <td>String</td> |
| 5442 | * <td>{@link #IM_HANDLE}</td> |
| 5443 | * <td>read/write</td> |
| 5444 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 5445 | * {@link #PROTOCOL}.</td> |
| 5446 | * </tr> |
| 5447 | * <tr> |
| 5448 | * <td>String</td> |
| 5449 | * <td>{@link #IM_ACCOUNT}</td> |
| 5450 | * <td>read/write</td> |
| 5451 | * <td>The IM account for the local user that the presence data came from.</td> |
| 5452 | * </tr> |
| 5453 | * <tr> |
| 5454 | * <td>int</td> |
| 5455 | * <td>{@link #PRESENCE}</td> |
| 5456 | * <td>read/write</td> |
| 5457 | * <td>Contact IM presence status. The allowed values are: |
| 5458 | * <p> |
| 5459 | * <ul> |
| 5460 | * <li>{@link #OFFLINE}</li> |
| 5461 | * <li>{@link #INVISIBLE}</li> |
| 5462 | * <li>{@link #AWAY}</li> |
| 5463 | * <li>{@link #IDLE}</li> |
| 5464 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 5465 | * <li>{@link #AVAILABLE}</li> |
| 5466 | * </ul> |
| 5467 | * </p> |
| 5468 | * <p> |
| 5469 | * Since presence status is inherently volatile, the content provider |
| 5470 | * may choose not to store this field in long-term storage. |
| 5471 | * </p> |
| 5472 | * </td> |
| 5473 | * </tr> |
| 5474 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5475 | * <td>int</td> |
| 5476 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 5477 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5478 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 5479 | * 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] | 5480 | * <p> |
| 5481 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5482 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5483 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 5484 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 5485 | * </ul> |
| 5486 | * </p> |
| 5487 | * <p> |
| 5488 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 5489 | * one device to another, the content provider may choose not to store this field in long-term |
| 5490 | * storage. |
| 5491 | * </p> |
| 5492 | * </td> |
| 5493 | * </tr> |
| 5494 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5495 | * <td>String</td> |
| 5496 | * <td>{@link #STATUS}</td> |
| 5497 | * <td>read/write</td> |
| 5498 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 5499 | * </tr> |
| 5500 | * <tr> |
| 5501 | * <td>long</td> |
| 5502 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 5503 | * <td>read/write</td> |
| 5504 | * <td>The absolute time in milliseconds when the status was |
| 5505 | * entered by the user. If this value is not provided, the provider will follow |
| 5506 | * this logic: if there was no prior status update, the value will be left as null. |
| 5507 | * If there was a prior status update, the provider will default this field |
| 5508 | * to the current time.</td> |
| 5509 | * </tr> |
| 5510 | * <tr> |
| 5511 | * <td>String</td> |
| 5512 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 5513 | * <td>read/write</td> |
| 5514 | * <td> The package containing resources for this status: label and icon.</td> |
| 5515 | * </tr> |
| 5516 | * <tr> |
| 5517 | * <td>long</td> |
| 5518 | * <td>{@link #STATUS_LABEL}</td> |
| 5519 | * <td>read/write</td> |
| 5520 | * <td>The resource ID of the label describing the source of contact status, |
| 5521 | * e.g. "Google Talk". This resource is scoped by the |
| 5522 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 5523 | * </tr> |
| 5524 | * <tr> |
| 5525 | * <td>long</td> |
| 5526 | * <td>{@link #STATUS_ICON}</td> |
| 5527 | * <td>read/write</td> |
| 5528 | * <td>The resource ID of the icon for the source of contact status. This |
| 5529 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 5530 | * </tr> |
| 5531 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5532 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5533 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5534 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5535 | /** |
| 5536 | * This utility class cannot be instantiated |
| 5537 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5538 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5539 | |
| 5540 | /** |
| 5541 | * The content:// style URI for this table |
| 5542 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5543 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5544 | |
| 5545 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5546 | * The content:// style URI for this table, specific to the user's profile. |
| 5547 | */ |
| 5548 | public static final Uri PROFILE_CONTENT_URI = |
| 5549 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5550 | |
| 5551 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5552 | * Gets the resource ID for the proper presence icon. |
| 5553 | * |
| 5554 | * @param status the status to get the icon for |
| 5555 | * @return the resource ID for the proper presence icon |
| 5556 | */ |
| 5557 | public static final int getPresenceIconResourceId(int status) { |
| 5558 | switch (status) { |
| 5559 | case AVAILABLE: |
| 5560 | return android.R.drawable.presence_online; |
| 5561 | case IDLE: |
| 5562 | case AWAY: |
| 5563 | return android.R.drawable.presence_away; |
| 5564 | case DO_NOT_DISTURB: |
| 5565 | return android.R.drawable.presence_busy; |
| 5566 | case INVISIBLE: |
| 5567 | return android.R.drawable.presence_invisible; |
| 5568 | case OFFLINE: |
| 5569 | default: |
| 5570 | return android.R.drawable.presence_offline; |
| 5571 | } |
| 5572 | } |
| 5573 | |
| 5574 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5575 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5576 | * |
| 5577 | * @param status The status code. |
| 5578 | * @return An integer representing the precedence, 0 being the lowest. |
| 5579 | */ |
| 5580 | public static final int getPresencePrecedence(int status) { |
| 5581 | // Keep this function here incase we want to enforce a different precedence than the |
| 5582 | // natural order of the status constants. |
| 5583 | return status; |
| 5584 | } |
| 5585 | |
| 5586 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5587 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5588 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5589 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5590 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5591 | |
| 5592 | /** |
| 5593 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5594 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5595 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5596 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5597 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5598 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5599 | /** |
| 5600 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5601 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5602 | @Deprecated |
| 5603 | public static final class Presence extends StatusUpdates { |
| 5604 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5605 | } |
| 5606 | |
| 5607 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 5608 | * Additional column returned by |
| 5609 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5610 | * why the filter matched the contact. This column will contain extracts from the contact's |
| 5611 | * constituent {@link Data Data} items, formatted in a way that indicates the section of the |
| 5612 | * snippet that matched the filter. |
| 5613 | * |
| 5614 | * <p> |
| 5615 | * The following example searches for all contacts that match the query "presi" and requests |
| 5616 | * the snippet column as well. |
| 5617 | * <pre> |
| 5618 | * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); |
| 5619 | * builder.appendPath("presi"); |
| 5620 | * // Defer snippeting to the client side if possible, for performance reasons. |
| 5621 | * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); |
| 5622 | * |
| 5623 | * Cursor cursor = getContentResolver().query(builder.build()); |
| 5624 | * |
| 5625 | * Bundle extras = cursor.getExtras(); |
| 5626 | * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { |
| 5627 | * // Do our own snippet formatting. |
| 5628 | * // For a contact with the email address (president@organization.com), the snippet |
| 5629 | * // column will contain the string "president@organization.com". |
| 5630 | * } else { |
| 5631 | * // The snippet has already been pre-formatted, we can display it as is. |
| 5632 | * // For a contact with the email address (president@organization.com), the snippet |
| 5633 | * // column will contain the string "[presi]dent@organization.com". |
| 5634 | * } |
| 5635 | * </pre> |
| 5636 | * </p> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5637 | */ |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5638 | public static class SearchSnippets { |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5639 | |
| 5640 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5641 | * The search snippet constructed by SQLite snippeting functionality. |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5642 | * <p> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5643 | * The snippet may contain (parts of) several data elements belonging to the contact, |
| 5644 | * with the matching parts optionally surrounded by special characters that indicate the |
| 5645 | * start and end of matching text. |
| 5646 | * |
| 5647 | * For example, if a contact has an address "123 Main Street", using a filter "mai" would |
| 5648 | * return the formatted snippet "123 [Mai]n street". |
| 5649 | * |
| 5650 | * @see <a href="http://www.sqlite.org/fts3.html#snippet"> |
| 5651 | * http://www.sqlite.org/fts3.html#snippet</a> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5652 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5653 | public static final String SNIPPET = "snippet"; |
| 5654 | |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5655 | /** |
| 5656 | * Comma-separated parameters for the generation of the snippet: |
| 5657 | * <ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5658 | * <li>The "start match" text. Default is '['</li> |
| 5659 | * <li>The "end match" text. Default is ']'</li> |
| 5660 | * <li>The "ellipsis" text. Default is "..."</li> |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5661 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5662 | * a positive or a negative number: A positive number indicates how many |
| 5663 | * tokens can be returned in total. A negative number indicates how many |
| 5664 | * tokens can be returned per occurrence of the search terms.</li> |
| 5665 | * </ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5666 | * |
| 5667 | * @hide |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5668 | */ |
| 5669 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5670 | |
| 5671 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5672 | * The key to ask the provider to defer the formatting of the snippet to the client if |
| 5673 | * possible, for performance reasons. |
| 5674 | * 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] | 5675 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5676 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5677 | * should do its own formatting of the snippet. If it doesn't exist, the snippet column |
| 5678 | * in the cursor should already contain a formatted snippet. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5679 | */ |
| 5680 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5681 | } |
| 5682 | |
| 5683 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5684 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5685 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5686 | */ |
| 5687 | public static final class CommonDataKinds { |
| 5688 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5689 | * This utility class cannot be instantiated |
| 5690 | */ |
| 5691 | private CommonDataKinds() {} |
| 5692 | |
| 5693 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5694 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5695 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5696 | * |
| 5697 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5698 | */ |
| 5699 | public static final String PACKAGE_COMMON = "common"; |
| 5700 | |
| 5701 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5702 | * The base types that all "Typed" data kinds support. |
| 5703 | */ |
| 5704 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5705 | /** |
| 5706 | * A custom type. The custom label should be supplied by user. |
| 5707 | */ |
| 5708 | public static int TYPE_CUSTOM = 0; |
| 5709 | } |
| 5710 | |
| 5711 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5712 | * Columns common across the specific types. |
| 5713 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5714 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5715 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5716 | * The data for the contact method. |
| 5717 | * <P>Type: TEXT</P> |
| 5718 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5719 | public static final String DATA = DataColumns.DATA1; |
| 5720 | |
| 5721 | /** |
| 5722 | * The type of data, for example Home or Work. |
| 5723 | * <P>Type: INTEGER</P> |
| 5724 | */ |
| 5725 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5726 | |
| 5727 | /** |
| 5728 | * The user defined label for the the contact method. |
| 5729 | * <P>Type: TEXT</P> |
| 5730 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5731 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5732 | } |
| 5733 | |
| 5734 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5735 | * A data kind representing the contact's proper name. You can use all |
| 5736 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5737 | * |
| 5738 | * <h2>Column aliases</h2> |
| 5739 | * <table class="jd-sumtable"> |
| 5740 | * <tr> |
| 5741 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5742 | * </tr> |
| 5743 | * <tr> |
| 5744 | * <td>String</td> |
| 5745 | * <td>{@link #DISPLAY_NAME}</td> |
| 5746 | * <td>{@link #DATA1}</td> |
| 5747 | * <td></td> |
| 5748 | * </tr> |
| 5749 | * <tr> |
| 5750 | * <td>String</td> |
| 5751 | * <td>{@link #GIVEN_NAME}</td> |
| 5752 | * <td>{@link #DATA2}</td> |
| 5753 | * <td></td> |
| 5754 | * </tr> |
| 5755 | * <tr> |
| 5756 | * <td>String</td> |
| 5757 | * <td>{@link #FAMILY_NAME}</td> |
| 5758 | * <td>{@link #DATA3}</td> |
| 5759 | * <td></td> |
| 5760 | * </tr> |
| 5761 | * <tr> |
| 5762 | * <td>String</td> |
| 5763 | * <td>{@link #PREFIX}</td> |
| 5764 | * <td>{@link #DATA4}</td> |
| 5765 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5766 | * </tr> |
| 5767 | * <tr> |
| 5768 | * <td>String</td> |
| 5769 | * <td>{@link #MIDDLE_NAME}</td> |
| 5770 | * <td>{@link #DATA5}</td> |
| 5771 | * <td></td> |
| 5772 | * </tr> |
| 5773 | * <tr> |
| 5774 | * <td>String</td> |
| 5775 | * <td>{@link #SUFFIX}</td> |
| 5776 | * <td>{@link #DATA6}</td> |
| 5777 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5778 | * </tr> |
| 5779 | * <tr> |
| 5780 | * <td>String</td> |
| 5781 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5782 | * <td>{@link #DATA7}</td> |
| 5783 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5784 | * </tr> |
| 5785 | * <tr> |
| 5786 | * <td>String</td> |
| 5787 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5788 | * <td>{@link #DATA8}</td> |
| 5789 | * <td></td> |
| 5790 | * </tr> |
| 5791 | * <tr> |
| 5792 | * <td>String</td> |
| 5793 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5794 | * <td>{@link #DATA9}</td> |
| 5795 | * <td></td> |
| 5796 | * </tr> |
| 5797 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5798 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5799 | public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5800 | /** |
| 5801 | * This utility class cannot be instantiated |
| 5802 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5803 | private StructuredName() {} |
| 5804 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5805 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5806 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5807 | |
| 5808 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5809 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5810 | * <i>Unstructured component of the name should be consistent with |
| 5811 | * its structured representation.</i> |
| 5812 | * <p> |
| 5813 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5814 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5815 | public static final String DISPLAY_NAME = DATA1; |
| 5816 | |
| 5817 | /** |
| 5818 | * The given name for the contact. |
| 5819 | * <P>Type: TEXT</P> |
| 5820 | */ |
| 5821 | public static final String GIVEN_NAME = DATA2; |
| 5822 | |
| 5823 | /** |
| 5824 | * The family name for the contact. |
| 5825 | * <P>Type: TEXT</P> |
| 5826 | */ |
| 5827 | public static final String FAMILY_NAME = DATA3; |
| 5828 | |
| 5829 | /** |
| 5830 | * The contact's honorific prefix, e.g. "Sir" |
| 5831 | * <P>Type: TEXT</P> |
| 5832 | */ |
| 5833 | public static final String PREFIX = DATA4; |
| 5834 | |
| 5835 | /** |
| 5836 | * The contact's middle name |
| 5837 | * <P>Type: TEXT</P> |
| 5838 | */ |
| 5839 | public static final String MIDDLE_NAME = DATA5; |
| 5840 | |
| 5841 | /** |
| 5842 | * The contact's honorific suffix, e.g. "Jr" |
| 5843 | */ |
| 5844 | public static final String SUFFIX = DATA6; |
| 5845 | |
| 5846 | /** |
| 5847 | * The phonetic version of the given name for the contact. |
| 5848 | * <P>Type: TEXT</P> |
| 5849 | */ |
| 5850 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5851 | |
| 5852 | /** |
| 5853 | * The phonetic version of the additional name for the contact. |
| 5854 | * <P>Type: TEXT</P> |
| 5855 | */ |
| 5856 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5857 | |
| 5858 | /** |
| 5859 | * The phonetic version of the family name for the contact. |
| 5860 | * <P>Type: TEXT</P> |
| 5861 | */ |
| 5862 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5863 | |
| 5864 | /** |
| 5865 | * The style used for combining given/middle/family name into a full name. |
| 5866 | * See {@link ContactsContract.FullNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5867 | */ |
| 5868 | public static final String FULL_NAME_STYLE = DATA10; |
| 5869 | |
| 5870 | /** |
| 5871 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5872 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5873 | */ |
| 5874 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5875 | } |
| 5876 | |
| 5877 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5878 | * <p>A data kind representing the contact's nickname. For example, for |
| 5879 | * Bob Parr ("Mr. Incredible"): |
| 5880 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5881 | * ArrayList<ContentProviderOperation> ops = |
| 5882 | * new ArrayList<ContentProviderOperation>(); |
| 5883 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5884 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5885 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5886 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5887 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5888 | * .build()); |
| 5889 | * |
| 5890 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5891 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5892 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5893 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5894 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5895 | * .withValue(Nickname.LABEL, "Superhero") |
| 5896 | * .build()); |
| 5897 | * |
| 5898 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5899 | * </pre> |
| 5900 | * </p> |
| 5901 | * <p> |
| 5902 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5903 | * following aliases. |
| 5904 | * </p> |
| 5905 | * |
| 5906 | * <h2>Column aliases</h2> |
| 5907 | * <table class="jd-sumtable"> |
| 5908 | * <tr> |
| 5909 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5910 | * </tr> |
| 5911 | * <tr> |
| 5912 | * <td>String</td> |
| 5913 | * <td>{@link #NAME}</td> |
| 5914 | * <td>{@link #DATA1}</td> |
| 5915 | * <td></td> |
| 5916 | * </tr> |
| 5917 | * <tr> |
| 5918 | * <td>int</td> |
| 5919 | * <td>{@link #TYPE}</td> |
| 5920 | * <td>{@link #DATA2}</td> |
| 5921 | * <td> |
| 5922 | * Allowed values are: |
| 5923 | * <p> |
| 5924 | * <ul> |
| 5925 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5926 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5927 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5928 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5929 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5930 | * <li>{@link #TYPE_INITIALS}</li> |
| 5931 | * </ul> |
| 5932 | * </p> |
| 5933 | * </td> |
| 5934 | * </tr> |
| 5935 | * <tr> |
| 5936 | * <td>String</td> |
| 5937 | * <td>{@link #LABEL}</td> |
| 5938 | * <td>{@link #DATA3}</td> |
| 5939 | * <td></td> |
| 5940 | * </tr> |
| 5941 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5942 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5943 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns, |
| 5944 | ContactCounts{ |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5945 | /** |
| 5946 | * This utility class cannot be instantiated |
| 5947 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5948 | private Nickname() {} |
| 5949 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5950 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5951 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5952 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5953 | public static final int TYPE_DEFAULT = 1; |
| 5954 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5955 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5956 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5957 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5958 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5959 | public static final int TYPE_SHORT_NAME = 4; |
| 5960 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5961 | |
| 5962 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5963 | * The name itself |
| 5964 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5965 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5966 | } |
| 5967 | |
| 5968 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5969 | * <p> |
| 5970 | * A data kind representing a telephone number. |
| 5971 | * </p> |
| 5972 | * <p> |
| 5973 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5974 | * well as the following aliases. |
| 5975 | * </p> |
| 5976 | * <h2>Column aliases</h2> |
| 5977 | * <table class="jd-sumtable"> |
| 5978 | * <tr> |
| 5979 | * <th>Type</th> |
| 5980 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5981 | * </tr> |
| 5982 | * <tr> |
| 5983 | * <td>String</td> |
| 5984 | * <td>{@link #NUMBER}</td> |
| 5985 | * <td>{@link #DATA1}</td> |
| 5986 | * <td></td> |
| 5987 | * </tr> |
| 5988 | * <tr> |
| 5989 | * <td>int</td> |
| 5990 | * <td>{@link #TYPE}</td> |
| 5991 | * <td>{@link #DATA2}</td> |
| 5992 | * <td>Allowed values are: |
| 5993 | * <p> |
| 5994 | * <ul> |
| 5995 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5996 | * <li>{@link #TYPE_HOME}</li> |
| 5997 | * <li>{@link #TYPE_MOBILE}</li> |
| 5998 | * <li>{@link #TYPE_WORK}</li> |
| 5999 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 6000 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 6001 | * <li>{@link #TYPE_PAGER}</li> |
| 6002 | * <li>{@link #TYPE_OTHER}</li> |
| 6003 | * <li>{@link #TYPE_CALLBACK}</li> |
| 6004 | * <li>{@link #TYPE_CAR}</li> |
| 6005 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 6006 | * <li>{@link #TYPE_ISDN}</li> |
| 6007 | * <li>{@link #TYPE_MAIN}</li> |
| 6008 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 6009 | * <li>{@link #TYPE_RADIO}</li> |
| 6010 | * <li>{@link #TYPE_TELEX}</li> |
| 6011 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 6012 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 6013 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 6014 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6015 | * <li>{@link #TYPE_MMS}</li> |
| 6016 | * </ul> |
| 6017 | * </p> |
| 6018 | * </td> |
| 6019 | * </tr> |
| 6020 | * <tr> |
| 6021 | * <td>String</td> |
| 6022 | * <td>{@link #LABEL}</td> |
| 6023 | * <td>{@link #DATA3}</td> |
| 6024 | * <td></td> |
| 6025 | * </tr> |
| 6026 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6027 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6028 | public static final class Phone implements DataColumnsWithJoins, CommonColumns, |
| 6029 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6030 | /** |
| 6031 | * This utility class cannot be instantiated |
| 6032 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6033 | private Phone() {} |
| 6034 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6035 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6036 | 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] | 6037 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6038 | /** |
| 6039 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6040 | * phones. |
| 6041 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6042 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6043 | |
| 6044 | /** |
| 6045 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6046 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 6047 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6048 | */ |
| 6049 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6050 | "phones"); |
| 6051 | |
| 6052 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 6053 | * URI used for getting all contacts from primary and managed profile. |
| 6054 | * |
| 6055 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same |
| 6056 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6057 | * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile |
| 6058 | * linked to the current profile, it will merge corp profile and current profile's |
| 6059 | * results and return |
| 6060 | * |
| 6061 | * @hide |
| 6062 | */ |
| 6063 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 6064 | Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); |
| 6065 | |
| 6066 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6067 | * 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] | 6068 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6069 | * to display names as well as phone numbers. The filter argument should be passed |
| 6070 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6071 | */ |
| 6072 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6073 | "filter"); |
| 6074 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6075 | /** |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 6076 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 6077 | * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6078 | * parameters, otherwise it will throw IllegalArgumentException. |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 6079 | */ |
| 6080 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6081 | CONTENT_URI, "filter_enterprise"); |
| 6082 | |
| 6083 | /** |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6084 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6085 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 6086 | * are not searched. Default is "1". |
| 6087 | */ |
| 6088 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 6089 | |
| 6090 | /** |
| 6091 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6092 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 6093 | * are not searched. Default is "1". |
| 6094 | */ |
| 6095 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 6096 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6097 | public static final int TYPE_HOME = 1; |
| 6098 | public static final int TYPE_MOBILE = 2; |
| 6099 | public static final int TYPE_WORK = 3; |
| 6100 | public static final int TYPE_FAX_WORK = 4; |
| 6101 | public static final int TYPE_FAX_HOME = 5; |
| 6102 | public static final int TYPE_PAGER = 6; |
| 6103 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 6104 | public static final int TYPE_CALLBACK = 8; |
| 6105 | public static final int TYPE_CAR = 9; |
| 6106 | public static final int TYPE_COMPANY_MAIN = 10; |
| 6107 | public static final int TYPE_ISDN = 11; |
| 6108 | public static final int TYPE_MAIN = 12; |
| 6109 | public static final int TYPE_OTHER_FAX = 13; |
| 6110 | public static final int TYPE_RADIO = 14; |
| 6111 | public static final int TYPE_TELEX = 15; |
| 6112 | public static final int TYPE_TTY_TDD = 16; |
| 6113 | public static final int TYPE_WORK_MOBILE = 17; |
| 6114 | public static final int TYPE_WORK_PAGER = 18; |
| 6115 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 6116 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6117 | |
| 6118 | /** |
| 6119 | * The phone number as the user entered it. |
| 6120 | * <P>Type: TEXT</P> |
| 6121 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6122 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6123 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6124 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 6125 | * 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] | 6126 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 6127 | * provider fails to infer.) |
| 6128 | * 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] | 6129 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 6130 | */ |
| 6131 | public static final String NORMALIZED_NUMBER = DATA4; |
| 6132 | |
| 6133 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6134 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6135 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6136 | */ |
| 6137 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6138 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6139 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6140 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6141 | } |
| 6142 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6143 | /** |
| 6144 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6145 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6146 | */ |
| 6147 | @Deprecated |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 6148 | @UnsupportedAppUsage |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6149 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6150 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6151 | return getTypeLabel(context.getResources(), type, label); |
| 6152 | } |
| 6153 | |
| 6154 | /** |
| 6155 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6156 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6157 | */ |
| 6158 | public static final int getTypeLabelResource(int type) { |
| 6159 | switch (type) { |
| 6160 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 6161 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 6162 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 6163 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 6164 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 6165 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 6166 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 6167 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 6168 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 6169 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 6170 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 6171 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 6172 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 6173 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 6174 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 6175 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 6176 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 6177 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 6178 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 6179 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 6180 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 6181 | } |
| 6182 | } |
| 6183 | |
| 6184 | /** |
| 6185 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6186 | * possibly substituting the given {@link #LABEL} value |
| 6187 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6188 | */ |
| 6189 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6190 | CharSequence label) { |
Tingting Wang | 86ac228 | 2015-07-16 21:19:28 +0000 | [diff] [blame] | 6191 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6192 | return label; |
| 6193 | } else { |
| 6194 | final int labelRes = getTypeLabelResource(type); |
| 6195 | return res.getText(labelRes); |
| 6196 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6197 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6198 | } |
| 6199 | |
| 6200 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6201 | * <p> |
| 6202 | * A data kind representing an email address. |
| 6203 | * </p> |
| 6204 | * <p> |
| 6205 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6206 | * well as the following aliases. |
| 6207 | * </p> |
| 6208 | * <h2>Column aliases</h2> |
| 6209 | * <table class="jd-sumtable"> |
| 6210 | * <tr> |
| 6211 | * <th>Type</th> |
| 6212 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6213 | * </tr> |
| 6214 | * <tr> |
| 6215 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 6216 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6217 | * <td>{@link #DATA1}</td> |
| 6218 | * <td>Email address itself.</td> |
| 6219 | * </tr> |
| 6220 | * <tr> |
| 6221 | * <td>int</td> |
| 6222 | * <td>{@link #TYPE}</td> |
| 6223 | * <td>{@link #DATA2}</td> |
| 6224 | * <td>Allowed values are: |
| 6225 | * <p> |
| 6226 | * <ul> |
| 6227 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6228 | * <li>{@link #TYPE_HOME}</li> |
| 6229 | * <li>{@link #TYPE_WORK}</li> |
| 6230 | * <li>{@link #TYPE_OTHER}</li> |
| 6231 | * <li>{@link #TYPE_MOBILE}</li> |
| 6232 | * </ul> |
| 6233 | * </p> |
| 6234 | * </td> |
| 6235 | * </tr> |
| 6236 | * <tr> |
| 6237 | * <td>String</td> |
| 6238 | * <td>{@link #LABEL}</td> |
| 6239 | * <td>{@link #DATA3}</td> |
| 6240 | * <td></td> |
| 6241 | * </tr> |
| 6242 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6243 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6244 | public static final class Email implements DataColumnsWithJoins, CommonColumns, |
| 6245 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6246 | /** |
| 6247 | * This utility class cannot be instantiated |
| 6248 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6249 | private Email() {} |
| 6250 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6251 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6252 | 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] | 6253 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6254 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 6255 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 6256 | */ |
| 6257 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 6258 | |
| 6259 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6260 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6261 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6262 | * associated raw contact and aggregate contact data. |
| 6263 | */ |
| 6264 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6265 | "emails"); |
| 6266 | |
| 6267 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6268 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6269 | * The content:// style URL for looking up data rows by email address. The |
| 6270 | * lookup argument, an email address, should be passed as an additional path segment |
| 6271 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6272 | * </p> |
| 6273 | * <p>Example: |
| 6274 | * <pre> |
| 6275 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 6276 | * Cursor c = getContentResolver().query(uri, |
| 6277 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 6278 | * null, null, null); |
| 6279 | * </pre> |
| 6280 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6281 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6282 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6283 | "lookup"); |
| 6284 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6285 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6286 | * <p>URI used for enterprise email lookup.</p> |
| 6287 | * |
| 6288 | * <p> |
| 6289 | * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same |
| 6290 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6291 | * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a |
| 6292 | * corp profile linked to the current profile, it first queries against the personal contact database, |
| 6293 | * and if no matching contacts are found there, then queries against the |
| 6294 | * corp contacts database. |
| 6295 | * </p> |
| 6296 | * <p> |
| 6297 | * If a result is from the corp profile, it makes the following changes to the data: |
| 6298 | * <ul> |
| 6299 | * <li> |
| 6300 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 6301 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 6302 | * load pictures from them. |
| 6303 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not |
| 6304 | * use them. |
| 6305 | * </li> |
| 6306 | * <li> |
| 6307 | * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether |
| 6308 | * a contact |
| 6309 | * is from the corp profile, use |
| 6310 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6311 | * </li> |
| 6312 | * <li> |
| 6313 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 6314 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 6315 | * <li> |
| 6316 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 6317 | * explicitly say to accept them. |
| 6318 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6319 | * </ul> |
| 6320 | * <p> |
| 6321 | * A contact lookup URL built by |
| 6322 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 6323 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 6324 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 6325 | * corp profile. |
| 6326 | * </p> |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6327 | * |
| 6328 | * <pre> |
| 6329 | * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI, |
| 6330 | * Uri.encode(email)); |
| 6331 | * </pre> |
| 6332 | */ |
| 6333 | public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI = |
| 6334 | Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); |
| 6335 | |
| 6336 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6337 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6338 | * 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] | 6339 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6340 | * to display names as well as email addresses. The filter argument should be passed |
| 6341 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6342 | * </p> |
| 6343 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 6344 | * as well as "Bob Parr (incredible@android.com)". |
| 6345 | * <pre> |
| 6346 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 6347 | * Cursor c = getContentResolver().query(uri, |
| 6348 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 6349 | * null, null, null); |
| 6350 | * </pre> |
| 6351 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6352 | */ |
| 6353 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6354 | "filter"); |
| 6355 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6356 | /** |
Tony Mak | 415369e | 2015-12-08 07:24:55 +0000 | [diff] [blame] | 6357 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 6358 | * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6359 | * parameters, otherwise it will throw IllegalArgumentException. |
Tony Mak | 415369e | 2015-12-08 07:24:55 +0000 | [diff] [blame] | 6360 | */ |
| 6361 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6362 | CONTENT_URI, "filter_enterprise"); |
| 6363 | |
| 6364 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6365 | * The email address. |
| 6366 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6367 | */ |
| 6368 | public static final String ADDRESS = DATA1; |
| 6369 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6370 | public static final int TYPE_HOME = 1; |
| 6371 | public static final int TYPE_WORK = 2; |
| 6372 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 6373 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6374 | |
| 6375 | /** |
| 6376 | * The display name for the email address |
| 6377 | * <P>Type: TEXT</P> |
| 6378 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6379 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6380 | |
| 6381 | /** |
| 6382 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6383 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6384 | */ |
| 6385 | public static final int getTypeLabelResource(int type) { |
| 6386 | switch (type) { |
| 6387 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 6388 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 6389 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 6390 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 6391 | default: return com.android.internal.R.string.emailTypeCustom; |
| 6392 | } |
| 6393 | } |
| 6394 | |
| 6395 | /** |
| 6396 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6397 | * possibly substituting the given {@link #LABEL} value |
| 6398 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6399 | */ |
| 6400 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6401 | CharSequence label) { |
| 6402 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6403 | return label; |
| 6404 | } else { |
| 6405 | final int labelRes = getTypeLabelResource(type); |
| 6406 | return res.getText(labelRes); |
| 6407 | } |
| 6408 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6409 | } |
| 6410 | |
| 6411 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6412 | * <p> |
| 6413 | * A data kind representing a postal addresses. |
| 6414 | * </p> |
| 6415 | * <p> |
| 6416 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6417 | * well as the following aliases. |
| 6418 | * </p> |
| 6419 | * <h2>Column aliases</h2> |
| 6420 | * <table class="jd-sumtable"> |
| 6421 | * <tr> |
| 6422 | * <th>Type</th> |
| 6423 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6424 | * </tr> |
| 6425 | * <tr> |
| 6426 | * <td>String</td> |
| 6427 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 6428 | * <td>{@link #DATA1}</td> |
| 6429 | * <td></td> |
| 6430 | * </tr> |
| 6431 | * <tr> |
| 6432 | * <td>int</td> |
| 6433 | * <td>{@link #TYPE}</td> |
| 6434 | * <td>{@link #DATA2}</td> |
| 6435 | * <td>Allowed values are: |
| 6436 | * <p> |
| 6437 | * <ul> |
| 6438 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6439 | * <li>{@link #TYPE_HOME}</li> |
| 6440 | * <li>{@link #TYPE_WORK}</li> |
| 6441 | * <li>{@link #TYPE_OTHER}</li> |
| 6442 | * </ul> |
| 6443 | * </p> |
| 6444 | * </td> |
| 6445 | * </tr> |
| 6446 | * <tr> |
| 6447 | * <td>String</td> |
| 6448 | * <td>{@link #LABEL}</td> |
| 6449 | * <td>{@link #DATA3}</td> |
| 6450 | * <td></td> |
| 6451 | * </tr> |
| 6452 | * <tr> |
| 6453 | * <td>String</td> |
| 6454 | * <td>{@link #STREET}</td> |
| 6455 | * <td>{@link #DATA4}</td> |
| 6456 | * <td></td> |
| 6457 | * </tr> |
| 6458 | * <tr> |
| 6459 | * <td>String</td> |
| 6460 | * <td>{@link #POBOX}</td> |
| 6461 | * <td>{@link #DATA5}</td> |
| 6462 | * <td>Post Office Box number</td> |
| 6463 | * </tr> |
| 6464 | * <tr> |
| 6465 | * <td>String</td> |
| 6466 | * <td>{@link #NEIGHBORHOOD}</td> |
| 6467 | * <td>{@link #DATA6}</td> |
| 6468 | * <td></td> |
| 6469 | * </tr> |
| 6470 | * <tr> |
| 6471 | * <td>String</td> |
| 6472 | * <td>{@link #CITY}</td> |
| 6473 | * <td>{@link #DATA7}</td> |
| 6474 | * <td></td> |
| 6475 | * </tr> |
| 6476 | * <tr> |
| 6477 | * <td>String</td> |
| 6478 | * <td>{@link #REGION}</td> |
| 6479 | * <td>{@link #DATA8}</td> |
| 6480 | * <td></td> |
| 6481 | * </tr> |
| 6482 | * <tr> |
| 6483 | * <td>String</td> |
| 6484 | * <td>{@link #POSTCODE}</td> |
| 6485 | * <td>{@link #DATA9}</td> |
| 6486 | * <td></td> |
| 6487 | * </tr> |
| 6488 | * <tr> |
| 6489 | * <td>String</td> |
| 6490 | * <td>{@link #COUNTRY}</td> |
| 6491 | * <td>{@link #DATA10}</td> |
| 6492 | * <td></td> |
| 6493 | * </tr> |
| 6494 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6495 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6496 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, |
| 6497 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6498 | /** |
| 6499 | * This utility class cannot be instantiated |
| 6500 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6501 | private StructuredPostal() { |
| 6502 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6503 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6504 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6505 | public static final String CONTENT_ITEM_TYPE = |
| 6506 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6507 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6508 | /** |
| 6509 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6510 | * postal addresses. |
| 6511 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6512 | 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] | 6513 | |
| 6514 | /** |
| 6515 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6516 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6517 | */ |
| 6518 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6519 | "postals"); |
| 6520 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6521 | public static final int TYPE_HOME = 1; |
| 6522 | public static final int TYPE_WORK = 2; |
| 6523 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6524 | |
| 6525 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 6526 | * The full, unstructured postal address. <i>This field must be |
| 6527 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6528 | * <p> |
| 6529 | * Type: TEXT |
| 6530 | */ |
| 6531 | public static final String FORMATTED_ADDRESS = DATA; |
| 6532 | |
| 6533 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6534 | * Can be street, avenue, road, etc. This element also includes the |
| 6535 | * house number and room/apartment/flat/floor number. |
| 6536 | * <p> |
| 6537 | * Type: TEXT |
| 6538 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6539 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6540 | |
| 6541 | /** |
| 6542 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 6543 | * usually but not always mutually exclusive with street. |
| 6544 | * <p> |
| 6545 | * Type: TEXT |
| 6546 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6547 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6548 | |
| 6549 | /** |
| 6550 | * This is used to disambiguate a street address when a city |
| 6551 | * contains more than one street with the same name, or to specify a |
| 6552 | * small place whose mail is routed through a larger postal town. In |
| 6553 | * China it could be a county or a minor city. |
| 6554 | * <p> |
| 6555 | * Type: TEXT |
| 6556 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6557 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6558 | |
| 6559 | /** |
| 6560 | * Can be city, village, town, borough, etc. This is the postal town |
| 6561 | * and not necessarily the place of residence or place of business. |
| 6562 | * <p> |
| 6563 | * Type: TEXT |
| 6564 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6565 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6566 | |
| 6567 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6568 | * A state, province, county (in Ireland), Land (in Germany), |
| 6569 | * departement (in France), etc. |
| 6570 | * <p> |
| 6571 | * Type: TEXT |
| 6572 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6573 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6574 | |
| 6575 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 6576 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6577 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 6578 | * <p> |
| 6579 | * Type: TEXT |
| 6580 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6581 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6582 | |
| 6583 | /** |
| 6584 | * The name or code of the country. |
| 6585 | * <p> |
| 6586 | * Type: TEXT |
| 6587 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6588 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6589 | |
| 6590 | /** |
| 6591 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6592 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6593 | */ |
| 6594 | public static final int getTypeLabelResource(int type) { |
| 6595 | switch (type) { |
| 6596 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 6597 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 6598 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 6599 | default: return com.android.internal.R.string.postalTypeCustom; |
| 6600 | } |
| 6601 | } |
| 6602 | |
| 6603 | /** |
| 6604 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6605 | * possibly substituting the given {@link #LABEL} value |
| 6606 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6607 | */ |
| 6608 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6609 | CharSequence label) { |
| 6610 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6611 | return label; |
| 6612 | } else { |
| 6613 | final int labelRes = getTypeLabelResource(type); |
| 6614 | return res.getText(labelRes); |
| 6615 | } |
| 6616 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6617 | } |
| 6618 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6619 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6620 | * <p> |
| 6621 | * A data kind representing an IM address |
| 6622 | * </p> |
| 6623 | * <p> |
| 6624 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6625 | * well as the following aliases. |
| 6626 | * </p> |
| 6627 | * <h2>Column aliases</h2> |
| 6628 | * <table class="jd-sumtable"> |
| 6629 | * <tr> |
| 6630 | * <th>Type</th> |
| 6631 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6632 | * </tr> |
| 6633 | * <tr> |
| 6634 | * <td>String</td> |
| 6635 | * <td>{@link #DATA}</td> |
| 6636 | * <td>{@link #DATA1}</td> |
| 6637 | * <td></td> |
| 6638 | * </tr> |
| 6639 | * <tr> |
| 6640 | * <td>int</td> |
| 6641 | * <td>{@link #TYPE}</td> |
| 6642 | * <td>{@link #DATA2}</td> |
| 6643 | * <td>Allowed values are: |
| 6644 | * <p> |
| 6645 | * <ul> |
| 6646 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6647 | * <li>{@link #TYPE_HOME}</li> |
| 6648 | * <li>{@link #TYPE_WORK}</li> |
| 6649 | * <li>{@link #TYPE_OTHER}</li> |
| 6650 | * </ul> |
| 6651 | * </p> |
| 6652 | * </td> |
| 6653 | * </tr> |
| 6654 | * <tr> |
| 6655 | * <td>String</td> |
| 6656 | * <td>{@link #LABEL}</td> |
| 6657 | * <td>{@link #DATA3}</td> |
| 6658 | * <td></td> |
| 6659 | * </tr> |
| 6660 | * <tr> |
| 6661 | * <td>String</td> |
| 6662 | * <td>{@link #PROTOCOL}</td> |
| 6663 | * <td>{@link #DATA5}</td> |
| 6664 | * <td> |
| 6665 | * <p> |
| 6666 | * Allowed values: |
| 6667 | * <ul> |
| 6668 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6669 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6670 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6671 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6672 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6673 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6674 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6675 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6676 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6677 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6678 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6679 | * </ul> |
| 6680 | * </p> |
| 6681 | * </td> |
| 6682 | * </tr> |
| 6683 | * <tr> |
| 6684 | * <td>String</td> |
| 6685 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6686 | * <td>{@link #DATA6}</td> |
| 6687 | * <td></td> |
| 6688 | * </tr> |
| 6689 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6690 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6691 | public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6692 | /** |
| 6693 | * This utility class cannot be instantiated |
| 6694 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6695 | private Im() {} |
| 6696 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6697 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6698 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6699 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6700 | public static final int TYPE_HOME = 1; |
| 6701 | public static final int TYPE_WORK = 2; |
| 6702 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6703 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6704 | /** |
| 6705 | * This column should be populated with one of the defined |
| 6706 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6707 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6708 | * should contain the name of the custom protocol. |
| 6709 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6710 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6711 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6712 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6713 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6714 | /* |
| 6715 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6716 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6717 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6718 | public static final int PROTOCOL_AIM = 0; |
| 6719 | public static final int PROTOCOL_MSN = 1; |
| 6720 | public static final int PROTOCOL_YAHOO = 2; |
| 6721 | public static final int PROTOCOL_SKYPE = 3; |
| 6722 | public static final int PROTOCOL_QQ = 4; |
| 6723 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6724 | public static final int PROTOCOL_ICQ = 6; |
| 6725 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6726 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6727 | |
| 6728 | /** |
| 6729 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6730 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6731 | */ |
| 6732 | public static final int getTypeLabelResource(int type) { |
| 6733 | switch (type) { |
| 6734 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6735 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6736 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6737 | default: return com.android.internal.R.string.imTypeCustom; |
| 6738 | } |
| 6739 | } |
| 6740 | |
| 6741 | /** |
| 6742 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6743 | * possibly substituting the given {@link #LABEL} value |
| 6744 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6745 | */ |
| 6746 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6747 | CharSequence label) { |
| 6748 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6749 | return label; |
| 6750 | } else { |
| 6751 | final int labelRes = getTypeLabelResource(type); |
| 6752 | return res.getText(labelRes); |
| 6753 | } |
| 6754 | } |
| 6755 | |
| 6756 | /** |
| 6757 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6758 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6759 | */ |
| 6760 | public static final int getProtocolLabelResource(int type) { |
| 6761 | switch (type) { |
| 6762 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6763 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6764 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6765 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6766 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6767 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6768 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6769 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6770 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6771 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6772 | } |
| 6773 | } |
| 6774 | |
| 6775 | /** |
| 6776 | * Return a {@link CharSequence} that best describes the given |
| 6777 | * protocol, possibly substituting the given |
| 6778 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6779 | */ |
| 6780 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6781 | CharSequence label) { |
| 6782 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6783 | return label; |
| 6784 | } else { |
| 6785 | final int labelRes = getProtocolLabelResource(type); |
| 6786 | return res.getText(labelRes); |
| 6787 | } |
| 6788 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6789 | } |
| 6790 | |
| 6791 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6792 | * <p> |
| 6793 | * A data kind representing an organization. |
| 6794 | * </p> |
| 6795 | * <p> |
| 6796 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6797 | * well as the following aliases. |
| 6798 | * </p> |
| 6799 | * <h2>Column aliases</h2> |
| 6800 | * <table class="jd-sumtable"> |
| 6801 | * <tr> |
| 6802 | * <th>Type</th> |
| 6803 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6804 | * </tr> |
| 6805 | * <tr> |
| 6806 | * <td>String</td> |
| 6807 | * <td>{@link #COMPANY}</td> |
| 6808 | * <td>{@link #DATA1}</td> |
| 6809 | * <td></td> |
| 6810 | * </tr> |
| 6811 | * <tr> |
| 6812 | * <td>int</td> |
| 6813 | * <td>{@link #TYPE}</td> |
| 6814 | * <td>{@link #DATA2}</td> |
| 6815 | * <td>Allowed values are: |
| 6816 | * <p> |
| 6817 | * <ul> |
| 6818 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6819 | * <li>{@link #TYPE_WORK}</li> |
| 6820 | * <li>{@link #TYPE_OTHER}</li> |
| 6821 | * </ul> |
| 6822 | * </p> |
| 6823 | * </td> |
| 6824 | * </tr> |
| 6825 | * <tr> |
| 6826 | * <td>String</td> |
| 6827 | * <td>{@link #LABEL}</td> |
| 6828 | * <td>{@link #DATA3}</td> |
| 6829 | * <td></td> |
| 6830 | * </tr> |
| 6831 | * <tr> |
| 6832 | * <td>String</td> |
| 6833 | * <td>{@link #TITLE}</td> |
| 6834 | * <td>{@link #DATA4}</td> |
| 6835 | * <td></td> |
| 6836 | * </tr> |
| 6837 | * <tr> |
| 6838 | * <td>String</td> |
| 6839 | * <td>{@link #DEPARTMENT}</td> |
| 6840 | * <td>{@link #DATA5}</td> |
| 6841 | * <td></td> |
| 6842 | * </tr> |
| 6843 | * <tr> |
| 6844 | * <td>String</td> |
| 6845 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6846 | * <td>{@link #DATA6}</td> |
| 6847 | * <td></td> |
| 6848 | * </tr> |
| 6849 | * <tr> |
| 6850 | * <td>String</td> |
| 6851 | * <td>{@link #SYMBOL}</td> |
| 6852 | * <td>{@link #DATA7}</td> |
| 6853 | * <td></td> |
| 6854 | * </tr> |
| 6855 | * <tr> |
| 6856 | * <td>String</td> |
| 6857 | * <td>{@link #PHONETIC_NAME}</td> |
| 6858 | * <td>{@link #DATA8}</td> |
| 6859 | * <td></td> |
| 6860 | * </tr> |
| 6861 | * <tr> |
| 6862 | * <td>String</td> |
| 6863 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6864 | * <td>{@link #DATA9}</td> |
| 6865 | * <td></td> |
| 6866 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6867 | * <tr> |
| 6868 | * <td>String</td> |
| 6869 | * <td>PHONETIC_NAME_STYLE</td> |
| 6870 | * <td>{@link #DATA10}</td> |
| 6871 | * <td></td> |
| 6872 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6873 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6874 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6875 | public static final class Organization implements DataColumnsWithJoins, CommonColumns, |
| 6876 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6877 | /** |
| 6878 | * This utility class cannot be instantiated |
| 6879 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6880 | private Organization() {} |
| 6881 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6882 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6883 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6884 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6885 | public static final int TYPE_WORK = 1; |
| 6886 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6887 | |
| 6888 | /** |
| 6889 | * The company as the user entered it. |
| 6890 | * <P>Type: TEXT</P> |
| 6891 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6892 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6893 | |
| 6894 | /** |
| 6895 | * The position title at this company as the user entered it. |
| 6896 | * <P>Type: TEXT</P> |
| 6897 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6898 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6899 | |
| 6900 | /** |
| 6901 | * The department at this company as the user entered it. |
| 6902 | * <P>Type: TEXT</P> |
| 6903 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6904 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6905 | |
| 6906 | /** |
| 6907 | * The job description at this company as the user entered it. |
| 6908 | * <P>Type: TEXT</P> |
| 6909 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6910 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6911 | |
| 6912 | /** |
| 6913 | * The symbol of this company as the user entered it. |
| 6914 | * <P>Type: TEXT</P> |
| 6915 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6916 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6917 | |
| 6918 | /** |
| 6919 | * The phonetic name of this company as the user entered it. |
| 6920 | * <P>Type: TEXT</P> |
| 6921 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6922 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6923 | |
| 6924 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6925 | * The office location of this organization. |
| 6926 | * <P>Type: TEXT</P> |
| 6927 | */ |
| 6928 | public static final String OFFICE_LOCATION = DATA9; |
| 6929 | |
| 6930 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6931 | * The alphabet used for capturing the phonetic name. |
| 6932 | * See {@link ContactsContract.PhoneticNameStyle}. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6933 | */ |
| 6934 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6935 | |
| 6936 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6937 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6938 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6939 | */ |
| 6940 | public static final int getTypeLabelResource(int type) { |
| 6941 | switch (type) { |
| 6942 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6943 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6944 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6945 | } |
| 6946 | } |
| 6947 | |
| 6948 | /** |
| 6949 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6950 | * possibly substituting the given {@link #LABEL} value |
| 6951 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6952 | */ |
| 6953 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6954 | CharSequence label) { |
| 6955 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6956 | return label; |
| 6957 | } else { |
| 6958 | final int labelRes = getTypeLabelResource(type); |
| 6959 | return res.getText(labelRes); |
| 6960 | } |
| 6961 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6962 | } |
| 6963 | |
| 6964 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6965 | * <p> |
| 6966 | * A data kind representing a relation. |
| 6967 | * </p> |
| 6968 | * <p> |
| 6969 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6970 | * well as the following aliases. |
| 6971 | * </p> |
| 6972 | * <h2>Column aliases</h2> |
| 6973 | * <table class="jd-sumtable"> |
| 6974 | * <tr> |
| 6975 | * <th>Type</th> |
| 6976 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6977 | * </tr> |
| 6978 | * <tr> |
| 6979 | * <td>String</td> |
| 6980 | * <td>{@link #NAME}</td> |
| 6981 | * <td>{@link #DATA1}</td> |
| 6982 | * <td></td> |
| 6983 | * </tr> |
| 6984 | * <tr> |
| 6985 | * <td>int</td> |
| 6986 | * <td>{@link #TYPE}</td> |
| 6987 | * <td>{@link #DATA2}</td> |
| 6988 | * <td>Allowed values are: |
| 6989 | * <p> |
| 6990 | * <ul> |
| 6991 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6992 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6993 | * <li>{@link #TYPE_BROTHER}</li> |
| 6994 | * <li>{@link #TYPE_CHILD}</li> |
| 6995 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 6996 | * <li>{@link #TYPE_FATHER}</li> |
| 6997 | * <li>{@link #TYPE_FRIEND}</li> |
| 6998 | * <li>{@link #TYPE_MANAGER}</li> |
| 6999 | * <li>{@link #TYPE_MOTHER}</li> |
| 7000 | * <li>{@link #TYPE_PARENT}</li> |
| 7001 | * <li>{@link #TYPE_PARTNER}</li> |
| 7002 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 7003 | * <li>{@link #TYPE_RELATIVE}</li> |
| 7004 | * <li>{@link #TYPE_SISTER}</li> |
| 7005 | * <li>{@link #TYPE_SPOUSE}</li> |
| 7006 | * </ul> |
| 7007 | * </p> |
| 7008 | * </td> |
| 7009 | * </tr> |
| 7010 | * <tr> |
| 7011 | * <td>String</td> |
| 7012 | * <td>{@link #LABEL}</td> |
| 7013 | * <td>{@link #DATA3}</td> |
| 7014 | * <td></td> |
| 7015 | * </tr> |
| 7016 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7017 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7018 | public static final class Relation implements DataColumnsWithJoins, CommonColumns, |
| 7019 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7020 | /** |
| 7021 | * This utility class cannot be instantiated |
| 7022 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7023 | private Relation() {} |
| 7024 | |
| 7025 | /** MIME type used when storing this in data table. */ |
| 7026 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 7027 | |
| 7028 | public static final int TYPE_ASSISTANT = 1; |
| 7029 | public static final int TYPE_BROTHER = 2; |
| 7030 | public static final int TYPE_CHILD = 3; |
| 7031 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 7032 | public static final int TYPE_FATHER = 5; |
| 7033 | public static final int TYPE_FRIEND = 6; |
| 7034 | public static final int TYPE_MANAGER = 7; |
| 7035 | public static final int TYPE_MOTHER = 8; |
| 7036 | public static final int TYPE_PARENT = 9; |
| 7037 | public static final int TYPE_PARTNER = 10; |
| 7038 | public static final int TYPE_REFERRED_BY = 11; |
| 7039 | public static final int TYPE_RELATIVE = 12; |
| 7040 | public static final int TYPE_SISTER = 13; |
| 7041 | public static final int TYPE_SPOUSE = 14; |
| 7042 | |
| 7043 | /** |
| 7044 | * The name of the relative as the user entered it. |
| 7045 | * <P>Type: TEXT</P> |
| 7046 | */ |
| 7047 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 7048 | |
| 7049 | /** |
| 7050 | * Return the string resource that best describes the given |
| 7051 | * {@link #TYPE}. Will always return a valid resource. |
| 7052 | */ |
| 7053 | public static final int getTypeLabelResource(int type) { |
| 7054 | switch (type) { |
| 7055 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 7056 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 7057 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 7058 | case TYPE_DOMESTIC_PARTNER: |
| 7059 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 7060 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 7061 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 7062 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 7063 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 7064 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 7065 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 7066 | case TYPE_REFERRED_BY: |
| 7067 | return com.android.internal.R.string.relationTypeReferredBy; |
| 7068 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 7069 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 7070 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 7071 | default: return com.android.internal.R.string.orgTypeCustom; |
| 7072 | } |
| 7073 | } |
| 7074 | |
| 7075 | /** |
| 7076 | * Return a {@link CharSequence} that best describes the given type, |
| 7077 | * possibly substituting the given {@link #LABEL} value |
| 7078 | * for {@link #TYPE_CUSTOM}. |
| 7079 | */ |
| 7080 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7081 | CharSequence label) { |
| 7082 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7083 | return label; |
| 7084 | } else { |
| 7085 | final int labelRes = getTypeLabelResource(type); |
| 7086 | return res.getText(labelRes); |
| 7087 | } |
| 7088 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7089 | } |
| 7090 | |
| 7091 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7092 | * <p> |
| 7093 | * A data kind representing an event. |
| 7094 | * </p> |
| 7095 | * <p> |
| 7096 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7097 | * well as the following aliases. |
| 7098 | * </p> |
| 7099 | * <h2>Column aliases</h2> |
| 7100 | * <table class="jd-sumtable"> |
| 7101 | * <tr> |
| 7102 | * <th>Type</th> |
| 7103 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7104 | * </tr> |
| 7105 | * <tr> |
| 7106 | * <td>String</td> |
| 7107 | * <td>{@link #START_DATE}</td> |
| 7108 | * <td>{@link #DATA1}</td> |
| 7109 | * <td></td> |
| 7110 | * </tr> |
| 7111 | * <tr> |
| 7112 | * <td>int</td> |
| 7113 | * <td>{@link #TYPE}</td> |
| 7114 | * <td>{@link #DATA2}</td> |
| 7115 | * <td>Allowed values are: |
| 7116 | * <p> |
| 7117 | * <ul> |
| 7118 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7119 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 7120 | * <li>{@link #TYPE_OTHER}</li> |
| 7121 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 7122 | * </ul> |
| 7123 | * </p> |
| 7124 | * </td> |
| 7125 | * </tr> |
| 7126 | * <tr> |
| 7127 | * <td>String</td> |
| 7128 | * <td>{@link #LABEL}</td> |
| 7129 | * <td>{@link #DATA3}</td> |
| 7130 | * <td></td> |
| 7131 | * </tr> |
| 7132 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7133 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7134 | public static final class Event implements DataColumnsWithJoins, CommonColumns, |
| 7135 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7136 | /** |
| 7137 | * This utility class cannot be instantiated |
| 7138 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7139 | private Event() {} |
| 7140 | |
| 7141 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7142 | 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] | 7143 | |
| 7144 | public static final int TYPE_ANNIVERSARY = 1; |
| 7145 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7146 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 7147 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7148 | /** |
| 7149 | * The event start date as the user entered it. |
| 7150 | * <P>Type: TEXT</P> |
| 7151 | */ |
| 7152 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7153 | |
| 7154 | /** |
| 7155 | * Return the string resource that best describes the given |
| 7156 | * {@link #TYPE}. Will always return a valid resource. |
| 7157 | */ |
| 7158 | public static int getTypeResource(Integer type) { |
| 7159 | if (type == null) { |
| 7160 | return com.android.internal.R.string.eventTypeOther; |
| 7161 | } |
| 7162 | switch (type) { |
| 7163 | case TYPE_ANNIVERSARY: |
| 7164 | return com.android.internal.R.string.eventTypeAnniversary; |
| 7165 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 7166 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 7167 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7168 | } |
| 7169 | } |
Paul Soulos | 6b2dd63 | 2014-07-24 17:17:42 -0700 | [diff] [blame] | 7170 | |
| 7171 | /** |
| 7172 | * Return a {@link CharSequence} that best describes the given type, |
| 7173 | * possibly substituting the given {@link #LABEL} value |
| 7174 | * for {@link #TYPE_CUSTOM}. |
| 7175 | */ |
| 7176 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7177 | CharSequence label) { |
| 7178 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7179 | return label; |
| 7180 | } else { |
| 7181 | final int labelRes = getTypeResource(type); |
| 7182 | return res.getText(labelRes); |
| 7183 | } |
| 7184 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7185 | } |
| 7186 | |
| 7187 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7188 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7189 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7190 | * </p> |
| 7191 | * <p> |
| 7192 | * Some sync adapters will choose to download photos in a separate |
| 7193 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 7194 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 7195 | * data, e.g. the image URL or ID, state of download, server-side version |
| 7196 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 7197 | * </p> |
| 7198 | * <p> |
| 7199 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7200 | * well as the following aliases. |
| 7201 | * </p> |
| 7202 | * <h2>Column aliases</h2> |
| 7203 | * <table class="jd-sumtable"> |
| 7204 | * <tr> |
| 7205 | * <th>Type</th> |
| 7206 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7207 | * </tr> |
| 7208 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7209 | * <td>NUMBER</td> |
| 7210 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 7211 | * <td>{@link #DATA14}</td> |
| 7212 | * <td>ID of the hi-res photo file.</td> |
| 7213 | * </tr> |
| 7214 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7215 | * <td>BLOB</td> |
| 7216 | * <td>{@link #PHOTO}</td> |
| 7217 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7218 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 7219 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7220 | * </tr> |
| 7221 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7222 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7223 | public static final class Photo implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7224 | /** |
| 7225 | * This utility class cannot be instantiated |
| 7226 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7227 | private Photo() {} |
| 7228 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7229 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7230 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 7231 | |
| 7232 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7233 | * Photo file ID for the display photo of the raw contact. |
| 7234 | * See {@link ContactsContract.DisplayPhoto}. |
| 7235 | * <p> |
| 7236 | * Type: NUMBER |
| 7237 | */ |
| 7238 | public static final String PHOTO_FILE_ID = DATA14; |
| 7239 | |
| 7240 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 7241 | * 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] | 7242 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7243 | * <p> |
| 7244 | * Type: BLOB |
| 7245 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7246 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7247 | } |
| 7248 | |
| 7249 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7250 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7251 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7252 | * </p> |
| 7253 | * <p> |
| 7254 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7255 | * well as the following aliases. |
| 7256 | * </p> |
| 7257 | * <h2>Column aliases</h2> |
| 7258 | * <table class="jd-sumtable"> |
| 7259 | * <tr> |
| 7260 | * <th>Type</th> |
| 7261 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7262 | * </tr> |
| 7263 | * <tr> |
| 7264 | * <td>String</td> |
| 7265 | * <td>{@link #NOTE}</td> |
| 7266 | * <td>{@link #DATA1}</td> |
| 7267 | * <td></td> |
| 7268 | * </tr> |
| 7269 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7270 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7271 | public static final class Note implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7272 | /** |
| 7273 | * This utility class cannot be instantiated |
| 7274 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7275 | private Note() {} |
| 7276 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7277 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7278 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 7279 | |
| 7280 | /** |
| 7281 | * The note text. |
| 7282 | * <P>Type: TEXT</P> |
| 7283 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7284 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7285 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 7286 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 7287 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7288 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7289 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7290 | * </p> |
| 7291 | * <p> |
| 7292 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7293 | * well as the following aliases. |
| 7294 | * </p> |
| 7295 | * <h2>Column aliases</h2> |
| 7296 | * <table class="jd-sumtable"> |
| 7297 | * <tr> |
| 7298 | * <th>Type</th> |
| 7299 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7300 | * </tr> |
| 7301 | * <tr> |
| 7302 | * <td>long</td> |
| 7303 | * <td>{@link #GROUP_ROW_ID}</td> |
| 7304 | * <td>{@link #DATA1}</td> |
| 7305 | * <td></td> |
| 7306 | * </tr> |
| 7307 | * <tr> |
| 7308 | * <td>String</td> |
| 7309 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 7310 | * <td>none</td> |
| 7311 | * <td> |
| 7312 | * <p> |
| 7313 | * The sourceid of the group that this group membership refers to. |
| 7314 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 7315 | * inserting a row. |
| 7316 | * </p> |
| 7317 | * <p> |
| 7318 | * If this field is specified, the provider will first try to |
| 7319 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 7320 | * is found, it will use the corresponding row id. If the group is not |
| 7321 | * found, it will create one. |
| 7322 | * </td> |
| 7323 | * </tr> |
| 7324 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7325 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7326 | public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7327 | /** |
| 7328 | * This utility class cannot be instantiated |
| 7329 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7330 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7331 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7332 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7333 | public static final String CONTENT_ITEM_TYPE = |
| 7334 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7335 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7336 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7337 | * The row id of the group that this group membership refers to. Exactly one of |
| 7338 | * 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] | 7339 | * <P>Type: INTEGER</P> |
| 7340 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7341 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7342 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7343 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7344 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 7345 | * 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] | 7346 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7347 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7348 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7349 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7350 | |
| 7351 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7352 | * <p> |
| 7353 | * A data kind representing a website related to the contact. |
| 7354 | * </p> |
| 7355 | * <p> |
| 7356 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7357 | * well as the following aliases. |
| 7358 | * </p> |
| 7359 | * <h2>Column aliases</h2> |
| 7360 | * <table class="jd-sumtable"> |
| 7361 | * <tr> |
| 7362 | * <th>Type</th> |
| 7363 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7364 | * </tr> |
| 7365 | * <tr> |
| 7366 | * <td>String</td> |
| 7367 | * <td>{@link #URL}</td> |
| 7368 | * <td>{@link #DATA1}</td> |
| 7369 | * <td></td> |
| 7370 | * </tr> |
| 7371 | * <tr> |
| 7372 | * <td>int</td> |
| 7373 | * <td>{@link #TYPE}</td> |
| 7374 | * <td>{@link #DATA2}</td> |
| 7375 | * <td>Allowed values are: |
| 7376 | * <p> |
| 7377 | * <ul> |
| 7378 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7379 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 7380 | * <li>{@link #TYPE_BLOG}</li> |
| 7381 | * <li>{@link #TYPE_PROFILE}</li> |
| 7382 | * <li>{@link #TYPE_HOME}</li> |
| 7383 | * <li>{@link #TYPE_WORK}</li> |
| 7384 | * <li>{@link #TYPE_FTP}</li> |
| 7385 | * <li>{@link #TYPE_OTHER}</li> |
| 7386 | * </ul> |
| 7387 | * </p> |
| 7388 | * </td> |
| 7389 | * </tr> |
| 7390 | * <tr> |
| 7391 | * <td>String</td> |
| 7392 | * <td>{@link #LABEL}</td> |
| 7393 | * <td>{@link #DATA3}</td> |
| 7394 | * <td></td> |
| 7395 | * </tr> |
| 7396 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7397 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7398 | public static final class Website implements DataColumnsWithJoins, CommonColumns, |
| 7399 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7400 | /** |
| 7401 | * This utility class cannot be instantiated |
| 7402 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7403 | private Website() {} |
| 7404 | |
| 7405 | /** MIME type used when storing this in data table. */ |
| 7406 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 7407 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7408 | public static final int TYPE_HOMEPAGE = 1; |
| 7409 | public static final int TYPE_BLOG = 2; |
| 7410 | public static final int TYPE_PROFILE = 3; |
| 7411 | public static final int TYPE_HOME = 4; |
| 7412 | public static final int TYPE_WORK = 5; |
| 7413 | public static final int TYPE_FTP = 6; |
| 7414 | public static final int TYPE_OTHER = 7; |
| 7415 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7416 | /** |
| 7417 | * The website URL string. |
| 7418 | * <P>Type: TEXT</P> |
| 7419 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7420 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7421 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7422 | |
| 7423 | /** |
| 7424 | * <p> |
| 7425 | * A data kind representing a SIP address for the contact. |
| 7426 | * </p> |
| 7427 | * <p> |
| 7428 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7429 | * well as the following aliases. |
| 7430 | * </p> |
| 7431 | * <h2>Column aliases</h2> |
| 7432 | * <table class="jd-sumtable"> |
| 7433 | * <tr> |
| 7434 | * <th>Type</th> |
| 7435 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7436 | * </tr> |
| 7437 | * <tr> |
| 7438 | * <td>String</td> |
| 7439 | * <td>{@link #SIP_ADDRESS}</td> |
| 7440 | * <td>{@link #DATA1}</td> |
| 7441 | * <td></td> |
| 7442 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7443 | * <tr> |
| 7444 | * <td>int</td> |
| 7445 | * <td>{@link #TYPE}</td> |
| 7446 | * <td>{@link #DATA2}</td> |
| 7447 | * <td>Allowed values are: |
| 7448 | * <p> |
| 7449 | * <ul> |
| 7450 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7451 | * <li>{@link #TYPE_HOME}</li> |
| 7452 | * <li>{@link #TYPE_WORK}</li> |
| 7453 | * <li>{@link #TYPE_OTHER}</li> |
| 7454 | * </ul> |
| 7455 | * </p> |
| 7456 | * </td> |
| 7457 | * </tr> |
| 7458 | * <tr> |
| 7459 | * <td>String</td> |
| 7460 | * <td>{@link #LABEL}</td> |
| 7461 | * <td>{@link #DATA3}</td> |
| 7462 | * <td></td> |
| 7463 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7464 | * </table> |
| 7465 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7466 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, |
| 7467 | ContactCounts { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7468 | /** |
| 7469 | * This utility class cannot be instantiated |
| 7470 | */ |
| 7471 | private SipAddress() {} |
| 7472 | |
| 7473 | /** MIME type used when storing this in data table. */ |
| 7474 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 7475 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7476 | public static final int TYPE_HOME = 1; |
| 7477 | public static final int TYPE_WORK = 2; |
| 7478 | public static final int TYPE_OTHER = 3; |
| 7479 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7480 | /** |
| 7481 | * The SIP address. |
| 7482 | * <P>Type: TEXT</P> |
| 7483 | */ |
| 7484 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7485 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 7486 | |
| 7487 | /** |
| 7488 | * Return the string resource that best describes the given |
| 7489 | * {@link #TYPE}. Will always return a valid resource. |
| 7490 | */ |
| 7491 | public static final int getTypeLabelResource(int type) { |
| 7492 | switch (type) { |
| 7493 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 7494 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 7495 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 7496 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 7497 | } |
| 7498 | } |
| 7499 | |
| 7500 | /** |
| 7501 | * Return a {@link CharSequence} that best describes the given type, |
| 7502 | * possibly substituting the given {@link #LABEL} value |
| 7503 | * for {@link #TYPE_CUSTOM}. |
| 7504 | */ |
| 7505 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7506 | CharSequence label) { |
| 7507 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7508 | return label; |
| 7509 | } else { |
| 7510 | final int labelRes = getTypeLabelResource(type); |
| 7511 | return res.getText(labelRes); |
| 7512 | } |
| 7513 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7514 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7515 | |
| 7516 | /** |
| 7517 | * A data kind representing an Identity related to the contact. |
| 7518 | * <p> |
| 7519 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 7520 | * contacts, e.g. if two contacts have Identity rows with |
| 7521 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 7522 | * to the same person. |
| 7523 | * </p> |
| 7524 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7525 | public static final class Identity implements DataColumnsWithJoins, ContactCounts { |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7526 | /** |
| 7527 | * This utility class cannot be instantiated |
| 7528 | */ |
| 7529 | private Identity() {} |
| 7530 | |
| 7531 | /** MIME type used when storing this in data table. */ |
| 7532 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 7533 | |
| 7534 | /** |
| 7535 | * The identity string. |
| 7536 | * <P>Type: TEXT</P> |
| 7537 | */ |
| 7538 | public static final String IDENTITY = DataColumns.DATA1; |
| 7539 | |
| 7540 | /** |
| 7541 | * The namespace of the identity string, e.g. "com.google" |
| 7542 | * <P>Type: TEXT</P> |
| 7543 | */ |
| 7544 | public static final String NAMESPACE = DataColumns.DATA2; |
| 7545 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7546 | |
| 7547 | /** |
| 7548 | * <p> |
| 7549 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 7550 | * kind. |
| 7551 | * </p> |
| 7552 | * <p> |
| 7553 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 7554 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 7555 | * current examples for "callable", but may be expanded to the other types. |
| 7556 | * </p> |
| 7557 | * <p> |
| 7558 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 7559 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 7560 | * {@link SipAddress}'s. |
| 7561 | * </p> |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7562 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7563 | public static final class Callable implements DataColumnsWithJoins, CommonColumns, |
| 7564 | ContactCounts { |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7565 | /** |
| 7566 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 7567 | * phone numbers. |
| 7568 | */ |
| 7569 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7570 | "callables"); |
| 7571 | /** |
| 7572 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 7573 | * data. |
| 7574 | */ |
| 7575 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 7576 | "filter"); |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7577 | |
| 7578 | /** |
| 7579 | * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter |
| 7580 | * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 7581 | * parameters, otherwise it will throw IllegalArgumentException. |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7582 | */ |
| 7583 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7584 | CONTENT_URI, "filter_enterprise"); |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7585 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7586 | |
| 7587 | /** |
| 7588 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 7589 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 7590 | * is NOT a separate data kind. |
| 7591 | * |
| 7592 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 7593 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 7594 | * are the current data types in this category. |
| 7595 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7596 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns, |
| 7597 | ContactCounts { |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7598 | /** |
| 7599 | * The content:// style URI for these data items, which requests a directory of data |
| 7600 | * rows matching the selection criteria. |
| 7601 | */ |
| 7602 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7603 | "contactables"); |
| 7604 | |
| 7605 | /** |
| 7606 | * The content:// style URI for these data items, which allows for a query parameter to |
| 7607 | * be appended onto the end to filter for data items matching the query. |
| 7608 | */ |
| 7609 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7610 | Contactables.CONTENT_URI, "filter"); |
| 7611 | |
| 7612 | /** |
| 7613 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 7614 | * This specifies whether or not the returned data items should be filtered to show |
| 7615 | * data items belonging to visible contacts only. |
| 7616 | */ |
| 7617 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 7618 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7619 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7620 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7621 | /** |
| 7622 | * @see Groups |
| 7623 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 7624 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7625 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7626 | * The data set within the account that this group belongs to. This allows |
| 7627 | * multiple sync adapters for the same account type to distinguish between |
| 7628 | * each others' group data. |
| 7629 | * |
| 7630 | * This is empty by default, and is completely optional. It only needs to |
| 7631 | * be populated if multiple sync adapters are entering distinct group data |
| 7632 | * for the same account type and account name. |
| 7633 | * <P>Type: TEXT</P> |
| 7634 | */ |
| 7635 | public static final String DATA_SET = "data_set"; |
| 7636 | |
| 7637 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 7638 | * A concatenation of the account type and data set (delimited by a forward |
| 7639 | * slash) - if the data set is empty, this will be the same as the account |
| 7640 | * type. For applications that need to be aware of the data set, this can |
| 7641 | * be used instead of account type to distinguish sets of data. This is |
| 7642 | * never intended to be used for specifying accounts. |
| 7643 | * @hide |
| 7644 | */ |
| 7645 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 7646 | |
| 7647 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7648 | * The display title of this group. |
| 7649 | * <p> |
| 7650 | * Type: TEXT |
| 7651 | */ |
| 7652 | public static final String TITLE = "title"; |
| 7653 | |
| 7654 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7655 | * The package name to use when creating {@link Resources} objects for |
| 7656 | * this group. This value is only designed for use when building user |
| 7657 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7658 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7659 | public static final String RES_PACKAGE = "res_package"; |
| 7660 | |
| 7661 | /** |
| 7662 | * The display title of this group to load as a resource from |
| 7663 | * {@link #RES_PACKAGE}, which may be localized. |
| 7664 | * <P>Type: TEXT</P> |
| 7665 | */ |
| 7666 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7667 | |
| 7668 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7669 | * Notes about the group. |
| 7670 | * <p> |
| 7671 | * Type: TEXT |
| 7672 | */ |
| 7673 | public static final String NOTES = "notes"; |
| 7674 | |
| 7675 | /** |
| 7676 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7677 | * to the sync adapter, null otherwise. |
| 7678 | * <P>Type: TEXT</P> |
| 7679 | */ |
| 7680 | public static final String SYSTEM_ID = "system_id"; |
| 7681 | |
| 7682 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7683 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7684 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7685 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7686 | * <p> |
| 7687 | * Type: INTEGER |
| 7688 | */ |
| 7689 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7690 | |
| 7691 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7692 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7693 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7694 | * |
| 7695 | * @hide |
| 7696 | */ |
| 7697 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7698 | "return_group_count_per_account"; |
| 7699 | |
| 7700 | /** |
| 7701 | * The total number of groups of the account that a group belongs to. |
| 7702 | * This column is available only when the parameter |
| 7703 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7704 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7705 | * |
| 7706 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7707 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7708 | * "group3" returns "1" for this column. |
| 7709 | * |
| 7710 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7711 | * |
| 7712 | * Type: INTEGER |
| 7713 | * @hide |
| 7714 | */ |
| 7715 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7716 | |
| 7717 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7718 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7719 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7720 | * Read-only value that is only present when querying |
| 7721 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7722 | * <p> |
| 7723 | * Type: INTEGER |
| 7724 | */ |
| 7725 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7726 | |
| 7727 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7728 | * Flag indicating if the contacts belonging to this group should be |
| 7729 | * visible in any user interface. |
| 7730 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7731 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7732 | */ |
| 7733 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7734 | |
| 7735 | /** |
| 7736 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7737 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7738 | * called on a group, it is marked for deletion. The sync adaptor |
| 7739 | * deletes the group on the server and then calls ContactResolver.delete |
| 7740 | * once more, this time setting the the |
| 7741 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7742 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7743 | * <P>Type: INTEGER</P> |
| 7744 | */ |
| 7745 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7746 | |
| 7747 | /** |
| 7748 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7749 | * is false for this group's account. |
| 7750 | * <p> |
| 7751 | * Type: INTEGER (boolean) |
| 7752 | */ |
| 7753 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7754 | |
| 7755 | /** |
| 7756 | * Any newly created contacts will automatically be added to groups that have this |
| 7757 | * flag set to true. |
| 7758 | * <p> |
| 7759 | * Type: INTEGER (boolean) |
| 7760 | */ |
| 7761 | public static final String AUTO_ADD = "auto_add"; |
| 7762 | |
| 7763 | /** |
| 7764 | * When a contacts is marked as a favorites it will be automatically added |
| 7765 | * to the groups that have this flag set, and when it is removed from favorites |
| 7766 | * it will be removed from these groups. |
| 7767 | * <p> |
| 7768 | * Type: INTEGER (boolean) |
| 7769 | */ |
| 7770 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7771 | |
| 7772 | /** |
| 7773 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7774 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7775 | * <P>Type: INTEGER</P> |
| 7776 | */ |
| 7777 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7778 | } |
| 7779 | |
| 7780 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7781 | * Constants for the groups table. Only per-account groups are supported. |
| 7782 | * <h2>Columns</h2> |
| 7783 | * <table class="jd-sumtable"> |
| 7784 | * <tr> |
| 7785 | * <th colspan='4'>Groups</th> |
| 7786 | * </tr> |
| 7787 | * <tr> |
| 7788 | * <td>long</td> |
| 7789 | * <td>{@link #_ID}</td> |
| 7790 | * <td>read-only</td> |
| 7791 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7792 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7793 | * group. A sync adapter should always do an update instead.</td> |
| 7794 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7795 | # <tr> |
| 7796 | * <td>String</td> |
| 7797 | * <td>{@link #DATA_SET}</td> |
| 7798 | * <td>read/write-once</td> |
| 7799 | * <td> |
| 7800 | * <p> |
| 7801 | * The data set within the account that this group belongs to. This allows |
| 7802 | * multiple sync adapters for the same account type to distinguish between |
| 7803 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7804 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7805 | * that is associated with a single sync adapter. |
| 7806 | * </p> |
| 7807 | * <p> |
| 7808 | * This is empty by default, and is completely optional. It only needs to |
| 7809 | * be populated if multiple sync adapters are entering distinct data for |
| 7810 | * the same account type and account name. |
| 7811 | * </p> |
| 7812 | * <p> |
| 7813 | * It should be set at the time the group is inserted and never changed |
| 7814 | * afterwards. |
| 7815 | * </p> |
| 7816 | * </td> |
| 7817 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7818 | * <tr> |
| 7819 | * <td>String</td> |
| 7820 | * <td>{@link #TITLE}</td> |
| 7821 | * <td>read/write</td> |
| 7822 | * <td>The display title of this group.</td> |
| 7823 | * </tr> |
| 7824 | * <tr> |
| 7825 | * <td>String</td> |
| 7826 | * <td>{@link #NOTES}</td> |
| 7827 | * <td>read/write</td> |
| 7828 | * <td>Notes about the group.</td> |
| 7829 | * </tr> |
| 7830 | * <tr> |
| 7831 | * <td>String</td> |
| 7832 | * <td>{@link #SYSTEM_ID}</td> |
| 7833 | * <td>read/write</td> |
| 7834 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7835 | * special meaning to the sync adapter, null otherwise.</td> |
| 7836 | * </tr> |
| 7837 | * <tr> |
| 7838 | * <td>int</td> |
| 7839 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7840 | * <td>read-only</td> |
| 7841 | * <td>The total number of {@link Contacts} that have |
| 7842 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7843 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7844 | * </tr> |
| 7845 | * <tr> |
| 7846 | * <td>int</td> |
| 7847 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7848 | * <td>read-only</td> |
| 7849 | * <td>The total number of {@link Contacts} that have both |
| 7850 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7851 | * phone numbers. Read-only value that is only present when querying |
| 7852 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7853 | * </tr> |
| 7854 | * <tr> |
| 7855 | * <td>int</td> |
| 7856 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7857 | * <td>read-only</td> |
| 7858 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7859 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7860 | * </tr> |
| 7861 | * <tr> |
| 7862 | * <td>int</td> |
| 7863 | * <td>{@link #DELETED}</td> |
| 7864 | * <td>read/write</td> |
| 7865 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7866 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7867 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7868 | * the group on the server and then calls ContactResolver.delete once more, |
| 7869 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7870 | * query parameter to finalize the data removal.</td> |
| 7871 | * </tr> |
| 7872 | * <tr> |
| 7873 | * <td>int</td> |
| 7874 | * <td>{@link #SHOULD_SYNC}</td> |
| 7875 | * <td>read/write</td> |
| 7876 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7877 | * is false for this group's account.</td> |
| 7878 | * </tr> |
| 7879 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7880 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7881 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7882 | /** |
| 7883 | * This utility class cannot be instantiated |
| 7884 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7885 | private Groups() { |
| 7886 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7887 | |
| 7888 | /** |
| 7889 | * The content:// style URI for this table |
| 7890 | */ |
| 7891 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7892 | |
| 7893 | /** |
| 7894 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7895 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7896 | */ |
| 7897 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7898 | "groups_summary"); |
| 7899 | |
| 7900 | /** |
| 7901 | * The MIME type of a directory of groups. |
| 7902 | */ |
| 7903 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7904 | |
| 7905 | /** |
| 7906 | * The MIME type of a single group. |
| 7907 | */ |
| 7908 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7909 | |
| 7910 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7911 | return new EntityIteratorImpl(cursor); |
| 7912 | } |
| 7913 | |
| 7914 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7915 | public EntityIteratorImpl(Cursor cursor) { |
| 7916 | super(cursor); |
| 7917 | } |
| 7918 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7919 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7920 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7921 | // we expect the cursor is already at the row we need to read from |
| 7922 | final ContentValues values = new ContentValues(); |
| 7923 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7924 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7925 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7926 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7927 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7928 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7929 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7930 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7931 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7932 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7933 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7934 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7935 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7936 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7937 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7938 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7939 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7940 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7941 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7942 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7943 | cursor.moveToNext(); |
| 7944 | return new Entity(values); |
| 7945 | } |
| 7946 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7947 | } |
| 7948 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7949 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7950 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7951 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7952 | * aggregation rules overriding those used by automatic aggregation. This |
| 7953 | * type only supports query and update. Neither insert nor delete are |
| 7954 | * supported. |
| 7955 | * </p> |
| 7956 | * <h2>Columns</h2> |
| 7957 | * <table class="jd-sumtable"> |
| 7958 | * <tr> |
| 7959 | * <th colspan='4'>AggregationExceptions</th> |
| 7960 | * </tr> |
| 7961 | * <tr> |
| 7962 | * <td>int</td> |
| 7963 | * <td>{@link #TYPE}</td> |
| 7964 | * <td>read/write</td> |
| 7965 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 7966 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 7967 | * </tr> |
| 7968 | * <tr> |
| 7969 | * <td>long</td> |
| 7970 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 7971 | * <td>read/write</td> |
| 7972 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 7973 | * the rule applies to.</td> |
| 7974 | * </tr> |
| 7975 | * <tr> |
| 7976 | * <td>long</td> |
| 7977 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 7978 | * <td>read/write</td> |
| 7979 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 7980 | * that the rule applies to.</td> |
| 7981 | * </tr> |
| 7982 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7983 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7984 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7985 | /** |
| 7986 | * This utility class cannot be instantiated |
| 7987 | */ |
| 7988 | private AggregationExceptions() {} |
| 7989 | |
| 7990 | /** |
| 7991 | * The content:// style URI for this table |
| 7992 | */ |
| 7993 | public static final Uri CONTENT_URI = |
| 7994 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 7995 | |
| 7996 | /** |
| 7997 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 7998 | */ |
| 7999 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 8000 | |
| 8001 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 8002 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 8003 | */ |
| 8004 | public static final String CONTENT_ITEM_TYPE = |
| 8005 | "vnd.android.cursor.item/aggregation_exception"; |
| 8006 | |
| 8007 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8008 | * 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] | 8009 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8010 | * |
| 8011 | * <P>Type: INTEGER</P> |
| 8012 | */ |
| 8013 | public static final String TYPE = "type"; |
| 8014 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8015 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8016 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 8017 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8018 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8019 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8020 | |
| 8021 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8022 | * Makes sure that the specified raw contacts are included in the same |
| 8023 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8024 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8025 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 8026 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8027 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8028 | * Makes sure that the specified raw contacts are NOT included in the same |
| 8029 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8030 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8031 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 8032 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8033 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 8034 | * 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] | 8035 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8036 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 8037 | |
| 8038 | /** |
| 8039 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 8040 | * applies to. |
| 8041 | */ |
| 8042 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8043 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 8044 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8045 | /** |
| 8046 | * @see Settings |
| 8047 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 8048 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8049 | /** |
| 8050 | * The name of the account instance to which this row belongs. |
| 8051 | * <P>Type: TEXT</P> |
| 8052 | */ |
| 8053 | public static final String ACCOUNT_NAME = "account_name"; |
| 8054 | |
| 8055 | /** |
| 8056 | * The type of account to which this row belongs, which when paired with |
| 8057 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 8058 | * <P>Type: TEXT</P> |
| 8059 | */ |
| 8060 | public static final String ACCOUNT_TYPE = "account_type"; |
| 8061 | |
| 8062 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 8063 | * The data set within the account that this row belongs to. This allows |
| 8064 | * multiple sync adapters for the same account type to distinguish between |
| 8065 | * each others' data. |
| 8066 | * |
| 8067 | * This is empty by default, and is completely optional. It only needs to |
| 8068 | * be populated if multiple sync adapters are entering distinct data for |
| 8069 | * the same account type and account name. |
| 8070 | * <P>Type: TEXT</P> |
| 8071 | */ |
| 8072 | public static final String DATA_SET = "data_set"; |
| 8073 | |
| 8074 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8075 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 8076 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8077 | * <p> |
| 8078 | * Type: INTEGER (boolean) |
| 8079 | */ |
| 8080 | public static final String SHOULD_SYNC = "should_sync"; |
| 8081 | |
| 8082 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 8083 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 8084 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8085 | * <p> |
| 8086 | * Type: INTEGER (boolean) |
| 8087 | */ |
| 8088 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8089 | |
| 8090 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 8091 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8092 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8093 | * unsynced. |
| 8094 | */ |
| 8095 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 8096 | |
| 8097 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8098 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8099 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8100 | * <p> |
| 8101 | * Type: INTEGER |
| 8102 | */ |
| 8103 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 8104 | |
| 8105 | /** |
| 8106 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8107 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8108 | * <p> |
| 8109 | * Type: INTEGER |
| 8110 | */ |
| 8111 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8112 | } |
| 8113 | |
| 8114 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8115 | * <p> |
| 8116 | * Contacts-specific settings for various {@link Account}'s. |
| 8117 | * </p> |
| 8118 | * <h2>Columns</h2> |
| 8119 | * <table class="jd-sumtable"> |
| 8120 | * <tr> |
| 8121 | * <th colspan='4'>Settings</th> |
| 8122 | * </tr> |
| 8123 | * <tr> |
| 8124 | * <td>String</td> |
| 8125 | * <td>{@link #ACCOUNT_NAME}</td> |
| 8126 | * <td>read/write-once</td> |
| 8127 | * <td>The name of the account instance to which this row belongs.</td> |
| 8128 | * </tr> |
| 8129 | * <tr> |
| 8130 | * <td>String</td> |
| 8131 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 8132 | * <td>read/write-once</td> |
| 8133 | * <td>The type of account to which this row belongs, which when paired with |
| 8134 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 8135 | * </tr> |
| 8136 | * <tr> |
| 8137 | * <td>int</td> |
| 8138 | * <td>{@link #SHOULD_SYNC}</td> |
| 8139 | * <td>read/write</td> |
| 8140 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 8141 | * the top-level sync behavior for this data source.</td> |
| 8142 | * </tr> |
| 8143 | * <tr> |
| 8144 | * <td>int</td> |
| 8145 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 8146 | * <td>read/write</td> |
| 8147 | * <td>Flag indicating if contacts without any |
| 8148 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 8149 | * user interface.</td> |
| 8150 | * </tr> |
| 8151 | * <tr> |
| 8152 | * <td>int</td> |
| 8153 | * <td>{@link #ANY_UNSYNCED}</td> |
| 8154 | * <td>read-only</td> |
| 8155 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8156 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8157 | * unsynced.</td> |
| 8158 | * </tr> |
| 8159 | * <tr> |
| 8160 | * <td>int</td> |
| 8161 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 8162 | * <td>read-only</td> |
| 8163 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8164 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 8165 | * </tr> |
| 8166 | * <tr> |
| 8167 | * <td>int</td> |
| 8168 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 8169 | * <td>read-only</td> |
| 8170 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8171 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 8172 | * numbers.</td> |
| 8173 | * </tr> |
| 8174 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8175 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8176 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8177 | /** |
| 8178 | * This utility class cannot be instantiated |
| 8179 | */ |
| 8180 | private Settings() { |
| 8181 | } |
| 8182 | |
| 8183 | /** |
| 8184 | * The content:// style URI for this table |
| 8185 | */ |
| 8186 | public static final Uri CONTENT_URI = |
| 8187 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 8188 | |
| 8189 | /** |
| 8190 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8191 | * settings. |
| 8192 | */ |
| 8193 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 8194 | |
| 8195 | /** |
| 8196 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 8197 | */ |
| 8198 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8199 | } |
| 8200 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8201 | /** |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 8202 | * API for inquiring about the general status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8203 | */ |
| 8204 | public static final class ProviderStatus { |
| 8205 | |
| 8206 | /** |
| 8207 | * Not instantiable. |
| 8208 | */ |
| 8209 | private ProviderStatus() { |
| 8210 | } |
| 8211 | |
| 8212 | /** |
| 8213 | * The content:// style URI for this table. Requests to this URI can be |
| 8214 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8215 | */ |
| 8216 | public static final Uri CONTENT_URI = |
| 8217 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 8218 | |
| 8219 | /** |
| 8220 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8221 | * settings. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8222 | */ |
| 8223 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 8224 | |
| 8225 | /** |
| 8226 | * An integer representing the current status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8227 | */ |
| 8228 | public static final String STATUS = "status"; |
| 8229 | |
| 8230 | /** |
| 8231 | * Default status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8232 | */ |
| 8233 | public static final int STATUS_NORMAL = 0; |
| 8234 | |
| 8235 | /** |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8236 | * The provider won't respond to queries. It is in the middle of a long running task, such |
| 8237 | * as a database upgrade or locale change. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8238 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8239 | public static final int STATUS_BUSY = 1; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8240 | |
| 8241 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8242 | * The status that indicates that there are no accounts and no contacts |
| 8243 | * on the device. |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8244 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8245 | public static final int STATUS_EMPTY = 2; |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8246 | |
| 8247 | /** |
| 8248 | * Timestamp (milliseconds since epoch) of when the provider's database was created. |
| 8249 | * |
| 8250 | * <P>Type: long |
| 8251 | */ |
| 8252 | public static final String DATABASE_CREATION_TIMESTAMP = "database_creation_timestamp"; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8253 | } |
| 8254 | |
| 8255 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8256 | * <p> |
| 8257 | * 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] | 8258 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8259 | * </p> |
| 8260 | * <p> |
| 8261 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 8262 | * Data listing, typically supplied with |
| 8263 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 8264 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 8265 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 8266 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 8267 | * </p> |
| 8268 | * <p> |
| 8269 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 8270 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 8271 | * implementation, the storage data structures as well as the resulting sort order is device |
| 8272 | * and version specific and can change over time. |
| 8273 | * </p> |
| 8274 | * <p> |
| 8275 | * When updating usage information, users of this API need to use |
| 8276 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 8277 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 8278 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 8279 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 8280 | * interactions using the same contact data field (for example a phone number can be used to |
| 8281 | * make phone calls or send SMS). |
| 8282 | * </p> |
| 8283 | * <p> |
| 8284 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 8285 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 8286 | * toward {@link Data#CONTENT_URI}. |
| 8287 | * </p> |
| 8288 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8289 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 8290 | * integer when successful, and returns 0 if no contact with that id was found. |
| 8291 | * </p> |
| 8292 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8293 | * Example: |
| 8294 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8295 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8296 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8297 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 8298 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8299 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8300 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8301 | * </pre> |
| 8302 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8303 | * <p> |
| 8304 | * Applications can also clear all usage information with: |
| 8305 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8306 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8307 | * </pre> |
| 8308 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8309 | */ |
| 8310 | public static final class DataUsageFeedback { |
| 8311 | |
| 8312 | /** |
| 8313 | * The content:// style URI for sending usage feedback. |
| 8314 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 8315 | */ |
| 8316 | public static final Uri FEEDBACK_URI = |
| 8317 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 8318 | |
| 8319 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8320 | * The content:// style URI for deleting all usage information. |
| 8321 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 8322 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 8323 | */ |
| 8324 | public static final Uri DELETE_USAGE_URI = |
| 8325 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 8326 | |
| 8327 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8328 | * <p> |
| 8329 | * Name for query parameter specifying the type of data usage. |
| 8330 | * </p> |
| 8331 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8332 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8333 | |
| 8334 | /** |
| 8335 | * <p> |
| 8336 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 8337 | * video chat. |
| 8338 | * </p> |
| 8339 | */ |
| 8340 | public static final String USAGE_TYPE_CALL = "call"; |
| 8341 | |
| 8342 | /** |
| 8343 | * <p> |
| 8344 | * Type of usage for text interaction involving longer messages, which includes email. |
| 8345 | * </p> |
| 8346 | */ |
| 8347 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 8348 | |
| 8349 | /** |
| 8350 | * <p> |
| 8351 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 8352 | * text chat with email addresses. |
| 8353 | * </p> |
| 8354 | */ |
| 8355 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 8356 | } |
| 8357 | |
| 8358 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8359 | * <p> |
Yorke Lee | cadbe4c | 2014-06-20 11:52:27 -0700 | [diff] [blame] | 8360 | * Contact-specific information about whether or not a contact has been pinned by the user |
| 8361 | * at a particular position within the system contact application's user interface. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8362 | * </p> |
| 8363 | * |
| 8364 | * <p> |
| 8365 | * This pinning information can be used by individual applications to customize how |
| 8366 | * they order particular pinned contacts. For example, a Dialer application could |
| 8367 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 8368 | * </p> |
| 8369 | * |
| 8370 | * <p> |
| 8371 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 8372 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 8373 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 8374 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 8375 | * on this information, so it is up to the client application to reorder these contacts within |
| 8376 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 8377 | * column. |
| 8378 | * </p> |
| 8379 | * |
| 8380 | * <p> |
| 8381 | * By default, unpinned contacts will have a pinned position of |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8382 | * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive |
| 8383 | * integers that are greater than 1. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8384 | * </p> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8385 | */ |
| 8386 | public static final class PinnedPositions { |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8387 | /** |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8388 | * The method to invoke in order to undemote a formerly demoted contact. The contact id of |
| 8389 | * the contact must be provided as an argument. If the contact was not previously demoted, |
| 8390 | * nothing will be done. |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8391 | * @hide |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8392 | */ |
| 8393 | public static final String UNDEMOTE_METHOD = "undemote"; |
| 8394 | |
| 8395 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8396 | * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing |
| 8397 | * will be done. |
| 8398 | * |
| 8399 | * @param contentResolver to perform the undemote operation on. |
| 8400 | * @param contactId the id of the contact to undemote. |
| 8401 | */ |
| 8402 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 8403 | contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, |
| 8404 | String.valueOf(contactId), null); |
| 8405 | } |
| 8406 | |
| 8407 | /** |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 8408 | * Pins a contact at a provided position, or unpins a contact. |
| 8409 | * |
| 8410 | * @param contentResolver to perform the pinning operation on. |
| 8411 | * @param pinnedPosition the position to pin the contact at. To unpin a contact, use |
| 8412 | * {@link PinnedPositions#UNPINNED}. |
| 8413 | */ |
| 8414 | public static void pin( |
| 8415 | ContentResolver contentResolver, long contactId, int pinnedPosition) { |
| 8416 | final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); |
| 8417 | final ContentValues values = new ContentValues(); |
| 8418 | values.put(Contacts.PINNED, pinnedPosition); |
| 8419 | contentResolver.update(uri, values, null, null); |
| 8420 | } |
| 8421 | |
| 8422 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8423 | * Default value for the pinned position of an unpinned contact. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8424 | */ |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8425 | public static final int UNPINNED = 0; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8426 | |
| 8427 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 8428 | * Value of pinned position for a contact that a user has indicated should be considered |
| 8429 | * of the lowest priority. It is up to the client application to determine how to present |
| 8430 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 8431 | * just hidden from view. |
| 8432 | */ |
| 8433 | public static final int DEMOTED = -1; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8434 | } |
| 8435 | |
| 8436 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8437 | * 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] | 8438 | * a specific {@link Contacts} entry. |
| 8439 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8440 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8441 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8442 | * Action used to launch the system contacts application and bring up a QuickContact dialog |
| 8443 | * for the provided {@link Contacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8444 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 8445 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 8446 | public static final String ACTION_QUICK_CONTACT = |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 8447 | "android.provider.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8448 | |
| 8449 | /** |
| 8450 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8451 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8452 | * @hide |
| 8453 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8454 | @Deprecated |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8455 | public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8456 | |
| 8457 | /** |
Brian Attwell | 029e681 | 2015-02-02 16:10:39 -0800 | [diff] [blame] | 8458 | * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts |
| 8459 | * will respect this extra's value. |
| 8460 | * |
| 8461 | * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8462 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8463 | public static final String EXTRA_MODE = "android.provider.extra.MODE"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8464 | |
| 8465 | /** |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8466 | * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. |
| 8467 | * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can |
| 8468 | * cause phone numbers to be displayed more prominently in QuickContacts. |
| 8469 | */ |
| 8470 | public static final String EXTRA_PRIORITIZED_MIMETYPE |
| 8471 | = "android.provider.extra.PRIORITIZED_MIMETYPE"; |
| 8472 | |
| 8473 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8474 | * Extra used to indicate a list of specific MIME-types to exclude and not display in the |
| 8475 | * QuickContacts dialog. Stored as a {@link String} array. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8476 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8477 | public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8478 | |
| 8479 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8480 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8481 | */ |
| 8482 | public static final int MODE_SMALL = 1; |
| 8483 | |
| 8484 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8485 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8486 | * the {@link Contacts} entry being shown. This may include social |
| 8487 | * status and presence details. |
| 8488 | */ |
| 8489 | public static final int MODE_MEDIUM = 2; |
| 8490 | |
| 8491 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8492 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8493 | * of the {@link Contacts} entry being shown. This may include detailed |
| 8494 | * information, such as a photo. |
| 8495 | */ |
| 8496 | public static final int MODE_LARGE = 3; |
| 8497 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8498 | /** @hide */ |
| 8499 | public static final int MODE_DEFAULT = MODE_LARGE; |
| 8500 | |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8501 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8502 | * Constructs the QuickContacts intent with a view's rect. |
| 8503 | * @hide |
| 8504 | */ |
| 8505 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 8506 | int mode, String[] excludeMimes) { |
| 8507 | // Find location and bounds of target view, adjusting based on the |
| 8508 | // assumed local density. |
| 8509 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 8510 | final int[] pos = new int[2]; |
| 8511 | target.getLocationOnScreen(pos); |
| 8512 | |
| 8513 | final Rect rect = new Rect(); |
| 8514 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 8515 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 8516 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 8517 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 8518 | |
| 8519 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 8520 | } |
| 8521 | |
| 8522 | /** |
| 8523 | * Constructs the QuickContacts intent. |
| 8524 | * @hide |
| 8525 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 8526 | @UnsupportedAppUsage |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8527 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 8528 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 8529 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 8530 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 8531 | Context actualContext = context; |
| 8532 | while ((actualContext instanceof ContextWrapper) |
| 8533 | && !(actualContext instanceof Activity)) { |
| 8534 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 8535 | } |
Brian Attwell | 9ee6640 | 2014-08-11 22:42:26 -0700 | [diff] [blame] | 8536 | final int intentFlags = ((actualContext instanceof Activity) |
| 8537 | ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) |
| 8538 | // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. |
| 8539 | | Intent.FLAG_ACTIVITY_SINGLE_TOP; |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8540 | |
| 8541 | // Launch pivot dialog through intent for now |
| 8542 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 8543 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8544 | // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync. |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8545 | intent.setData(lookupUri); |
| 8546 | intent.setSourceBounds(target); |
| 8547 | intent.putExtra(EXTRA_MODE, mode); |
| 8548 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 8549 | return intent; |
| 8550 | } |
| 8551 | |
| 8552 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8553 | * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager |
| 8554 | * to strip off anything not necessary. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 8555 | * |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8556 | * @hide |
| 8557 | */ |
| 8558 | public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId, |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8559 | boolean isContactIdIgnored, long directoryId, Intent originalIntent) { |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8560 | final Intent intent = new Intent(ACTION_QUICK_CONTACT); |
| 8561 | // Rebuild the URI from a lookup key and a contact ID. |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8562 | Uri uri = null; |
| 8563 | if (!TextUtils.isEmpty(lookupKey)) { |
| 8564 | uri = isContactIdIgnored |
| 8565 | ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey) |
| 8566 | : Contacts.getLookupUri(contactId, lookupKey); |
| 8567 | } |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 8568 | if (uri != null && directoryId != Directory.DEFAULT) { |
| 8569 | uri = uri.buildUpon().appendQueryParameter( |
| 8570 | ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build(); |
| 8571 | } |
| 8572 | intent.setData(uri); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8573 | |
| 8574 | // Copy flags and always set NEW_TASK because it won't have a parent activity. |
| 8575 | intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 8576 | |
| 8577 | // Copy extras. |
| 8578 | intent.setSourceBounds(originalIntent.getSourceBounds()); |
| 8579 | intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT)); |
| 8580 | intent.putExtra(EXTRA_EXCLUDE_MIMES, |
| 8581 | originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES)); |
| 8582 | return intent; |
| 8583 | } |
| 8584 | |
| 8585 | |
| 8586 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8587 | * Trigger a dialog that lists the various methods of interacting with |
| 8588 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8589 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8590 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8591 | * |
| 8592 | * @param context The parent {@link Context} that may be used as the |
| 8593 | * parent for this dialog. |
| 8594 | * @param target Specific {@link View} from your layout that this dialog |
| 8595 | * should be centered around. In particular, if the dialog |
| 8596 | * has a "callout" arrow, it will be pointed and centered |
| 8597 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 8598 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8599 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8600 | * in this dialog. A work lookup uri is supported here, |
| 8601 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8602 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8603 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8604 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8605 | * when supported. |
| 8606 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8607 | * to exclude when showing this dialog. For example, when |
| 8608 | * already viewing the contact details card, this can be used |
| 8609 | * to omit the details entry from the dialog. |
| 8610 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8611 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8612 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8613 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8614 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8615 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8616 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8617 | } |
| 8618 | |
| 8619 | /** |
| 8620 | * Trigger a dialog that lists the various methods of interacting with |
| 8621 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8622 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8623 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8624 | * |
| 8625 | * @param context The parent {@link Context} that may be used as the |
| 8626 | * parent for this dialog. |
| 8627 | * @param target Specific {@link Rect} that this dialog should be |
| 8628 | * centered around, in screen coordinates. In particular, if |
| 8629 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8630 | * centered around this {@link Rect}. If you are running at a |
| 8631 | * non-native density, you need to manually adjust using |
| 8632 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8633 | * @param lookupUri A |
| 8634 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8635 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8636 | * in this dialog. A work lookup uri is supported here, |
| 8637 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8638 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8639 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8640 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8641 | * when supported. |
| 8642 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8643 | * to exclude when showing this dialog. For example, when |
| 8644 | * already viewing the contact details card, this can be used |
| 8645 | * to omit the details entry from the dialog. |
| 8646 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8647 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8648 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8649 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8650 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8651 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8652 | } |
| 8653 | |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8654 | /** |
| 8655 | * Trigger a dialog that lists the various methods of interacting with |
| 8656 | * the requested {@link Contacts} entry. This may be based on available |
| 8657 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8658 | * include social status and presence details. |
| 8659 | * |
| 8660 | * @param context The parent {@link Context} that may be used as the |
| 8661 | * parent for this dialog. |
| 8662 | * @param target Specific {@link View} from your layout that this dialog |
| 8663 | * should be centered around. In particular, if the dialog |
| 8664 | * has a "callout" arrow, it will be pointed and centered |
| 8665 | * around this {@link View}. |
| 8666 | * @param lookupUri A |
| 8667 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8668 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8669 | * in this dialog. A work lookup uri is supported here, |
| 8670 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8671 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8672 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8673 | * to exclude when showing this dialog. For example, when |
| 8674 | * already viewing the contact details card, this can be used |
| 8675 | * to omit the details entry from the dialog. |
| 8676 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8677 | * For example, passing the value |
| 8678 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8679 | * displayed more prominently in QuickContacts. |
| 8680 | */ |
| 8681 | public static void showQuickContact(Context context, View target, Uri lookupUri, |
| 8682 | String[] excludeMimes, String prioritizedMimeType) { |
| 8683 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8684 | // values defined in ContactsContract only affect very old implementations |
| 8685 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8686 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8687 | excludeMimes); |
| 8688 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8689 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8690 | } |
| 8691 | |
| 8692 | /** |
| 8693 | * Trigger a dialog that lists the various methods of interacting with |
| 8694 | * the requested {@link Contacts} entry. This may be based on available |
| 8695 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8696 | * include social status and presence details. |
| 8697 | * |
| 8698 | * @param context The parent {@link Context} that may be used as the |
| 8699 | * parent for this dialog. |
| 8700 | * @param target Specific {@link Rect} that this dialog should be |
| 8701 | * centered around, in screen coordinates. In particular, if |
| 8702 | * the dialog has a "callout" arrow, it will be pointed and |
| 8703 | * centered around this {@link Rect}. If you are running at a |
| 8704 | * non-native density, you need to manually adjust using |
| 8705 | * {@link DisplayMetrics#density} before calling. |
| 8706 | * @param lookupUri A |
| 8707 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8708 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8709 | * in this dialog. A work lookup uri is supported here, |
| 8710 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8711 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8712 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8713 | * to exclude when showing this dialog. For example, when |
| 8714 | * already viewing the contact details card, this can be used |
| 8715 | * to omit the details entry from the dialog. |
| 8716 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8717 | * For example, passing the value |
| 8718 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8719 | * displayed more prominently in QuickContacts. |
| 8720 | */ |
| 8721 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, |
| 8722 | String[] excludeMimes, String prioritizedMimeType) { |
| 8723 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8724 | // values defined in ContactsContract only affect very old implementations |
| 8725 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8726 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8727 | excludeMimes); |
| 8728 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8729 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8730 | } |
| 8731 | } |
| 8732 | |
| 8733 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8734 | * Helper class for accessing full-size photos by photo file ID. |
| 8735 | * <p> |
| 8736 | * Usage example: |
| 8737 | * <dl> |
| 8738 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8739 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8740 | * </dt> |
| 8741 | * <dd> |
| 8742 | * <pre> |
| 8743 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8744 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8745 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8746 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8747 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8748 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8749 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8750 | * return null; |
| 8751 | * } |
| 8752 | * } |
| 8753 | * </pre> |
| 8754 | * </dd> |
| 8755 | * </dl> |
| 8756 | * </p> |
| 8757 | */ |
| 8758 | public static final class DisplayPhoto { |
| 8759 | /** |
| 8760 | * no public constructor since this is a utility class |
| 8761 | */ |
| 8762 | private DisplayPhoto() {} |
| 8763 | |
| 8764 | /** |
| 8765 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8766 | * given a key. |
| 8767 | */ |
| 8768 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8769 | |
| 8770 | /** |
| 8771 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8772 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8773 | * they are always unblocking. |
| 8774 | */ |
| 8775 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8776 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8777 | |
| 8778 | /** |
| 8779 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8780 | * contain this column, populated with the maximum height and width (in pixels) |
| 8781 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8782 | * fit within a square of this many pixels. |
| 8783 | */ |
| 8784 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8785 | |
| 8786 | /** |
| 8787 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8788 | * contain this column, populated with the height and width (in pixels) for photo |
| 8789 | * thumbnails. |
| 8790 | */ |
| 8791 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8792 | } |
| 8793 | |
| 8794 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8795 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8796 | * that involve contacts. |
| 8797 | */ |
| 8798 | public static final class Intents { |
| 8799 | /** |
| 8800 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8801 | */ |
| 8802 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8803 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8804 | |
| 8805 | /** |
| 8806 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8807 | * is clicked on. |
| 8808 | */ |
| 8809 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8810 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8811 | |
| 8812 | /** |
| 8813 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8814 | * is clicked on. |
| 8815 | */ |
| 8816 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8817 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8818 | |
| 8819 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8820 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8821 | * READ_CONTACT permission is required to receive these broadcasts. |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8822 | * |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 8823 | * <p>Because this is an implicit broadcast, apps targeting Android O will no longer |
| 8824 | * receive this broadcast via a manifest broadcast receiver. (Broadcast receivers |
| 8825 | * registered at runtime with |
| 8826 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)} will still receive it.) |
| 8827 | * Instead, an app can use {@link ProviderStatus#DATABASE_CREATION_TIMESTAMP} to see if the |
| 8828 | * contacts database has been initialized when it starts. |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8829 | */ |
| 8830 | public static final String CONTACTS_DATABASE_CREATED = |
| 8831 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8832 | |
| 8833 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8834 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8835 | * After picking the contact it launches the image cropper in face detection mode. |
| 8836 | */ |
| 8837 | public static final String ATTACH_IMAGE = |
| 8838 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8839 | |
| 8840 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8841 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8842 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8843 | * provider which supports the "invite to the network" feature. |
| 8844 | * <p> |
| 8845 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8846 | */ |
| 8847 | public static final String INVITE_CONTACT = |
| 8848 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8849 | |
| 8850 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8851 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8852 | * contact exists with the given data it will be shown. If no contact |
| 8853 | * exists, a dialog will ask the user if they want to create a new |
| 8854 | * contact with the provided details filled in. If multiple contacts |
| 8855 | * share the data the user will be prompted to pick which contact they |
| 8856 | * want to view. |
| 8857 | * <p> |
| 8858 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8859 | * raw email address, such as one built using |
| 8860 | * {@link Uri#fromParts(String, String, String)}. |
| 8861 | * <p> |
| 8862 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8863 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8864 | * The number must be properly encoded, for example using |
| 8865 | * {@link Uri#fromParts(String, String, String)}. |
| 8866 | * <p> |
| 8867 | * Any extras from the {@link Insert} class will be passed along to the |
| 8868 | * create activity if there are no contacts to show. |
| 8869 | * <p> |
| 8870 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8871 | * prompting the user when the contact doesn't exist. |
| 8872 | */ |
| 8873 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8874 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8875 | |
| 8876 | /** |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8877 | * Activity Action: Initiate a message to someone by voice. The message could be text, |
| 8878 | * audio, video or image(photo). This action supports messaging with a specific contact |
| 8879 | * regardless of the underlying messaging protocol used. |
| 8880 | * <p> |
| 8881 | * The action could be originated from the Voice Assistant as a voice interaction. In such |
| 8882 | * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE} |
| 8883 | * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before |
| 8884 | * proceeding. By doing this check the activity verifies that the action indeed was |
| 8885 | * initiated by Voice Assistant and could send a message right away, without any further |
| 8886 | * input from the user. This allows for a smooth user experience when sending a message by |
| 8887 | * voice. Note: this activity must also support the {@link |
| 8888 | * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link |
| 8889 | * android.service.voice.VoiceInteractionSession#startVoiceActivity}. |
| 8890 | * <p> |
| 8891 | * 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] | 8892 | * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8893 | * with the user before sending the message (because in this case it is unknown which app |
| 8894 | * sent the intent, it could be malicious). |
| 8895 | * <p> |
| 8896 | * 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] | 8897 | * app may choose to integrate with the Contacts Provider. You will need to specify a new |
| 8898 | * MIME type in order to store your app’s unique contact IDs and optional human readable |
| 8899 | * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link |
| 8900 | * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact |
| 8901 | * disambiguation user experience. The following convention should be met when performing |
| 8902 | * such integration: |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8903 | * <ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8904 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 8905 | * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts |
| 8906 | * Provider implementation. The account type should be globally unique, for example you can |
| 8907 | * use your app package name as the account type.</li> |
| 8908 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 8909 | * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts |
| 8910 | * Provider implementation. For example, you can use |
| 8911 | * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li> |
| 8912 | * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1} |
| 8913 | * should store the unique contact ID as understood by the app. This value will be used in |
| 8914 | * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li> |
| 8915 | * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link |
| 8916 | * DataColumns#DATA3} could store a human readable label for the ID. For example it could be |
| 8917 | * phone number or human readable username/user_id like "a_super_cool_user_name". This label |
| 8918 | * may be shown below the Contact Name by the Voice Assistant as the user completes the |
| 8919 | * 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] | 8920 | * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will |
| 8921 | * already get the Contact Name from the RawContact’s display_name.</em></li> |
| 8922 | * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1. |
| 8923 | * If this applies to you and you’d like phone number to be shown below the Contact Name by |
| 8924 | * 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] | 8925 | * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App, |
| 8926 | * make sure it does not include prefix text such as "Message +<phone>" or "Free Message |
| 8927 | * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a |
| 8928 | * different DATA# column, and update your contacts.xml to point to this new column. </em> |
| 8929 | * </li> |
| 8930 | * <li>Everytime the user sends a message to a contact, your app may choose to update the |
| 8931 | * {@link ContactOptionsColumns#TIMES_CONTACTED} entry through DataUsageFeedback class. |
| 8932 | * Doing this will allow Voice Assistant to bias speech recognition to contacts frequently |
| 8933 | * contacted, this is particularly useful for contact names that are hard to pronounce.</li> |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8934 | * </ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8935 | * If the app chooses not to integrate with the Contacts Provider (in particular, when |
| 8936 | * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant |
| 8937 | * 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] | 8938 | * <p> |
| 8939 | * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent. |
| 8940 | * The intent sender will always put the concrete mime type in the intent type, like |
| 8941 | * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to |
| 8942 | * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled |
| 8943 | * CharSequence. Otherwise, the message content will be supplied through {@link |
| 8944 | * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter |
| 8945 | * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages |
| 8946 | * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text |
| 8947 | * transcription of this recording. |
| 8948 | * <p> |
| 8949 | * The message can have n recipients. The n-th recipient of the message will be provided as |
| 8950 | * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link |
| 8951 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a |
| 8952 | * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and |
| 8953 | * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements |
| 8954 | * is provided (e.g. all 3 are null) for the recipient or if the information provided is |
| 8955 | * ambiguous then the activity should prompt the user for the recipient to send the message |
| 8956 | * to. |
| 8957 | * <p> |
| 8958 | * Output: nothing |
| 8959 | * |
| 8960 | * @see #EXTRA_RECIPIENT_CONTACT_URI |
| 8961 | * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID |
| 8962 | * @see #EXTRA_RECIPIENT_CONTACT_NAME |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8963 | * @see #METADATA_ACCOUNT_TYPE |
| 8964 | * @see #METADATA_MIMETYPE |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8965 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 8966 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8967 | public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS = |
| 8968 | "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS"; |
| 8969 | |
| 8970 | /** |
| 8971 | * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were |
| 8972 | * located in the Contacts Provider), used with {@link |
| 8973 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 8974 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 8975 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and |
| 8976 | * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 8977 | * recipient is absent, it will be set to null. |
| 8978 | * <p> |
| 8979 | * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging |
| 8980 | * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two |
| 8981 | * accounts on the same messaging app.</em> |
| 8982 | * <p> |
| 8983 | * <em>Example value: {"content://com.android.contacts/contacts/16"}</em> |
| 8984 | */ |
| 8985 | public static final String EXTRA_RECIPIENT_CONTACT_URI = |
| 8986 | "android.provider.extra.RECIPIENT_CONTACT_URI"; |
| 8987 | |
| 8988 | /** |
| 8989 | * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link |
| 8990 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 8991 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 8992 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 8993 | * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 8994 | * recipient is absent, it will be set to null. |
| 8995 | * <p> |
| 8996 | * 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] | 8997 | * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both |
| 8998 | * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app; |
| 8999 | * otherwise, the value will be a phone number), and should be the unambiguous contact |
| 9000 | * 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] | 9001 | */ |
| 9002 | public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID = |
| 9003 | "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID"; |
| 9004 | |
| 9005 | /** |
| 9006 | * This extra specifies the contact name (full name from the Contacts Provider), used with |
| 9007 | * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this |
| 9008 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9009 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 9010 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular |
| 9011 | * recipient is absent, it will be set to null. |
| 9012 | * <p> |
| 9013 | * The value of the elements comes from RawContact's display_name column. |
| 9014 | * <p> |
| 9015 | * <em>Example value: {"Jane Doe"}</em> |
| 9016 | */ |
| 9017 | public static final String EXTRA_RECIPIENT_CONTACT_NAME = |
| 9018 | "android.provider.extra.RECIPIENT_CONTACT_NAME"; |
| 9019 | |
| 9020 | /** |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9021 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9022 | * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider |
| 9023 | * implementation. |
| 9024 | */ |
| 9025 | public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; |
| 9026 | |
| 9027 | /** |
| 9028 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9029 | * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider |
| 9030 | * implementation. |
| 9031 | */ |
| 9032 | public static final String METADATA_MIMETYPE = "android.provider.mimetype"; |
| 9033 | |
| 9034 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9035 | * Starts an Activity that lets the user select the multiple phones from a |
| 9036 | * list of phone numbers which come from the contacts or |
| 9037 | * {@link #EXTRA_PHONE_URIS}. |
| 9038 | * <p> |
| 9039 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 9040 | * could belong to the contacts or not, and will be selected by default. |
| 9041 | * <p> |
| 9042 | * The user's selection will be returned from |
| 9043 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 9044 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9045 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 9046 | * numbers are in the Intent's |
| 9047 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 9048 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 9049 | * left the Activity without changing the selection. |
| 9050 | * |
| 9051 | * @hide |
| 9052 | */ |
| 9053 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 9054 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 9055 | |
| 9056 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 9057 | * A broadcast action which is sent when any change has been made to the profile, such |
| 9058 | * as the profile name or the picture. A receiver must have |
| 9059 | * the android.permission.READ_PROFILE permission. |
| 9060 | * |
| 9061 | * @hide |
| 9062 | */ |
| 9063 | public static final String ACTION_PROFILE_CHANGED = |
| 9064 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 9065 | |
| 9066 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9067 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 9068 | * contact if no matching contact found. Otherwise, default behavior is |
| 9069 | * to prompt user with dialog before creating. |
| 9070 | * <p> |
| 9071 | * Type: BOOLEAN |
| 9072 | */ |
| 9073 | public static final String EXTRA_FORCE_CREATE = |
| 9074 | "com.android.contacts.action.FORCE_CREATE"; |
| 9075 | |
| 9076 | /** |
| 9077 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 9078 | * description to be shown when prompting user about creating a new |
| 9079 | * contact. |
| 9080 | * <p> |
| 9081 | * Type: STRING |
| 9082 | */ |
| 9083 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 9084 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 9085 | |
| 9086 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9087 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 9088 | * <p> |
| 9089 | * The phone numbers want to be picked by default should be passed in as |
| 9090 | * input value. These phone numbers could belong to the contacts or not. |
| 9091 | * <p> |
| 9092 | * The phone numbers which were picked by the user are returned as output |
| 9093 | * value. |
| 9094 | * <p> |
| 9095 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 9096 | * 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] | 9097 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9098 | * @hide |
| 9099 | */ |
| 9100 | public static final String EXTRA_PHONE_URIS = |
| 9101 | "com.android.contacts.extra.PHONE_URIS"; |
| 9102 | |
| 9103 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9104 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9105 | * dialog location using screen coordinates. When not specified, the |
| 9106 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9107 | * |
| 9108 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9109 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9110 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9111 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 9112 | |
| 9113 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9114 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9115 | * desired dialog style, usually a variation on size. One of |
| 9116 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9117 | * |
| 9118 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9119 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9120 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9121 | public static final String EXTRA_MODE = "mode"; |
| 9122 | |
| 9123 | /** |
| 9124 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9125 | * |
| 9126 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9127 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9128 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9129 | public static final int MODE_SMALL = 1; |
| 9130 | |
| 9131 | /** |
| 9132 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9133 | * |
| 9134 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9135 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9136 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9137 | public static final int MODE_MEDIUM = 2; |
| 9138 | |
| 9139 | /** |
| 9140 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9141 | * |
| 9142 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9143 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9144 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9145 | public static final int MODE_LARGE = 3; |
| 9146 | |
| 9147 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9148 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 9149 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 9150 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9151 | * |
| 9152 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9153 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9154 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9155 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 9156 | |
| 9157 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9158 | * Convenience class that contains string constants used |
| 9159 | * to create contact {@link android.content.Intent Intents}. |
| 9160 | */ |
| 9161 | public static final class Insert { |
| 9162 | /** The action code to use when adding a contact */ |
| 9163 | public static final String ACTION = Intent.ACTION_INSERT; |
| 9164 | |
| 9165 | /** |
| 9166 | * If present, forces a bypass of quick insert mode. |
| 9167 | */ |
| 9168 | public static final String FULL_MODE = "full_mode"; |
| 9169 | |
| 9170 | /** |
| 9171 | * The extra field for the contact name. |
| 9172 | * <P>Type: String</P> |
| 9173 | */ |
| 9174 | public static final String NAME = "name"; |
| 9175 | |
| 9176 | // TODO add structured name values here. |
| 9177 | |
| 9178 | /** |
| 9179 | * The extra field for the contact phonetic name. |
| 9180 | * <P>Type: String</P> |
| 9181 | */ |
| 9182 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 9183 | |
| 9184 | /** |
| 9185 | * The extra field for the contact company. |
| 9186 | * <P>Type: String</P> |
| 9187 | */ |
| 9188 | public static final String COMPANY = "company"; |
| 9189 | |
| 9190 | /** |
| 9191 | * The extra field for the contact job title. |
| 9192 | * <P>Type: String</P> |
| 9193 | */ |
| 9194 | public static final String JOB_TITLE = "job_title"; |
| 9195 | |
| 9196 | /** |
| 9197 | * The extra field for the contact notes. |
| 9198 | * <P>Type: String</P> |
| 9199 | */ |
| 9200 | public static final String NOTES = "notes"; |
| 9201 | |
| 9202 | /** |
| 9203 | * The extra field for the contact phone number. |
| 9204 | * <P>Type: String</P> |
| 9205 | */ |
| 9206 | public static final String PHONE = "phone"; |
| 9207 | |
| 9208 | /** |
| 9209 | * The extra field for the contact phone number type. |
| 9210 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9211 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9212 | * or a string specifying a custom label.</P> |
| 9213 | */ |
| 9214 | public static final String PHONE_TYPE = "phone_type"; |
| 9215 | |
| 9216 | /** |
| 9217 | * The extra field for the phone isprimary flag. |
| 9218 | * <P>Type: boolean</P> |
| 9219 | */ |
| 9220 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 9221 | |
| 9222 | /** |
| 9223 | * The extra field for an optional second contact phone number. |
| 9224 | * <P>Type: String</P> |
| 9225 | */ |
| 9226 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 9227 | |
| 9228 | /** |
| 9229 | * The extra field for an optional second contact phone number type. |
| 9230 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9231 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9232 | * or a string specifying a custom label.</P> |
| 9233 | */ |
| 9234 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 9235 | |
| 9236 | /** |
| 9237 | * The extra field for an optional third contact phone number. |
| 9238 | * <P>Type: String</P> |
| 9239 | */ |
| 9240 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 9241 | |
| 9242 | /** |
| 9243 | * The extra field for an optional third contact phone number type. |
| 9244 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9245 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9246 | * or a string specifying a custom label.</P> |
| 9247 | */ |
| 9248 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 9249 | |
| 9250 | /** |
| 9251 | * The extra field for the contact email address. |
| 9252 | * <P>Type: String</P> |
| 9253 | */ |
| 9254 | public static final String EMAIL = "email"; |
| 9255 | |
| 9256 | /** |
| 9257 | * The extra field for the contact email type. |
| 9258 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9259 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9260 | * or a string specifying a custom label.</P> |
| 9261 | */ |
| 9262 | public static final String EMAIL_TYPE = "email_type"; |
| 9263 | |
| 9264 | /** |
| 9265 | * The extra field for the email isprimary flag. |
| 9266 | * <P>Type: boolean</P> |
| 9267 | */ |
| 9268 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 9269 | |
| 9270 | /** |
| 9271 | * The extra field for an optional second contact email address. |
| 9272 | * <P>Type: String</P> |
| 9273 | */ |
| 9274 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 9275 | |
| 9276 | /** |
| 9277 | * The extra field for an optional second contact email type. |
| 9278 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9279 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9280 | * or a string specifying a custom label.</P> |
| 9281 | */ |
| 9282 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 9283 | |
| 9284 | /** |
| 9285 | * The extra field for an optional third contact email address. |
| 9286 | * <P>Type: String</P> |
| 9287 | */ |
| 9288 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 9289 | |
| 9290 | /** |
| 9291 | * The extra field for an optional third contact email type. |
| 9292 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9293 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9294 | * or a string specifying a custom label.</P> |
| 9295 | */ |
| 9296 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 9297 | |
| 9298 | /** |
| 9299 | * The extra field for the contact postal address. |
| 9300 | * <P>Type: String</P> |
| 9301 | */ |
| 9302 | public static final String POSTAL = "postal"; |
| 9303 | |
| 9304 | /** |
| 9305 | * The extra field for the contact postal address type. |
| 9306 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9307 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9308 | * or a string specifying a custom label.</P> |
| 9309 | */ |
| 9310 | public static final String POSTAL_TYPE = "postal_type"; |
| 9311 | |
| 9312 | /** |
| 9313 | * The extra field for the postal isprimary flag. |
| 9314 | * <P>Type: boolean</P> |
| 9315 | */ |
| 9316 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 9317 | |
| 9318 | /** |
| 9319 | * The extra field for an IM handle. |
| 9320 | * <P>Type: String</P> |
| 9321 | */ |
| 9322 | public static final String IM_HANDLE = "im_handle"; |
| 9323 | |
| 9324 | /** |
| 9325 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9326 | */ |
| 9327 | public static final String IM_PROTOCOL = "im_protocol"; |
| 9328 | |
| 9329 | /** |
| 9330 | * The extra field for the IM isprimary flag. |
| 9331 | * <P>Type: boolean</P> |
| 9332 | */ |
| 9333 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9334 | |
| 9335 | /** |
| 9336 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9337 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 9338 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 9339 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 9340 | * similar to inserting multiple rows into the {@link Data} table, |
| 9341 | * except the user gets a chance to see and edit them before saving. |
| 9342 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 9343 | * If supplied values are not visible in the editor UI, they will be |
| 9344 | * dropped. Duplicate data will dropped. Some fields |
| 9345 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 9346 | * adjusted to comply with the constraints of the specific account type. |
| 9347 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 9348 | * so the contact editor may choose a different type for this phone number to |
| 9349 | * avoid dropping the valueable part of the row, which is the phone number. |
| 9350 | * <p> |
| 9351 | * Example: |
| 9352 | * <pre> |
| 9353 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9354 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9355 | * ContentValues row1 = new ContentValues(); |
| 9356 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 9357 | * row1.put(Organization.COMPANY, "Android"); |
| 9358 | * data.add(row1); |
| 9359 | * |
| 9360 | * ContentValues row2 = new ContentValues(); |
| 9361 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 9362 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 9363 | * row2.put(Email.LABEL, "Green Bot"); |
| 9364 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 9365 | * data.add(row2); |
| 9366 | * |
| 9367 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 9368 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 9369 | * |
| 9370 | * startActivity(intent); |
| 9371 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9372 | */ |
| 9373 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9374 | |
| 9375 | /** |
| 9376 | * Used to specify the account in which to create the new contact. |
| 9377 | * <p> |
| 9378 | * If this value is not provided, the user is presented with a disambiguation |
| 9379 | * dialog to chose an account |
| 9380 | * <p> |
| 9381 | * Type: {@link Account} |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9382 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9383 | public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9384 | |
| 9385 | /** |
| 9386 | * Used to specify the data set within the account in which to create the |
| 9387 | * new contact. |
| 9388 | * <p> |
| 9389 | * This value is optional - if it is not specified, the contact will be |
| 9390 | * created in the base account, with no data set. |
| 9391 | * <p> |
| 9392 | * Type: String |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9393 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9394 | public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9395 | } |
| 9396 | } |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9397 | |
| 9398 | /** |
| 9399 | * @hide |
| 9400 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9401 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9402 | protected interface MetadataSyncColumns { |
| 9403 | |
| 9404 | /** |
| 9405 | * The raw contact backup id. |
| 9406 | * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the |
| 9407 | * persistent unique id for each raw contact within its source system. |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9408 | */ |
| 9409 | public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id"; |
| 9410 | |
| 9411 | /** |
| 9412 | * The account type to which the raw_contact of this item is associated. See |
| 9413 | * {@link RawContacts#ACCOUNT_TYPE} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9414 | */ |
| 9415 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9416 | |
| 9417 | /** |
| 9418 | * The account name to which the raw_contact of this item is associated. See |
| 9419 | * {@link RawContacts#ACCOUNT_NAME} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9420 | */ |
| 9421 | public static final String ACCOUNT_NAME = "account_name"; |
| 9422 | |
| 9423 | /** |
| 9424 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 9425 | * multiple sync adapters for the same account type to distinguish between |
| 9426 | * each others' data. |
| 9427 | * {@link RawContacts#DATA_SET} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9428 | */ |
| 9429 | public static final String DATA_SET = "data_set"; |
| 9430 | |
| 9431 | /** |
| 9432 | * A text column contains the Json string got from People API. The Json string contains |
| 9433 | * all the metadata related to the raw contact, i.e., all the data fields and |
| 9434 | * aggregation exceptions. |
| 9435 | * |
| 9436 | * Here is an example of the Json string got from the actual schema. |
| 9437 | * <pre> |
| 9438 | * { |
| 9439 | * "unique_contact_id": { |
| 9440 | * "account_type": "CUSTOM_ACCOUNT", |
| 9441 | * "custom_account_type": "facebook", |
| 9442 | * "account_name": "android-test", |
| 9443 | * "contact_id": "1111111", |
| 9444 | * "data_set": "FOCUS" |
| 9445 | * }, |
| 9446 | * "contact_prefs": { |
| 9447 | * "send_to_voicemail": true, |
| 9448 | * "starred": false, |
| 9449 | * "pinned": 2 |
| 9450 | * }, |
| 9451 | * "aggregation_data": [ |
| 9452 | * { |
| 9453 | * "type": "TOGETHER", |
| 9454 | * "contact_ids": [ |
| 9455 | * { |
| 9456 | * "account_type": "GOOGLE_ACCOUNT", |
| 9457 | * "account_name": "android-test2", |
| 9458 | * "contact_id": "2222222", |
| 9459 | * "data_set": "GOOGLE_PLUS" |
| 9460 | * }, |
| 9461 | * { |
| 9462 | * "account_type": "GOOGLE_ACCOUNT", |
| 9463 | * "account_name": "android-test3", |
| 9464 | * "contact_id": "3333333", |
| 9465 | * "data_set": "CUSTOM", |
| 9466 | * "custom_data_set": "custom type" |
| 9467 | * } |
| 9468 | * ] |
| 9469 | * } |
| 9470 | * ], |
| 9471 | * "field_data": [ |
| 9472 | * { |
| 9473 | * "field_data_id": "1001", |
| 9474 | * "field_data_prefs": { |
| 9475 | * "is_primary": true, |
| 9476 | * "is_super_primary": true |
| 9477 | * }, |
| 9478 | * "usage_stats": [ |
| 9479 | * { |
| 9480 | * "usage_type": "CALL", |
| 9481 | * "last_time_used": 10000001, |
| 9482 | * "usage_count": 10 |
| 9483 | * } |
| 9484 | * ] |
| 9485 | * } |
| 9486 | * ] |
| 9487 | * } |
| 9488 | * </pre> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9489 | */ |
| 9490 | public static final String DATA = "data"; |
| 9491 | |
| 9492 | /** |
| 9493 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 9494 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 9495 | * called on a raw contact, updating MetadataSync table to set the flag of the raw contact |
| 9496 | * as "1", then metadata sync adapter deletes the raw contact metadata on the server. |
| 9497 | * <P>Type: INTEGER</P> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9498 | */ |
| 9499 | public static final String DELETED = "deleted"; |
| 9500 | } |
| 9501 | |
| 9502 | /** |
| 9503 | * Constants for the metadata sync table. This table is used to cache the metadata_sync data |
| 9504 | * from server before it is merged into other CP2 tables. |
| 9505 | * |
| 9506 | * @hide |
| 9507 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9508 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9509 | public static final class MetadataSync implements BaseColumns, MetadataSyncColumns { |
| 9510 | |
| 9511 | /** The authority for the contacts metadata */ |
| 9512 | public static final String METADATA_AUTHORITY = "com.android.contacts.metadata"; |
| 9513 | |
| 9514 | /** A content:// style uri to the authority for the contacts metadata */ |
| 9515 | public static final Uri METADATA_AUTHORITY_URI = Uri.parse( |
| 9516 | "content://" + METADATA_AUTHORITY); |
| 9517 | |
| 9518 | /** |
| 9519 | * This utility class cannot be instantiated |
| 9520 | */ |
| 9521 | private MetadataSync() { |
| 9522 | } |
| 9523 | |
| 9524 | /** |
| 9525 | * The content:// style URI for this table. |
| 9526 | */ |
| 9527 | public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI, |
| 9528 | "metadata_sync"); |
Zheng Fu | c37ba12 | 2015-04-23 16:46:45 -0700 | [diff] [blame] | 9529 | |
| 9530 | /** |
| 9531 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata |
| 9532 | */ |
| 9533 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata"; |
| 9534 | |
| 9535 | /** |
| 9536 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata. |
| 9537 | */ |
| 9538 | 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] | 9539 | } |
Zheng Fu | ae678b8 | 2015-08-07 13:28:50 -0700 | [diff] [blame] | 9540 | |
| 9541 | /** |
| 9542 | * @hide |
| 9543 | */ |
| 9544 | @SystemApi |
| 9545 | protected interface MetadataSyncStateColumns { |
| 9546 | |
| 9547 | /** |
| 9548 | * A reference to the name of the account to which this state belongs |
| 9549 | * <P>Type: STRING</P> |
| 9550 | */ |
| 9551 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9552 | |
| 9553 | /** |
| 9554 | * A reference to the type of the account to which this state belongs |
| 9555 | * <P>Type: STRING</P> |
| 9556 | */ |
| 9557 | public static final String ACCOUNT_NAME = "account_name"; |
| 9558 | |
| 9559 | /** |
| 9560 | * A reference to the data set within the account to which this state belongs |
| 9561 | * <P>Type: STRING</P> |
| 9562 | */ |
| 9563 | public static final String DATA_SET = "data_set"; |
| 9564 | |
| 9565 | /** |
| 9566 | * The sync state associated with this account. |
| 9567 | * <P>Type: Blob</P> |
| 9568 | */ |
| 9569 | public static final String STATE = "state"; |
| 9570 | } |
| 9571 | |
| 9572 | /** |
| 9573 | * Constants for the metadata_sync_state table. This table is used to store the metadata |
| 9574 | * sync state for a set of accounts. |
| 9575 | * |
| 9576 | * @hide |
| 9577 | */ |
| 9578 | @SystemApi |
| 9579 | public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns { |
| 9580 | |
| 9581 | /** |
| 9582 | * This utility class cannot be instantiated |
| 9583 | */ |
| 9584 | private MetadataSyncState() { |
| 9585 | } |
| 9586 | |
| 9587 | /** |
| 9588 | * The content:// style URI for this table. |
| 9589 | */ |
| 9590 | public static final Uri CONTENT_URI = |
| 9591 | Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state"); |
| 9592 | |
| 9593 | /** |
| 9594 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync |
| 9595 | * states. |
| 9596 | */ |
| 9597 | public static final String CONTENT_TYPE = |
| 9598 | "vnd.android.cursor.dir/contact_metadata_sync_state"; |
| 9599 | |
| 9600 | /** |
| 9601 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync |
| 9602 | * state. |
| 9603 | */ |
| 9604 | public static final String CONTENT_ITEM_TYPE = |
| 9605 | "vnd.android.cursor.item/contact_metadata_sync_state"; |
| 9606 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 9607 | } |