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