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