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