Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package android.provider; |
| 18 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 20 | import android.content.ContentProviderClient; |
| 21 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 22 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 23 | import android.content.ContentUris; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 24 | import android.content.Context; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 25 | import android.content.Intent; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 26 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 27 | import android.database.Cursor; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 28 | import android.graphics.BitmapFactory; |
| 29 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 30 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 31 | import android.text.TextUtils; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 32 | import android.util.Pair; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 33 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 34 | import java.io.ByteArrayInputStream; |
| 35 | import java.io.InputStream; |
| 36 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 37 | /** |
| 38 | * The contract between the contacts provider and applications. Contains definitions |
| 39 | * for the supported URIs and columns. |
| 40 | * |
Dmitri Plotnikov | 5f123bd | 2009-05-28 18:06:31 -0700 | [diff] [blame] | 41 | * @hide |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 42 | */ |
| 43 | public final class ContactsContract { |
| 44 | /** The authority for the contacts provider */ |
| 45 | public static final String AUTHORITY = "com.android.contacts"; |
| 46 | /** A content:// style uri to the authority for the contacts provider */ |
| 47 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 48 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 49 | /** |
| 50 | * An optional insert, update or delete URI parameter that allows the caller |
| 51 | * to specify that it is a sync adapter. The default value is false. If true |
| 52 | * the dirty flag is not automatically set and the "syncToNetwork" parameter |
| 53 | * is set to false when calling |
| 54 | * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 55 | */ |
| 56 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 57 | |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 58 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 59 | } |
| 60 | |
| 61 | public static final class SyncState { |
| 62 | /** |
| 63 | * This utility class cannot be instantiated |
| 64 | */ |
| 65 | private SyncState() {} |
| 66 | |
| 67 | public static final String CONTENT_DIRECTORY = |
| 68 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 69 | |
| 70 | /** |
| 71 | * The content:// style URI for this table |
| 72 | */ |
| 73 | public static final Uri CONTENT_URI = |
| 74 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 75 | |
| 76 | /** |
| 77 | * @see android.provider.SyncStateContract.Helpers#get |
| 78 | */ |
| 79 | public static byte[] get(ContentProviderClient provider, Account account) |
| 80 | throws RemoteException { |
| 81 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 82 | } |
| 83 | |
| 84 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 85 | * @see android.provider.SyncStateContract.Helpers#get |
| 86 | */ |
| 87 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 88 | throws RemoteException { |
| 89 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 90 | } |
| 91 | |
| 92 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 93 | * @see android.provider.SyncStateContract.Helpers#set |
| 94 | */ |
| 95 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 96 | throws RemoteException { |
| 97 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 102 | */ |
| 103 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 104 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 105 | } |
| 106 | } |
| 107 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Generic columns for use by sync adapters. The specific functions of |
| 110 | * these columns are private to the sync adapter. Other clients of the API |
| 111 | * should not attempt to either read or write this column. |
| 112 | */ |
| 113 | private interface BaseSyncColumns { |
| 114 | |
| 115 | /** Generic column for use by sync adapters. */ |
| 116 | public static final String SYNC1 = "sync1"; |
| 117 | /** Generic column for use by sync adapters. */ |
| 118 | public static final String SYNC2 = "sync2"; |
| 119 | /** Generic column for use by sync adapters. */ |
| 120 | public static final String SYNC3 = "sync3"; |
| 121 | /** Generic column for use by sync adapters. */ |
| 122 | public static final String SYNC4 = "sync4"; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Columns that appear when each row of a table belongs to a specific |
| 127 | * account, including sync information that an account may need. |
| 128 | */ |
| 129 | private interface SyncColumns extends BaseSyncColumns { |
| 130 | /** |
| 131 | * The name of the account instance to which this row belongs. |
| 132 | * <P>Type: TEXT</P> |
| 133 | */ |
| 134 | public static final String ACCOUNT_NAME = "account_name"; |
| 135 | |
| 136 | /** |
| 137 | * The type of account to which this row belongs, which when paired with |
| 138 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 139 | * <P>Type: TEXT</P> |
| 140 | */ |
| 141 | public static final String ACCOUNT_TYPE = "account_type"; |
| 142 | |
| 143 | /** |
| 144 | * String that uniquely identifies this row to its source account. |
| 145 | * <P>Type: TEXT</P> |
| 146 | */ |
| 147 | public static final String SOURCE_ID = "sourceid"; |
| 148 | |
| 149 | /** |
| 150 | * Version number that is updated whenever this row or its related data |
| 151 | * changes. |
| 152 | * <P>Type: INTEGER</P> |
| 153 | */ |
| 154 | public static final String VERSION = "version"; |
| 155 | |
| 156 | /** |
| 157 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 158 | * to be synchronized by its owning account. |
| 159 | * <P>Type: INTEGER (boolean)</P> |
| 160 | */ |
| 161 | public static final String DIRTY = "dirty"; |
| 162 | } |
| 163 | |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 164 | public interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 165 | /** |
| 166 | * The number of times a person has been contacted |
| 167 | * <P>Type: INTEGER</P> |
| 168 | */ |
| 169 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 170 | |
| 171 | /** |
| 172 | * The last time a person was contacted. |
| 173 | * <P>Type: INTEGER</P> |
| 174 | */ |
| 175 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 176 | |
| 177 | /** |
| 178 | * Is the contact starred? |
| 179 | * <P>Type: INTEGER (boolean)</P> |
| 180 | */ |
| 181 | public static final String STARRED = "starred"; |
| 182 | |
| 183 | /** |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 184 | * A custom ringtone associated with a person. Not always present. |
| 185 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 186 | */ |
| 187 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 188 | |
| 189 | /** |
| 190 | * Whether the person should always be sent to voicemail. Not always |
| 191 | * present. |
| 192 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 193 | */ |
| 194 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 197 | private interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 198 | /** |
| 199 | * The display name for the contact. |
| 200 | * <P>Type: TEXT</P> |
| 201 | */ |
| 202 | public static final String DISPLAY_NAME = "display_name"; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 203 | |
| 204 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 205 | * Reference to the row in the data table holding the photo. |
| 206 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 207 | */ |
| 208 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 209 | |
| 210 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 211 | * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 212 | * any {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 213 | */ |
| 214 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 215 | |
| 216 | /** |
| 217 | * Contact presence status. See {@link android.provider.Im.CommonPresenceColumns} |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 218 | * for individual status definitions. This column is only returned if explicitly |
| 219 | * requested in the query projection. |
| 220 | * <p>Type: NUMBER</p> |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 221 | */ |
| 222 | public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS; |
| 223 | |
| 224 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 225 | * Contact presence custom status. This column is only returned if explicitly |
| 226 | * requested in the query projection. |
| 227 | * <p>Type: TEXT</p> |
| 228 | */ |
| 229 | public static final String PRESENCE_CUSTOM_STATUS = Presence.PRESENCE_CUSTOM_STATUS; |
| 230 | |
| 231 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 232 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 233 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 234 | * <P>Type: INTEGER</P> |
| 235 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 236 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * An opaque value that contains hints on how to find the contact if |
| 240 | * its row id changed as a result of a sync or aggregation. |
| 241 | */ |
| 242 | public static final String LOOKUP_KEY = "lookup"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 246 | * Constants for the contacts table, which contains a record per group |
| 247 | * of raw contact representing the same person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 248 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 249 | public static class Contacts implements BaseColumns, ContactsColumns, |
Dmitri Plotnikov | c9ec66b | 2009-08-05 12:11:22 -0700 | [diff] [blame] | 250 | ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 251 | /** |
| 252 | * This utility class cannot be instantiated |
| 253 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 254 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 255 | |
| 256 | /** |
| 257 | * The content:// style URI for this table |
| 258 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 259 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 260 | |
| 261 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 262 | * A content:// style URI for this table that should be used to create |
| 263 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 264 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 265 | * It can optionally also have a "/" and last known contact ID appended after |
| 266 | * that. This "complete" format is an important optimization and is highly recommended. |
| 267 | * <p> |
| 268 | * As long as the contact's row ID remains the same, this URI is |
| 269 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 270 | * as a result of a sync or aggregation, this URI will look up the |
| 271 | * contact using indirect information (sync IDs or constituent raw |
| 272 | * contacts). |
| 273 | * <p> |
| 274 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 275 | * form, ready for use in a URI. |
| 276 | */ |
| 277 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 278 | "lookup"); |
| 279 | |
| 280 | /** |
| 281 | * Computes a complete lookup URI (see {@link #CONTENT_LOOKUP_URI}). |
| 282 | * Pass either a basic content URI with a contact ID to obtain an |
| 283 | * equivalent lookup URI. Pass a possibly stale lookup URI to get a fresh |
| 284 | * lookup URI for the same contact. |
| 285 | * <p> |
| 286 | * Returns null if the contact cannot be found. |
| 287 | */ |
| 288 | public static Uri getLookupUri(ContentResolver resolver, Uri contentUri) { |
| 289 | Cursor c = resolver.query(contentUri, |
| 290 | new String[]{Contacts.LOOKUP_KEY, Contacts._ID}, null, null, null); |
| 291 | if (c == null) { |
| 292 | return null; |
| 293 | } |
| 294 | |
| 295 | try { |
| 296 | if (c.moveToFirst()) { |
| 297 | String lookupKey = c.getString(0); |
| 298 | long contactId = c.getLong(1); |
| 299 | return ContentUris.withAppendedId( |
| 300 | Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), |
| 301 | contactId); |
| 302 | } |
| 303 | } finally { |
| 304 | c.close(); |
| 305 | } |
| 306 | return null; |
| 307 | } |
| 308 | |
| 309 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 310 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
| 311 | * given {@link Contacts#_ID} and {@link Contacts#LOOKUP_KEY}. |
| 312 | */ |
| 313 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 314 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 315 | lookupKey), contactId); |
| 316 | } |
| 317 | |
| 318 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 319 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 320 | * <p> |
| 321 | * Returns null if the contact cannot be found. |
| 322 | */ |
| 323 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 324 | if (lookupUri == null) { |
| 325 | return null; |
| 326 | } |
| 327 | |
| 328 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 329 | if (c == null) { |
| 330 | return null; |
| 331 | } |
| 332 | |
| 333 | try { |
| 334 | if (c.moveToFirst()) { |
| 335 | long contactId = c.getLong(0); |
| 336 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 337 | } |
| 338 | } finally { |
| 339 | c.close(); |
| 340 | } |
| 341 | return null; |
| 342 | } |
| 343 | |
| 344 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 345 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 346 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 347 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 348 | * as an additional path segment after this URI. |
| 349 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 350 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 351 | CONTENT_URI, "filter"); |
| 352 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 353 | /** |
| 354 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 355 | * {@link Data}, filtered to include only starred contacts |
| 356 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 357 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 358 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 359 | CONTENT_URI, "strequent"); |
| 360 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 361 | /** |
| 362 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 363 | * {@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] | 364 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 365 | * as an additional path segment after this URI. |
| 366 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 367 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 368 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 369 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 370 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 371 | CONTENT_URI, "group"); |
| 372 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 373 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 374 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 375 | * people. |
| 376 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 377 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 378 | |
| 379 | /** |
| 380 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 381 | * person. |
| 382 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 383 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 384 | |
| 385 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 386 | * A sub-directory of a single contact that contains all of the constituent raw contact |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 387 | * {@link Data} rows. |
| 388 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 389 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 390 | /** |
| 391 | * no public constructor since this is a utility class |
| 392 | */ |
| 393 | private Data() {} |
| 394 | |
| 395 | /** |
| 396 | * The directory twig for this sub-table |
| 397 | */ |
| 398 | public static final String CONTENT_DIRECTORY = "data"; |
| 399 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 400 | |
| 401 | /** |
| 402 | * A sub-directory of a single contact aggregate that contains all aggregation suggestions |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 403 | * (other contacts). The aggregation suggestions are computed based on approximate |
| 404 | * data matches with this contact. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 405 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 406 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 407 | /** |
| 408 | * No public constructor since this is a utility class |
| 409 | */ |
| 410 | private AggregationSuggestions() {} |
| 411 | |
| 412 | /** |
| 413 | * The directory twig for this sub-table |
| 414 | */ |
| 415 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 416 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 417 | |
| 418 | /** |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 419 | * A sub-directory of a single contact that contains the contact's primary photo. |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 420 | */ |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 421 | public static final class Photo implements BaseColumns, DataColumns { |
| 422 | /** |
| 423 | * no public constructor since this is a utility class |
| 424 | */ |
| 425 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 426 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 427 | /** |
| 428 | * The directory twig for this sub-table |
| 429 | */ |
| 430 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Opens an InputStream for the person's default photo and returns the |
| 435 | * photo as a Bitmap stream. |
| 436 | * |
| 437 | * @param contactUri the contact whose photo should be used |
| 438 | */ |
| 439 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 440 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 441 | if (photoUri == null) { |
| 442 | return null; |
| 443 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 444 | Cursor cursor = cr.query(photoUri, |
| 445 | new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); |
| 446 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 447 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 448 | return null; |
| 449 | } |
| 450 | byte[] data = cursor.getBlob(0); |
| 451 | if (data == null) { |
| 452 | return null; |
| 453 | } |
| 454 | return new ByteArrayInputStream(data); |
| 455 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 456 | if (cursor != null) { |
| 457 | cursor.close(); |
| 458 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 459 | } |
| 460 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 461 | } |
| 462 | |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 463 | private interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 464 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 465 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this |
| 466 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 467 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 468 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 469 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 470 | |
| 471 | /** |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 472 | * Flag indicating that this {@link RawContacts} entry and its children has |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 473 | * been restricted to specific platform apps. |
| 474 | * <P>Type: INTEGER (boolean)</P> |
| 475 | * |
| 476 | * @hide until finalized in future platform release |
| 477 | */ |
| 478 | public static final String IS_RESTRICTED = "is_restricted"; |
| 479 | |
| 480 | /** |
| 481 | * The aggregation mode for this contact. |
| 482 | * <P>Type: INTEGER</P> |
| 483 | */ |
| 484 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 485 | |
| 486 | /** |
| 487 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 488 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 489 | * 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] | 490 | * 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] | 491 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 492 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 493 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 494 | * <P>Type: INTEGER</P> |
| 495 | */ |
| 496 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | /** |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 500 | * Constants for the raw_contacts table, which contains the base contact |
| 501 | * information per sync source. Sync adapters and contact management apps |
| 502 | * are the primary consumers of this API. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 503 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 504 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 505 | ContactOptionsColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 506 | /** |
| 507 | * This utility class cannot be instantiated |
| 508 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 509 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 513 | * The content:// style URI for this table |
| 514 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 515 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 516 | |
| 517 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 518 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 519 | * people. |
| 520 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 521 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 522 | |
| 523 | /** |
| 524 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 525 | * person. |
| 526 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 527 | 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] | 528 | |
| 529 | /** |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 530 | * Aggregation mode: aggregate asynchronously. |
| 531 | */ |
| 532 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 533 | |
| 534 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 535 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 536 | */ |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 537 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 538 | |
| 539 | /** |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 540 | * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes |
| 541 | * to the raw contact do not cause its aggregation to be revisited. Note that changing |
| 542 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
| 543 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent |
| 544 | * change to the raw contact's data will. |
| 545 | */ |
| 546 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 547 | |
| 548 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 549 | * Aggregation mode: never aggregate this raw contact (note that the raw contact will not |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 550 | * have a corresponding Aggregate and therefore will not be included in Aggregates |
| 551 | * query results.) |
| 552 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 553 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 554 | |
| 555 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 556 | * A sub-directory of a single raw contact that contains all of their {@link Data} rows. |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 557 | * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 558 | */ |
| 559 | public static final class Data implements BaseColumns, DataColumns { |
| 560 | /** |
| 561 | * no public constructor since this is a utility class |
| 562 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 563 | private Data() { |
| 564 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 565 | |
| 566 | /** |
| 567 | * The directory twig for this sub-table |
| 568 | */ |
| 569 | public static final String CONTENT_DIRECTORY = "data"; |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | private interface DataColumns { |
| 574 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 575 | * The package name to use when creating {@link Resources} objects for |
| 576 | * this data row. This value is only designed for use when building user |
| 577 | * interfaces, and should not be used to infer the owner. |
| 578 | */ |
| 579 | public static final String RES_PACKAGE = "res_package"; |
| 580 | |
| 581 | /** |
| 582 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 583 | */ |
| 584 | public static final String MIMETYPE = "mimetype"; |
| 585 | |
| 586 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 587 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 588 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 589 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 590 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 591 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 592 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 593 | * 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] | 594 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 595 | */ |
| 596 | public static final String IS_PRIMARY = "is_primary"; |
| 597 | |
| 598 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 599 | * Whether this is the primary entry of its kind for the aggregate |
| 600 | * contact it belongs to. Any data record that is "super primary" must |
| 601 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 602 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 603 | */ |
| 604 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 605 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 606 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 607 | * The version of this data record. This is a read-only value. The data column is |
| 608 | * guaranteed to not change without the version going up. This value is monotonically |
| 609 | * increasing. |
| 610 | * <P>Type: INTEGER</P> |
| 611 | */ |
| 612 | public static final String DATA_VERSION = "data_version"; |
| 613 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 614 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 615 | public static final String DATA1 = "data1"; |
| 616 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 617 | public static final String DATA2 = "data2"; |
| 618 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 619 | public static final String DATA3 = "data3"; |
| 620 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 621 | public static final String DATA4 = "data4"; |
| 622 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 623 | public static final String DATA5 = "data5"; |
| 624 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 625 | public static final String DATA6 = "data6"; |
| 626 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 627 | public static final String DATA7 = "data7"; |
| 628 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 629 | public static final String DATA8 = "data8"; |
| 630 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 631 | public static final String DATA9 = "data9"; |
| 632 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 633 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 634 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 635 | public static final String DATA11 = "data11"; |
| 636 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 637 | public static final String DATA12 = "data12"; |
| 638 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 639 | public static final String DATA13 = "data13"; |
| 640 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 641 | public static final String DATA14 = "data14"; |
| 642 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 643 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 644 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 645 | /** Generic column for use by sync adapters. */ |
| 646 | public static final String SYNC1 = "data_sync1"; |
| 647 | /** Generic column for use by sync adapters. */ |
| 648 | public static final String SYNC2 = "data_sync2"; |
| 649 | /** Generic column for use by sync adapters. */ |
| 650 | public static final String SYNC3 = "data_sync3"; |
| 651 | /** Generic column for use by sync adapters. */ |
| 652 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 656 | * Constants for the data table, which contains data points tied to a raw contact. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 657 | * For example, a phone number or email address. Each row in this table contains a type |
| 658 | * definition and some generic columns. Each data type can define the meaning for each of |
| 659 | * the generic columns. |
| 660 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 661 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 662 | /** |
| 663 | * This utility class cannot be instantiated |
| 664 | */ |
| 665 | private Data() {} |
| 666 | |
| 667 | /** |
| 668 | * The content:// style URI for this table |
| 669 | */ |
| 670 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 671 | |
| 672 | /** |
Jeff Sharkey | 0c36a51 | 2009-09-02 23:16:44 -0700 | [diff] [blame] | 673 | * The content:// style URI for this table joined with {@link Presence} |
| 674 | * data where applicable. |
| 675 | * |
| 676 | * @hide |
| 677 | */ |
| 678 | public static final Uri CONTENT_WITH_PRESENCE_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 679 | "data_with_presence"); |
| 680 | |
| 681 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 682 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 683 | */ |
| 684 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
| 685 | } |
| 686 | |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 687 | private interface PhoneLookupColumns { |
| 688 | /** |
| 689 | * The phone number as the user entered it. |
| 690 | * <P>Type: TEXT</P> |
| 691 | */ |
| 692 | public static final String NUMBER = "number"; |
| 693 | |
| 694 | /** |
| 695 | * The type of phone number, for example Home or Work. |
| 696 | * <P>Type: INTEGER</P> |
| 697 | */ |
| 698 | public static final String TYPE = "type"; |
| 699 | |
| 700 | /** |
| 701 | * The user defined label for the phone number. |
| 702 | * <P>Type: TEXT</P> |
| 703 | */ |
| 704 | public static final String LABEL = "label"; |
| 705 | } |
| 706 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 707 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 708 | * 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] | 709 | * example for caller ID. To perform a lookup you must append the number you |
| 710 | * want to find to {@link #CONTENT_FILTER_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 711 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 712 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 713 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 714 | /** |
| 715 | * This utility class cannot be instantiated |
| 716 | */ |
| 717 | private PhoneLookup() {} |
| 718 | |
| 719 | /** |
| 720 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 721 | * to this URI and query it to perform a lookup. For example: |
| 722 | * |
| 723 | * {@code |
| 724 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber); |
| 725 | * } |
| 726 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 727 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 728 | "phone_lookup"); |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Additional data mixed in with {@link Im.CommonPresenceColumns} to link |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 733 | * back to specific {@link ContactsContract.Contacts#_ID} entries. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 734 | */ |
| 735 | private interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 736 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 737 | /** |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 738 | * The unique ID for a row. |
| 739 | * <P>Type: INTEGER (long)</P> |
| 740 | */ |
| 741 | public static final String _ID = "presence_id"; |
| 742 | |
| 743 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 744 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 745 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 746 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 747 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 748 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 749 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 750 | * <p>Type: NUMBER</p> |
| 751 | */ |
| 752 | public static final String PROTOCOL = "protocol"; |
| 753 | |
| 754 | /** |
| 755 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 756 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 757 | * omitted if {@link #PROTOCOL} value is not |
| 758 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 759 | * |
| 760 | * <p>Type: NUMBER</p> |
| 761 | */ |
| 762 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 763 | |
| 764 | /** |
| 765 | * The IM handle the presence item is for. The handle is scoped to |
| 766 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 767 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 768 | */ |
| 769 | public static final String IM_HANDLE = "im_handle"; |
| 770 | |
| 771 | /** |
| 772 | * 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] | 773 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 774 | */ |
| 775 | public static final String IM_ACCOUNT = "im_account"; |
| 776 | } |
| 777 | |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 778 | public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns { |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 779 | /** |
| 780 | * This utility class cannot be instantiated |
| 781 | */ |
| 782 | private Presence() { |
| 783 | } |
| 784 | |
| 785 | /** |
| 786 | * The content:// style URI for this table |
| 787 | */ |
| 788 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence"); |
| 789 | |
| 790 | /** |
| 791 | * Gets the resource ID for the proper presence icon. |
| 792 | * |
| 793 | * @param status the status to get the icon for |
| 794 | * @return the resource ID for the proper presence icon |
| 795 | */ |
| 796 | public static final int getPresenceIconResourceId(int status) { |
| 797 | switch (status) { |
| 798 | case AVAILABLE: |
| 799 | return android.R.drawable.presence_online; |
| 800 | case IDLE: |
| 801 | case AWAY: |
| 802 | return android.R.drawable.presence_away; |
| 803 | case DO_NOT_DISTURB: |
| 804 | return android.R.drawable.presence_busy; |
| 805 | case INVISIBLE: |
| 806 | return android.R.drawable.presence_invisible; |
| 807 | case OFFLINE: |
| 808 | default: |
| 809 | return android.R.drawable.presence_offline; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 814 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 815 | * |
| 816 | * @param status The status code. |
| 817 | * @return An integer representing the precedence, 0 being the lowest. |
| 818 | */ |
| 819 | public static final int getPresencePrecedence(int status) { |
| 820 | // Keep this function here incase we want to enforce a different precedence than the |
| 821 | // natural order of the status constants. |
| 822 | return status; |
| 823 | } |
| 824 | |
| 825 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 826 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 827 | * presence details. |
| 828 | */ |
| 829 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence"; |
| 830 | |
| 831 | /** |
| 832 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 833 | * presence detail. |
| 834 | */ |
| 835 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | /** |
| 839 | * Container for definitions of common data types stored in the {@link Data} table. |
| 840 | */ |
| 841 | public static final class CommonDataKinds { |
| 842 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 843 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 844 | * shown using a default style. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 845 | */ |
| 846 | public static final String PACKAGE_COMMON = "common"; |
| 847 | |
| 848 | /** |
| 849 | * Columns common across the specific types. |
| 850 | */ |
| 851 | private interface BaseCommonColumns { |
| 852 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 853 | * The package name to use when creating {@link Resources} objects for |
| 854 | * this data row. This value is only designed for use when building user |
| 855 | * interfaces, and should not be used to infer the owner. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 856 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 857 | public static final String RES_PACKAGE = "res_package"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 858 | |
| 859 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 860 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 861 | */ |
| 862 | public static final String MIMETYPE = "mimetype"; |
| 863 | |
| 864 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 865 | * The {@link RawContacts#_ID} that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 866 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 867 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 871 | * The base types that all "Typed" data kinds support. |
| 872 | */ |
| 873 | public interface BaseTypes { |
| 874 | |
| 875 | /** |
| 876 | * A custom type. The custom label should be supplied by user. |
| 877 | */ |
| 878 | public static int TYPE_CUSTOM = 0; |
| 879 | } |
| 880 | |
| 881 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 882 | * Columns common across the specific types. |
| 883 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 884 | private interface CommonColumns extends BaseTypes{ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 885 | /** |
| 886 | * The type of data, for example Home or Work. |
| 887 | * <P>Type: INTEGER</P> |
| 888 | */ |
| 889 | public static final String TYPE = "data1"; |
| 890 | |
| 891 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 892 | * The data for the contact method. |
| 893 | * <P>Type: TEXT</P> |
| 894 | */ |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 895 | public static final String DATA = "data2"; |
| 896 | |
| 897 | /** |
| 898 | * The user defined label for the the contact method. |
| 899 | * <P>Type: TEXT</P> |
| 900 | */ |
| 901 | public static final String LABEL = "data3"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | /** |
| 905 | * Parts of the name. |
| 906 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 907 | public static final class StructuredName implements BaseCommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 908 | private StructuredName() {} |
| 909 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 910 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 911 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 912 | |
| 913 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 914 | * The given name for the contact. |
| 915 | * <P>Type: TEXT</P> |
| 916 | */ |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 917 | public static final String GIVEN_NAME = "data1"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 918 | |
| 919 | /** |
| 920 | * The family name for the contact. |
| 921 | * <P>Type: TEXT</P> |
| 922 | */ |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 923 | public static final String FAMILY_NAME = "data2"; |
| 924 | |
| 925 | /** |
| 926 | * The contact's honorific prefix, e.g. "Sir" |
| 927 | * <P>Type: TEXT</P> |
| 928 | */ |
| 929 | public static final String PREFIX = "data3"; |
| 930 | |
| 931 | /** |
| 932 | * The contact's middle name |
| 933 | * <P>Type: TEXT</P> |
| 934 | */ |
| 935 | public static final String MIDDLE_NAME = "data4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 936 | |
| 937 | /** |
| 938 | * The contact's honorific suffix, e.g. "Jr" |
| 939 | */ |
| 940 | public static final String SUFFIX = "data5"; |
| 941 | |
| 942 | /** |
| 943 | * The phonetic version of the given name for the contact. |
| 944 | * <P>Type: TEXT</P> |
| 945 | */ |
| 946 | public static final String PHONETIC_GIVEN_NAME = "data6"; |
| 947 | |
| 948 | /** |
| 949 | * The phonetic version of the additional name for the contact. |
| 950 | * <P>Type: TEXT</P> |
| 951 | */ |
| 952 | public static final String PHONETIC_MIDDLE_NAME = "data7"; |
| 953 | |
| 954 | /** |
| 955 | * The phonetic version of the family name for the contact. |
| 956 | * <P>Type: TEXT</P> |
| 957 | */ |
| 958 | public static final String PHONETIC_FAMILY_NAME = "data8"; |
| 959 | |
| 960 | /** |
| 961 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 962 | * <i>Unstructured component of the name should be consistent with |
| 963 | * its structured representation.</i> |
| 964 | * <p> |
| 965 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 966 | */ |
| 967 | public static final String DISPLAY_NAME = "data9"; |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * A nickname. |
| 972 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 973 | public static final class Nickname implements CommonColumns, BaseCommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 974 | private Nickname() {} |
| 975 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 976 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 977 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 978 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 979 | public static final int TYPE_DEFAULT = 1; |
| 980 | public static final int TYPE_OTHER_NAME = 2; |
| 981 | public static final int TYPE_MAINDEN_NAME = 3; |
| 982 | public static final int TYPE_SHORT_NAME = 4; |
| 983 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 984 | |
| 985 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 986 | * The name itself |
| 987 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 988 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | /** |
| 992 | * Common data definition for telephone numbers. |
| 993 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 994 | public static final class Phone implements BaseCommonColumns, CommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 995 | private Phone() {} |
| 996 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 997 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 998 | 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] | 999 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1000 | /** |
| 1001 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1002 | * phones. |
| 1003 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1004 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1005 | |
| 1006 | /** |
| 1007 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1008 | * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1009 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1010 | */ |
| 1011 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1012 | "phones"); |
| 1013 | |
| 1014 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1015 | * The content:// style URL for phone lookup using a filter. The filter returns |
| 1016 | * records of MIME type {@link Phone#CONTENT_ITEM_TYPE}. The filter is applied |
| 1017 | * to display names as well as phone numbers. The filter argument should be passed |
| 1018 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1019 | */ |
| 1020 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1021 | "filter"); |
| 1022 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1023 | public static final int TYPE_HOME = 1; |
| 1024 | public static final int TYPE_MOBILE = 2; |
| 1025 | public static final int TYPE_WORK = 3; |
| 1026 | public static final int TYPE_FAX_WORK = 4; |
| 1027 | public static final int TYPE_FAX_HOME = 5; |
| 1028 | public static final int TYPE_PAGER = 6; |
| 1029 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 1030 | public static final int TYPE_CALLBACK = 8; |
| 1031 | public static final int TYPE_CAR = 9; |
| 1032 | public static final int TYPE_COMPANY_MAIN = 10; |
| 1033 | public static final int TYPE_ISDN = 11; |
| 1034 | public static final int TYPE_MAIN = 12; |
| 1035 | public static final int TYPE_OTHER_FAX = 13; |
| 1036 | public static final int TYPE_RADIO = 14; |
| 1037 | public static final int TYPE_TELEX = 15; |
| 1038 | public static final int TYPE_TTY_TDD = 16; |
| 1039 | public static final int TYPE_WORK_MOBILE = 17; |
| 1040 | public static final int TYPE_WORK_PAGER = 18; |
| 1041 | public static final int TYPE_ASSISTANT = 19; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1042 | |
| 1043 | /** |
| 1044 | * The phone number as the user entered it. |
| 1045 | * <P>Type: TEXT</P> |
| 1046 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1047 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1048 | |
| 1049 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 1050 | CharSequence label, CharSequence[] labelArray) { |
| 1051 | CharSequence display = ""; |
| 1052 | |
| 1053 | if (type != Phone.TYPE_CUSTOM) { |
| 1054 | CharSequence[] labels = labelArray != null? labelArray |
| 1055 | : context.getResources().getTextArray( |
| 1056 | com.android.internal.R.array.phoneTypes); |
| 1057 | try { |
| 1058 | display = labels[type - 1]; |
| 1059 | } catch (ArrayIndexOutOfBoundsException e) { |
| 1060 | display = labels[Phone.TYPE_CUSTOM]; |
| 1061 | } |
| 1062 | } else { |
| 1063 | if (!TextUtils.isEmpty(label)) { |
| 1064 | display = label; |
| 1065 | } |
| 1066 | } |
| 1067 | return display; |
| 1068 | } |
| 1069 | |
| 1070 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 1071 | CharSequence label) { |
| 1072 | return getDisplayLabel(context, type, label, null); |
| 1073 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | /** |
| 1077 | * Common data definition for email addresses. |
| 1078 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1079 | public static final class Email implements BaseCommonColumns, CommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1080 | private Email() {} |
| 1081 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1082 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1083 | 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] | 1084 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1085 | /** |
| 1086 | * The content:// style URI for all data records of the |
| 1087 | * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the |
| 1088 | * associated raw contact and aggregate contact data. |
| 1089 | */ |
| 1090 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1091 | "emails"); |
| 1092 | |
| 1093 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1094 | * The content:// style URL for looking up data rows by email address. The |
| 1095 | * lookup argument, an email address, should be passed as an additional path segment |
| 1096 | * after this URI. |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1097 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1098 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1099 | "lookup"); |
| 1100 | |
| 1101 | @Deprecated |
| 1102 | public static final Uri CONTENT_FILTER_EMAIL_URI = CONTENT_LOOKUP_URI; |
| 1103 | |
| 1104 | /** |
| 1105 | * The content:// style URL for email lookup using a filter. The filter returns |
| 1106 | * records of MIME type {@link Email#CONTENT_ITEM_TYPE}. The filter is applied |
| 1107 | * to display names as well as email addresses. The filter argument should be passed |
| 1108 | * as an additional path segment after this URI. |
| 1109 | */ |
| 1110 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1111 | "filter"); |
| 1112 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1113 | public static final int TYPE_HOME = 1; |
| 1114 | public static final int TYPE_WORK = 2; |
| 1115 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 1116 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1117 | |
| 1118 | /** |
| 1119 | * The display name for the email address |
| 1120 | * <P>Type: TEXT</P> |
| 1121 | */ |
| 1122 | public static final String DISPLAY_NAME = "data4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1123 | } |
| 1124 | |
| 1125 | /** |
| 1126 | * Common data definition for postal addresses. |
| 1127 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1128 | public static final class StructuredPostal implements BaseCommonColumns, CommonColumns { |
| 1129 | private StructuredPostal() { |
| 1130 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1131 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1132 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1133 | public static final String CONTENT_ITEM_TYPE = |
| 1134 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1135 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1136 | /** |
| 1137 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1138 | * postal addresses. |
| 1139 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1140 | 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] | 1141 | |
| 1142 | /** |
| 1143 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1144 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1145 | */ |
| 1146 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1147 | "postals"); |
| 1148 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1149 | public static final int TYPE_HOME = 1; |
| 1150 | public static final int TYPE_WORK = 2; |
| 1151 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1152 | |
| 1153 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 1154 | * The full, unstructured postal address. <i>This field must be |
| 1155 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1156 | * <p> |
| 1157 | * Type: TEXT |
| 1158 | */ |
| 1159 | public static final String FORMATTED_ADDRESS = DATA; |
| 1160 | |
| 1161 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1162 | * Can be street, avenue, road, etc. This element also includes the |
| 1163 | * house number and room/apartment/flat/floor number. |
| 1164 | * <p> |
| 1165 | * Type: TEXT |
| 1166 | */ |
| 1167 | public static final String STREET = "data6"; |
| 1168 | |
| 1169 | /** |
| 1170 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 1171 | * usually but not always mutually exclusive with street. |
| 1172 | * <p> |
| 1173 | * Type: TEXT |
| 1174 | */ |
| 1175 | public static final String POBOX = "data7"; |
| 1176 | |
| 1177 | /** |
| 1178 | * This is used to disambiguate a street address when a city |
| 1179 | * contains more than one street with the same name, or to specify a |
| 1180 | * small place whose mail is routed through a larger postal town. In |
| 1181 | * China it could be a county or a minor city. |
| 1182 | * <p> |
| 1183 | * Type: TEXT |
| 1184 | */ |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 1185 | public static final String NEIGHBORHOOD = "data8"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1186 | |
| 1187 | /** |
| 1188 | * Can be city, village, town, borough, etc. This is the postal town |
| 1189 | * and not necessarily the place of residence or place of business. |
| 1190 | * <p> |
| 1191 | * Type: TEXT |
| 1192 | */ |
| 1193 | public static final String CITY = "data9"; |
| 1194 | |
| 1195 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1196 | * A state, province, county (in Ireland), Land (in Germany), |
| 1197 | * departement (in France), etc. |
| 1198 | * <p> |
| 1199 | * Type: TEXT |
| 1200 | */ |
| 1201 | public static final String REGION = "data11"; |
| 1202 | |
| 1203 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 1204 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1205 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 1206 | * <p> |
| 1207 | * Type: TEXT |
| 1208 | */ |
| 1209 | public static final String POSTCODE = "data12"; |
| 1210 | |
| 1211 | /** |
| 1212 | * The name or code of the country. |
| 1213 | * <p> |
| 1214 | * Type: TEXT |
| 1215 | */ |
| 1216 | public static final String COUNTRY = "data13"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1217 | } |
| 1218 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1219 | /** |
| 1220 | * Common data definition for IM addresses. |
| 1221 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1222 | public static final class Im implements BaseCommonColumns, CommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1223 | private Im() {} |
| 1224 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1225 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1226 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 1227 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1228 | public static final int TYPE_HOME = 1; |
| 1229 | public static final int TYPE_WORK = 2; |
| 1230 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1231 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1232 | /** |
| 1233 | * This column should be populated with one of the defined |
| 1234 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 1235 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 1236 | * should contain the name of the custom protocol. |
| 1237 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1238 | public static final String PROTOCOL = "data5"; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1239 | |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 1240 | public static final String CUSTOM_PROTOCOL = "data6"; |
| 1241 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1242 | /* |
| 1243 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1244 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 1245 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1246 | public static final int PROTOCOL_AIM = 0; |
| 1247 | public static final int PROTOCOL_MSN = 1; |
| 1248 | public static final int PROTOCOL_YAHOO = 2; |
| 1249 | public static final int PROTOCOL_SKYPE = 3; |
| 1250 | public static final int PROTOCOL_QQ = 4; |
| 1251 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 1252 | public static final int PROTOCOL_ICQ = 6; |
| 1253 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1254 | public static final int PROTOCOL_NETMEETING = 8; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | /** |
| 1258 | * Common data definition for organizations. |
| 1259 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1260 | public static final class Organization implements BaseCommonColumns, CommonColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1261 | private Organization() {} |
| 1262 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1263 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1264 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 1265 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1266 | public static final int TYPE_WORK = 1; |
| 1267 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1268 | |
| 1269 | /** |
| 1270 | * The company as the user entered it. |
| 1271 | * <P>Type: TEXT</P> |
| 1272 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1273 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1274 | |
| 1275 | /** |
| 1276 | * The position title at this company as the user entered it. |
| 1277 | * <P>Type: TEXT</P> |
| 1278 | */ |
| 1279 | public static final String TITLE = "data4"; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1280 | |
| 1281 | /** |
| 1282 | * The department at this company as the user entered it. |
| 1283 | * <P>Type: TEXT</P> |
| 1284 | */ |
| 1285 | public static final String DEPARTMENT = "data5"; |
| 1286 | |
| 1287 | /** |
| 1288 | * The job description at this company as the user entered it. |
| 1289 | * <P>Type: TEXT</P> |
| 1290 | */ |
| 1291 | public static final String JOB_DESCRIPTION = "data6"; |
| 1292 | |
| 1293 | /** |
| 1294 | * The symbol of this company as the user entered it. |
| 1295 | * <P>Type: TEXT</P> |
| 1296 | */ |
| 1297 | public static final String SYMBOL = "data7"; |
| 1298 | |
| 1299 | /** |
| 1300 | * The phonetic name of this company as the user entered it. |
| 1301 | * <P>Type: TEXT</P> |
| 1302 | */ |
| 1303 | public static final String PHONETIC_NAME = "data8"; |
| 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * Common data definition for miscellaneous information. |
| 1308 | */ |
| 1309 | public static final class Miscellaneous implements BaseCommonColumns { |
| 1310 | private Miscellaneous() {} |
| 1311 | |
| 1312 | /** MIME type used when storing this in data table. */ |
| 1313 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc"; |
| 1314 | |
| 1315 | /** |
| 1316 | * The birthday as the user entered it. |
| 1317 | * <P>Type: TEXT</P> |
| 1318 | */ |
| 1319 | public static final String BIRTHDAY = "data1"; |
| 1320 | |
| 1321 | /** |
| 1322 | * The nickname as the user entered it. |
| 1323 | * <P>Type: TEXT</P> |
| 1324 | */ |
| 1325 | public static final String NICKNAME = "data2"; |
| 1326 | } |
| 1327 | |
| 1328 | /** |
| 1329 | * Common data definition for relations. |
| 1330 | */ |
| 1331 | public static final class Relation implements BaseCommonColumns, CommonColumns { |
| 1332 | private Relation() {} |
| 1333 | |
| 1334 | /** MIME type used when storing this in data table. */ |
| 1335 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 1336 | |
| 1337 | public static final int TYPE_ASSISTANT = 1; |
| 1338 | public static final int TYPE_BROTHER = 2; |
| 1339 | public static final int TYPE_CHILD = 3; |
| 1340 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 1341 | public static final int TYPE_FATHER = 5; |
| 1342 | public static final int TYPE_FRIEND = 6; |
| 1343 | public static final int TYPE_MANAGER = 7; |
| 1344 | public static final int TYPE_MOTHER = 8; |
| 1345 | public static final int TYPE_PARENT = 9; |
| 1346 | public static final int TYPE_PARTNER = 10; |
| 1347 | public static final int TYPE_REFERRED_BY = 11; |
| 1348 | public static final int TYPE_RELATIVE = 12; |
| 1349 | public static final int TYPE_SISTER = 13; |
| 1350 | public static final int TYPE_SPOUSE = 14; |
| 1351 | |
| 1352 | /** |
| 1353 | * The name of the relative as the user entered it. |
| 1354 | * <P>Type: TEXT</P> |
| 1355 | */ |
| 1356 | public static final String NAME = DATA; |
| 1357 | } |
| 1358 | |
| 1359 | /** |
| 1360 | * Common data definition for events. |
| 1361 | */ |
| 1362 | public static final class Event implements BaseCommonColumns, CommonColumns { |
| 1363 | private Event() {} |
| 1364 | |
| 1365 | /** MIME type used when storing this in data table. */ |
| 1366 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event"; |
| 1367 | |
| 1368 | public static final int TYPE_ANNIVERSARY = 1; |
| 1369 | public static final int TYPE_OTHER = 2; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1370 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1371 | /** |
| 1372 | * The event start date as the user entered it. |
| 1373 | * <P>Type: TEXT</P> |
| 1374 | */ |
| 1375 | public static final String START_DATE = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | /** |
| 1379 | * Photo of the contact. |
| 1380 | */ |
| 1381 | public static final class Photo implements BaseCommonColumns { |
| 1382 | private Photo() {} |
| 1383 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1384 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1385 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 1386 | |
| 1387 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 1388 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1389 | * that could be inflated using {@link BitmapFactory}. |
| 1390 | * <p> |
| 1391 | * Type: BLOB |
| 1392 | */ |
| 1393 | public static final String PHOTO = "data1"; |
| 1394 | } |
| 1395 | |
| 1396 | /** |
| 1397 | * Notes about the contact. |
| 1398 | */ |
| 1399 | public static final class Note implements BaseCommonColumns { |
| 1400 | private Note() {} |
| 1401 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1402 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1403 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 1404 | |
| 1405 | /** |
| 1406 | * The note text. |
| 1407 | * <P>Type: TEXT</P> |
| 1408 | */ |
| 1409 | public static final String NOTE = "data1"; |
| 1410 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1411 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 1412 | /** |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1413 | * Group Membership. |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1414 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1415 | public static final class GroupMembership implements BaseCommonColumns { |
| 1416 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1417 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1418 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1419 | public static final String CONTENT_ITEM_TYPE = |
| 1420 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1421 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1422 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1423 | * The row id of the group that this group membership refers to. Exactly one of |
| 1424 | * 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] | 1425 | * <P>Type: INTEGER</P> |
| 1426 | */ |
| 1427 | public static final String GROUP_ROW_ID = "data1"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1428 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1429 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1430 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 1431 | * 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] | 1432 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1433 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1434 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1435 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1436 | |
| 1437 | /** |
| 1438 | * Website related to the contact. |
| 1439 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1440 | public static final class Website implements BaseCommonColumns, CommonColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1441 | private Website() {} |
| 1442 | |
| 1443 | /** MIME type used when storing this in data table. */ |
| 1444 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 1445 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1446 | public static final int TYPE_HOMEPAGE = 1; |
| 1447 | public static final int TYPE_BLOG = 2; |
| 1448 | public static final int TYPE_PROFILE = 3; |
| 1449 | public static final int TYPE_HOME = 4; |
| 1450 | public static final int TYPE_WORK = 5; |
| 1451 | public static final int TYPE_FTP = 6; |
| 1452 | public static final int TYPE_OTHER = 7; |
| 1453 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1454 | /** |
| 1455 | * The website URL string. |
| 1456 | * <P>Type: TEXT</P> |
| 1457 | */ |
| 1458 | public static final String URL = "data1"; |
| 1459 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1460 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1461 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1462 | // TODO: make this private before unhiding |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1463 | public interface GroupsColumns { |
| 1464 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1465 | * The display title of this group. |
| 1466 | * <p> |
| 1467 | * Type: TEXT |
| 1468 | */ |
| 1469 | public static final String TITLE = "title"; |
| 1470 | |
| 1471 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1472 | * The package name to use when creating {@link Resources} objects for |
| 1473 | * this group. This value is only designed for use when building user |
| 1474 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1475 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1476 | public static final String RES_PACKAGE = "res_package"; |
| 1477 | |
| 1478 | /** |
| 1479 | * The display title of this group to load as a resource from |
| 1480 | * {@link #RES_PACKAGE}, which may be localized. |
| 1481 | * <P>Type: TEXT</P> |
| 1482 | */ |
| 1483 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1484 | |
| 1485 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 1486 | * Notes about the group. |
| 1487 | * <p> |
| 1488 | * Type: TEXT |
| 1489 | */ |
| 1490 | public static final String NOTES = "notes"; |
| 1491 | |
| 1492 | /** |
| 1493 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 1494 | * to the sync adapter, null otherwise. |
| 1495 | * <P>Type: TEXT</P> |
| 1496 | */ |
| 1497 | public static final String SYSTEM_ID = "system_id"; |
| 1498 | |
| 1499 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1500 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1501 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1502 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 1503 | * <p> |
| 1504 | * Type: INTEGER |
| 1505 | */ |
| 1506 | public static final String SUMMARY_COUNT = "summ_count"; |
| 1507 | |
| 1508 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1509 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1510 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1511 | * Read-only value that is only present when querying |
| 1512 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 1513 | * <p> |
| 1514 | * Type: INTEGER |
| 1515 | */ |
| 1516 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 1517 | |
| 1518 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1519 | * Flag indicating if the contacts belonging to this group should be |
| 1520 | * visible in any user interface. |
| 1521 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1522 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1523 | */ |
| 1524 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 1525 | |
| 1526 | /** |
| 1527 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 1528 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 1529 | * called on a raw contact, it is marked for deletion and removed from its |
| 1530 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 1531 | * then calls ContactResolver.delete once more, this time setting the the |
| 1532 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 1533 | * the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 1534 | * <P>Type: INTEGER</P> |
| 1535 | */ |
| 1536 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 1537 | |
| 1538 | /** |
| 1539 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 1540 | * is false for this group's account. |
| 1541 | * <p> |
| 1542 | * Type: INTEGER (boolean) |
| 1543 | */ |
| 1544 | public static final String SHOULD_SYNC = "should_sync"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | /** |
| 1548 | * Constants for the groups table. |
| 1549 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1550 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1551 | /** |
| 1552 | * This utility class cannot be instantiated |
| 1553 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1554 | private Groups() { |
| 1555 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1556 | |
| 1557 | /** |
| 1558 | * The content:// style URI for this table |
| 1559 | */ |
| 1560 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 1561 | |
| 1562 | /** |
| 1563 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 1564 | * {@link Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1565 | */ |
| 1566 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1567 | "groups_summary"); |
| 1568 | |
| 1569 | /** |
| 1570 | * The MIME type of a directory of groups. |
| 1571 | */ |
| 1572 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 1573 | |
| 1574 | /** |
| 1575 | * The MIME type of a single group. |
| 1576 | */ |
| 1577 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
| 1578 | } |
| 1579 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1580 | /** |
| 1581 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1582 | * aggregation rules overriding those used by automatic aggregation. This type only |
| 1583 | * supports query and update. Neither insert nor delete are supported. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1584 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1585 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1586 | /** |
| 1587 | * This utility class cannot be instantiated |
| 1588 | */ |
| 1589 | private AggregationExceptions() {} |
| 1590 | |
| 1591 | /** |
| 1592 | * The content:// style URI for this table |
| 1593 | */ |
| 1594 | public static final Uri CONTENT_URI = |
| 1595 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 1596 | |
| 1597 | /** |
| 1598 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 1599 | */ |
| 1600 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 1601 | |
| 1602 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1603 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 1604 | */ |
| 1605 | public static final String CONTENT_ITEM_TYPE = |
| 1606 | "vnd.android.cursor.item/aggregation_exception"; |
| 1607 | |
| 1608 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1609 | * 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] | 1610 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1611 | * |
| 1612 | * <P>Type: INTEGER</P> |
| 1613 | */ |
| 1614 | public static final String TYPE = "type"; |
| 1615 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1616 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1617 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 1618 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1619 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1620 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1621 | |
| 1622 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1623 | * Makes sure that the specified raw contacts are included in the same |
| 1624 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1625 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1626 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 1627 | |
| 1628 | @Deprecated |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1629 | public static final int TYPE_KEEP_IN = 1; |
| 1630 | |
| 1631 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1632 | * Makes sure that the specified raw contacts are NOT included in the same |
| 1633 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1634 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1635 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 1636 | |
| 1637 | @Deprecated |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1638 | public static final int TYPE_KEEP_OUT = 2; |
| 1639 | |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1640 | @Deprecated |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1641 | public static final String CONTACT_ID = "contact_id"; |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1642 | |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1643 | @Deprecated |
| 1644 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1645 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1646 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1647 | * 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] | 1648 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1649 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 1650 | |
| 1651 | /** |
| 1652 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 1653 | * applies to. |
| 1654 | */ |
| 1655 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1656 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 1657 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1658 | private interface SettingsColumns { |
| 1659 | /** |
| 1660 | * The name of the account instance to which this row belongs. |
| 1661 | * <P>Type: TEXT</P> |
| 1662 | */ |
| 1663 | public static final String ACCOUNT_NAME = "account_name"; |
| 1664 | |
| 1665 | /** |
| 1666 | * The type of account to which this row belongs, which when paired with |
| 1667 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 1668 | * <P>Type: TEXT</P> |
| 1669 | */ |
| 1670 | public static final String ACCOUNT_TYPE = "account_type"; |
| 1671 | |
| 1672 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 1673 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 1674 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1675 | * <p> |
| 1676 | * Type: INTEGER (boolean) |
| 1677 | */ |
| 1678 | public static final String SHOULD_SYNC = "should_sync"; |
| 1679 | |
| 1680 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1681 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 1682 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1683 | * <p> |
| 1684 | * Type: INTEGER (boolean) |
| 1685 | */ |
| 1686 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 1687 | |
| 1688 | /** |
| 1689 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1690 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 1691 | * <p> |
| 1692 | * Type: INTEGER |
| 1693 | */ |
| 1694 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 1695 | |
| 1696 | /** |
| 1697 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1698 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 1699 | * <p> |
| 1700 | * Type: INTEGER |
| 1701 | */ |
| 1702 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | /** |
| 1706 | * Contacts-specific settings for various {@link Account}. |
| 1707 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 1708 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1709 | /** |
| 1710 | * This utility class cannot be instantiated |
| 1711 | */ |
| 1712 | private Settings() { |
| 1713 | } |
| 1714 | |
| 1715 | /** |
| 1716 | * The content:// style URI for this table |
| 1717 | */ |
| 1718 | public static final Uri CONTENT_URI = |
| 1719 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 1720 | |
| 1721 | /** |
| 1722 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 1723 | * settings. |
| 1724 | */ |
| 1725 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 1726 | |
| 1727 | /** |
| 1728 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 1729 | */ |
| 1730 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1731 | } |
| 1732 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1733 | /** |
| 1734 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 1735 | * that involve contacts. |
| 1736 | */ |
| 1737 | public static final class Intents { |
| 1738 | /** |
| 1739 | * This is the intent that is fired when a search suggestion is clicked on. |
| 1740 | */ |
| 1741 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 1742 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 1743 | |
| 1744 | /** |
| 1745 | * This is the intent that is fired when a search suggestion for dialing a number |
| 1746 | * is clicked on. |
| 1747 | */ |
| 1748 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 1749 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 1750 | |
| 1751 | /** |
| 1752 | * This is the intent that is fired when a search suggestion for creating a contact |
| 1753 | * is clicked on. |
| 1754 | */ |
| 1755 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 1756 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 1757 | |
| 1758 | /** |
| 1759 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 1760 | * After picking the contact it launches the image cropper in face detection mode. |
| 1761 | */ |
| 1762 | public static final String ATTACH_IMAGE = |
| 1763 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 1764 | |
| 1765 | /** |
| 1766 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 1767 | * contact exists with the given data it will be shown. If no contact |
| 1768 | * exists, a dialog will ask the user if they want to create a new |
| 1769 | * contact with the provided details filled in. If multiple contacts |
| 1770 | * share the data the user will be prompted to pick which contact they |
| 1771 | * want to view. |
| 1772 | * <p> |
| 1773 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 1774 | * raw email address, such as one built using |
| 1775 | * {@link Uri#fromParts(String, String, String)}. |
| 1776 | * <p> |
| 1777 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 1778 | * to existing numbers using the standard caller ID lookup algorithm. |
| 1779 | * The number must be properly encoded, for example using |
| 1780 | * {@link Uri#fromParts(String, String, String)}. |
| 1781 | * <p> |
| 1782 | * Any extras from the {@link Insert} class will be passed along to the |
| 1783 | * create activity if there are no contacts to show. |
| 1784 | * <p> |
| 1785 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 1786 | * prompting the user when the contact doesn't exist. |
| 1787 | */ |
| 1788 | public static final String SHOW_OR_CREATE_CONTACT = |
| 1789 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 1790 | |
| 1791 | /** |
| 1792 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 1793 | * contact if no matching contact found. Otherwise, default behavior is |
| 1794 | * to prompt user with dialog before creating. |
| 1795 | * <p> |
| 1796 | * Type: BOOLEAN |
| 1797 | */ |
| 1798 | public static final String EXTRA_FORCE_CREATE = |
| 1799 | "com.android.contacts.action.FORCE_CREATE"; |
| 1800 | |
| 1801 | /** |
| 1802 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 1803 | * description to be shown when prompting user about creating a new |
| 1804 | * contact. |
| 1805 | * <p> |
| 1806 | * Type: STRING |
| 1807 | */ |
| 1808 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 1809 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 1810 | |
| 1811 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 1812 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 1813 | * dialog location using screen coordinates. When not specified, the |
| 1814 | * dialog will be centered. |
| 1815 | */ |
| 1816 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 1817 | |
| 1818 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 1819 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 1820 | * desired dialog style, usually a variation on size. One of |
| 1821 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
| 1822 | */ |
| 1823 | public static final String EXTRA_MODE = "mode"; |
| 1824 | |
| 1825 | /** |
| 1826 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
| 1827 | */ |
| 1828 | public static final int MODE_SMALL = 1; |
| 1829 | |
| 1830 | /** |
| 1831 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
| 1832 | */ |
| 1833 | public static final int MODE_MEDIUM = 2; |
| 1834 | |
| 1835 | /** |
| 1836 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
| 1837 | */ |
| 1838 | public static final int MODE_LARGE = 3; |
| 1839 | |
| 1840 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 1841 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 1842 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 1843 | * {@link String} array. |
| 1844 | */ |
| 1845 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 1846 | |
| 1847 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1848 | * Intents related to the Contacts app UI. |
| 1849 | */ |
| 1850 | public static final class UI { |
| 1851 | /** |
| 1852 | * The action for the default contacts list tab. |
| 1853 | */ |
| 1854 | public static final String LIST_DEFAULT = |
| 1855 | "com.android.contacts.action.LIST_DEFAULT"; |
| 1856 | |
| 1857 | /** |
| 1858 | * The action for the contacts list tab. |
| 1859 | */ |
| 1860 | public static final String LIST_GROUP_ACTION = |
| 1861 | "com.android.contacts.action.LIST_GROUP"; |
| 1862 | |
| 1863 | /** |
| 1864 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 1865 | */ |
| 1866 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 1867 | |
| 1868 | /** |
| 1869 | * The action for the all contacts list tab. |
| 1870 | */ |
| 1871 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 1872 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 1873 | |
| 1874 | /** |
| 1875 | * The action for the contacts with phone numbers list tab. |
| 1876 | */ |
| 1877 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 1878 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 1879 | |
| 1880 | /** |
| 1881 | * The action for the starred contacts list tab. |
| 1882 | */ |
| 1883 | public static final String LIST_STARRED_ACTION = |
| 1884 | "com.android.contacts.action.LIST_STARRED"; |
| 1885 | |
| 1886 | /** |
| 1887 | * The action for the frequent contacts list tab. |
| 1888 | */ |
| 1889 | public static final String LIST_FREQUENT_ACTION = |
| 1890 | "com.android.contacts.action.LIST_FREQUENT"; |
| 1891 | |
| 1892 | /** |
| 1893 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 1894 | * contacts in alphabetical order and then the frequent contacts in descending |
| 1895 | * order of the number of times they have been contacted. |
| 1896 | */ |
| 1897 | public static final String LIST_STREQUENT_ACTION = |
| 1898 | "com.android.contacts.action.LIST_STREQUENT"; |
| 1899 | |
| 1900 | /** |
| 1901 | * A key for to be used as an intent extra to set the activity |
| 1902 | * title to a custom String value. |
| 1903 | */ |
| 1904 | public static final String TITLE_EXTRA_KEY = |
| 1905 | "com.android.contacts.extra.TITLE_EXTRA"; |
| 1906 | |
| 1907 | /** |
| 1908 | * Activity Action: Display a filtered list of contacts |
| 1909 | * <p> |
| 1910 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 1911 | * filtering |
| 1912 | * <p> |
| 1913 | * Output: Nothing. |
| 1914 | */ |
| 1915 | public static final String FILTER_CONTACTS_ACTION = |
| 1916 | "com.android.contacts.action.FILTER_CONTACTS"; |
| 1917 | |
| 1918 | /** |
| 1919 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 1920 | * intents to supply the text on which to filter. |
| 1921 | */ |
| 1922 | public static final String FILTER_TEXT_EXTRA_KEY = |
| 1923 | "com.android.contacts.extra.FILTER_TEXT"; |
| 1924 | } |
| 1925 | |
| 1926 | /** |
| 1927 | * Convenience class that contains string constants used |
| 1928 | * to create contact {@link android.content.Intent Intents}. |
| 1929 | */ |
| 1930 | public static final class Insert { |
| 1931 | /** The action code to use when adding a contact */ |
| 1932 | public static final String ACTION = Intent.ACTION_INSERT; |
| 1933 | |
| 1934 | /** |
| 1935 | * If present, forces a bypass of quick insert mode. |
| 1936 | */ |
| 1937 | public static final String FULL_MODE = "full_mode"; |
| 1938 | |
| 1939 | /** |
| 1940 | * The extra field for the contact name. |
| 1941 | * <P>Type: String</P> |
| 1942 | */ |
| 1943 | public static final String NAME = "name"; |
| 1944 | |
| 1945 | // TODO add structured name values here. |
| 1946 | |
| 1947 | /** |
| 1948 | * The extra field for the contact phonetic name. |
| 1949 | * <P>Type: String</P> |
| 1950 | */ |
| 1951 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1952 | |
| 1953 | /** |
| 1954 | * The extra field for the contact company. |
| 1955 | * <P>Type: String</P> |
| 1956 | */ |
| 1957 | public static final String COMPANY = "company"; |
| 1958 | |
| 1959 | /** |
| 1960 | * The extra field for the contact job title. |
| 1961 | * <P>Type: String</P> |
| 1962 | */ |
| 1963 | public static final String JOB_TITLE = "job_title"; |
| 1964 | |
| 1965 | /** |
| 1966 | * The extra field for the contact notes. |
| 1967 | * <P>Type: String</P> |
| 1968 | */ |
| 1969 | public static final String NOTES = "notes"; |
| 1970 | |
| 1971 | /** |
| 1972 | * The extra field for the contact phone number. |
| 1973 | * <P>Type: String</P> |
| 1974 | */ |
| 1975 | public static final String PHONE = "phone"; |
| 1976 | |
| 1977 | /** |
| 1978 | * The extra field for the contact phone number type. |
| 1979 | * <P>Type: Either an integer value from |
| 1980 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 1981 | * or a string specifying a custom label.</P> |
| 1982 | */ |
| 1983 | public static final String PHONE_TYPE = "phone_type"; |
| 1984 | |
| 1985 | /** |
| 1986 | * The extra field for the phone isprimary flag. |
| 1987 | * <P>Type: boolean</P> |
| 1988 | */ |
| 1989 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 1990 | |
| 1991 | /** |
| 1992 | * The extra field for an optional second contact phone number. |
| 1993 | * <P>Type: String</P> |
| 1994 | */ |
| 1995 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 1996 | |
| 1997 | /** |
| 1998 | * The extra field for an optional second contact phone number type. |
| 1999 | * <P>Type: Either an integer value from |
| 2000 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 2001 | * or a string specifying a custom label.</P> |
| 2002 | */ |
| 2003 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 2004 | |
| 2005 | /** |
| 2006 | * The extra field for an optional third contact phone number. |
| 2007 | * <P>Type: String</P> |
| 2008 | */ |
| 2009 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 2010 | |
| 2011 | /** |
| 2012 | * The extra field for an optional third contact phone number type. |
| 2013 | * <P>Type: Either an integer value from |
| 2014 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 2015 | * or a string specifying a custom label.</P> |
| 2016 | */ |
| 2017 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 2018 | |
| 2019 | /** |
| 2020 | * The extra field for the contact email address. |
| 2021 | * <P>Type: String</P> |
| 2022 | */ |
| 2023 | public static final String EMAIL = "email"; |
| 2024 | |
| 2025 | /** |
| 2026 | * The extra field for the contact email type. |
| 2027 | * <P>Type: Either an integer value from |
| 2028 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2029 | * or a string specifying a custom label.</P> |
| 2030 | */ |
| 2031 | public static final String EMAIL_TYPE = "email_type"; |
| 2032 | |
| 2033 | /** |
| 2034 | * The extra field for the email isprimary flag. |
| 2035 | * <P>Type: boolean</P> |
| 2036 | */ |
| 2037 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 2038 | |
| 2039 | /** |
| 2040 | * The extra field for an optional second contact email address. |
| 2041 | * <P>Type: String</P> |
| 2042 | */ |
| 2043 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 2044 | |
| 2045 | /** |
| 2046 | * The extra field for an optional second contact email type. |
| 2047 | * <P>Type: Either an integer value from |
| 2048 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2049 | * or a string specifying a custom label.</P> |
| 2050 | */ |
| 2051 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 2052 | |
| 2053 | /** |
| 2054 | * The extra field for an optional third contact email address. |
| 2055 | * <P>Type: String</P> |
| 2056 | */ |
| 2057 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 2058 | |
| 2059 | /** |
| 2060 | * The extra field for an optional third contact email type. |
| 2061 | * <P>Type: Either an integer value from |
| 2062 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2063 | * or a string specifying a custom label.</P> |
| 2064 | */ |
| 2065 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 2066 | |
| 2067 | /** |
| 2068 | * The extra field for the contact postal address. |
| 2069 | * <P>Type: String</P> |
| 2070 | */ |
| 2071 | public static final String POSTAL = "postal"; |
| 2072 | |
| 2073 | /** |
| 2074 | * The extra field for the contact postal address type. |
| 2075 | * <P>Type: Either an integer value from |
| 2076 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2077 | * or a string specifying a custom label.</P> |
| 2078 | */ |
| 2079 | public static final String POSTAL_TYPE = "postal_type"; |
| 2080 | |
| 2081 | /** |
| 2082 | * The extra field for the postal isprimary flag. |
| 2083 | * <P>Type: boolean</P> |
| 2084 | */ |
| 2085 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 2086 | |
| 2087 | /** |
| 2088 | * The extra field for an IM handle. |
| 2089 | * <P>Type: String</P> |
| 2090 | */ |
| 2091 | public static final String IM_HANDLE = "im_handle"; |
| 2092 | |
| 2093 | /** |
| 2094 | * The extra field for the IM protocol |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2095 | * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} |
| 2096 | * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P> |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2097 | */ |
| 2098 | public static final String IM_PROTOCOL = "im_protocol"; |
| 2099 | |
| 2100 | /** |
| 2101 | * The extra field for the IM isprimary flag. |
| 2102 | * <P>Type: boolean</P> |
| 2103 | */ |
| 2104 | public static final String IM_ISPRIMARY = "im_isprimary"; |
| 2105 | } |
| 2106 | } |
| 2107 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2108 | } |