danger.contacts
Class Contact

java.lang.Object
  extended by danger.app.Listener
      extended by danger.contacts.Dialable
          extended by danger.contacts.Contact
All Implemented Interfaces:
DisplayableObject, ActiveObject


public abstract class Contact
extends Dialable
implements ActiveObject, DisplayableObject

Since:
4.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface danger.util.ActiveObject
ActiveObject.Delegate, ActiveObject.WeakDelegateList
 
Field Summary
static int CHANGETYPE_DELETION
          Deprecated.  
static int CHANGETYPE_MODIFICATION
          Deprecated.  
static int EVENT_CHANGETYPE_DELETION
          EVENT_CHANGETYPE_DELETION - The Contact was deleted This event type is broadcast to Listeners registered for Contact Change Events when this Contact is deleted.
static int EVENT_CHANGETYPE_MODIFICATION
          EVENT_CHANGETYPE_MODIFICATION - The Contact was modified.
static int FIELD_COMPANY
           
static int FIELD_EMAIL_1
           
static int FIELD_EMAIL_2
           
static int FIELD_EMAIL_3
           
static int FIELD_EMAIL_4
           
static int FIELD_EMAIL_5
           
static int FIELD_EMAIL_ALL
           
static int FIELD_FIRSTNAME
          For backwards compatibility.
static int FIELD_LASTNAME
           
static int FIELD_NICKNAME
           
static int FIELD_PHONE_1
           
static int FIELD_PHONE_10
           
static int FIELD_PHONE_2
           
static int FIELD_PHONE_3
           
static int FIELD_PHONE_4
           
static int FIELD_PHONE_5
           
static int FIELD_PHONE_6
           
static int FIELD_PHONE_7
           
static int FIELD_PHONE_8
           
static int FIELD_PHONE_9
           
static int FIELD_PHONE_ALL
           
static int NAME_FORMAT_BOTH
          Deprecated.  
static int NAME_FORMAT_FIRST
          When asking for the formatted contact name and you want the First name to appear first.
static int NAME_FORMAT_LAST
          When asking for the formatted contact name and you want the Last name to appear first.
static int NAME_FORMAT_USE_MIDDLENAME
          When asking for the formatted contact name and you want to include the Middle name.
static int NAME_FORMAT_USE_NICKNAME
          When asking for the formatted contact name and you want the First name to be replaced by the Nickname.
 
Constructor Summary
Contact()
           
 
Method Summary
abstract  int convertMatchFieldToIndex(int fieldspec)
          This is a convenience for getting at the data in the contact that was matched by one of the search methods.
abstract  boolean equals(Object o)
           
abstract  String getAddress(int index)
           
abstract  int getAddressCount()
           
abstract  String getAddressLabel(int index)
           
abstract  int getBirthDate()
           
abstract  int getBirthMonth()
           
abstract  int getBirthYear()
           
abstract  String getCity(int index)
           
abstract  String getCompany()
           
abstract  String getCountry(int index)
           
abstract  byte[] getCustomIconData()
           
abstract  String getDisplayInfoString()
           
abstract  String getEmailAddress(int index)
           
abstract  int getEmailCount()
           
abstract  String getEmailLabel(int index)
           
abstract  String getFirstName()
           
abstract  String getFormattedName(int format)
          Get the Contact full name using the specified format.
abstract  Bitmap getIconAsBitmap(int size, boolean circleCrop)
           
abstract  Bitmap getIconForPhoneNumber(String number, int size)
          Return the icon associated with this phone number, if it's a favorite.
abstract  int getIconIndex()
           
abstract  String getIMAccount(int i)
           
abstract  int getIMCount()
           
abstract  String getIMLabel(int i)
           
abstract  String getLastName()
           
abstract  String[] getMatchFieldAndLabel(int field)
          This is a convenience for getting at the data in the contact that was matched by one of the search methods.
abstract  String getMiddleName()
           
abstract  String getNickname()
           
abstract  String getNote()
           
abstract  String getPhoneLabel(int index)
           
abstract  String getPhoneNumber(int index)
           
abstract  PhoneNumber getPhoneNumberObject(int index)
           
abstract  int getRingToneFlags(int index)
           
abstract  int getRingToneID(int index)
           
abstract  int getSMSRingToneFlags(int index)
           
abstract  int getSMSRingToneID(int index)
           
abstract  String getState(int index)
           
abstract  String getTitle()
           
abstract  int getUID()
          Get the UID of this Contact object
abstract  String getURLAddress(int index)
           
abstract  int getURLCount()
           
abstract  String getURLLabel(int index)
           
abstract  String getZipCode(int index)
           
abstract  boolean hasCustomIcon()
           
abstract  boolean hasCustomRingTone()
           
abstract  boolean hasPhoneNumbers()
           
abstract  boolean isInTrash()
           
abstract  boolean isMe()
           
abstract  boolean isOnSIM()
           
 void registerForContactChangeEvents(Listener listener)
          Use this method to register a Listener for Contact change events.
abstract  String toVCard()
           
 void unregisterFromContactChangeEvents(Listener listener)
          Use this method in conjunction with registerForContactChangeEvents(Listener listener)
 
Methods inherited from class danger.contacts.Dialable
getDisplayNameFirst, getDisplayNameLast, getIconAsBitmap, getPhoneCount, getPhoneNumberAndLabel, isFavorite
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, receiveEvent, receiveEventInternal, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface danger.util.ActiveObject
addDelegate, removeDelegate, update
 

Field Detail

CHANGETYPE_MODIFICATION

public static final int CHANGETYPE_MODIFICATION
Deprecated. 
CHANGETYPE_MODIFICATION - One of the Contact fields was modified

See Also:
Constant Field Values

CHANGETYPE_DELETION

public static final int CHANGETYPE_DELETION
Deprecated. 
CHANGETYPE_DELETION - The Contact was deleted

See Also:
Constant Field Values

EVENT_CHANGETYPE_MODIFICATION

public static final int EVENT_CHANGETYPE_MODIFICATION
EVENT_CHANGETYPE_MODIFICATION - The Contact was modified. This event type is broadcast to Listeners registered for Contact Change Events when any of this Contacts fields are modified. See method registerForContactChangeEvents(Listener listener) to register a Listener for Contact change events.

Since:
4.5
See Also:
Constant Field Values

EVENT_CHANGETYPE_DELETION

public static final int EVENT_CHANGETYPE_DELETION
EVENT_CHANGETYPE_DELETION - The Contact was deleted This event type is broadcast to Listeners registered for Contact Change Events when this Contact is deleted. See method registerForContactChangeEvents(Listener listener) to register a Listener for Contact change events.

Since:
4.5
See Also:
Constant Field Values

NAME_FORMAT_FIRST

public static final int NAME_FORMAT_FIRST
When asking for the formatted contact name and you want the First name to appear first. See method getFormattedName(int)

See Also:
Constant Field Values

NAME_FORMAT_LAST

public static final int NAME_FORMAT_LAST
When asking for the formatted contact name and you want the Last name to appear first. See method getFormattedName(int)

See Also:
Constant Field Values

NAME_FORMAT_USE_NICKNAME

public static final int NAME_FORMAT_USE_NICKNAME
When asking for the formatted contact name and you want the First name to be replaced by the Nickname. See method getFormattedName(int)

See Also:
Constant Field Values

NAME_FORMAT_USE_MIDDLENAME

public static final int NAME_FORMAT_USE_MIDDLENAME
When asking for the formatted contact name and you want to include the Middle name. See method getFormattedName(int)

Since:
4.5
See Also:
Constant Field Values

NAME_FORMAT_BOTH

public static final int NAME_FORMAT_BOTH
Deprecated. 
This is a redundant field, since both First and Last names are included in the formatted name.

See Also:
Constant Field Values

FIELD_FIRSTNAME

public static final int FIELD_FIRSTNAME
For backwards compatibility. Enumerated Indexed Fields as static final class members. See Contact.IndexedField for enumeration definition.


FIELD_LASTNAME

public static final int FIELD_LASTNAME

FIELD_NICKNAME

public static final int FIELD_NICKNAME

FIELD_COMPANY

public static final int FIELD_COMPANY

FIELD_EMAIL_1

public static final int FIELD_EMAIL_1

FIELD_EMAIL_2

public static final int FIELD_EMAIL_2

FIELD_EMAIL_3

public static final int FIELD_EMAIL_3

FIELD_EMAIL_4

public static final int FIELD_EMAIL_4

FIELD_EMAIL_5

public static final int FIELD_EMAIL_5

FIELD_PHONE_1

public static final int FIELD_PHONE_1

FIELD_PHONE_2

public static final int FIELD_PHONE_2

FIELD_PHONE_3

public static final int FIELD_PHONE_3

FIELD_PHONE_4

public static final int FIELD_PHONE_4

FIELD_PHONE_5

public static final int FIELD_PHONE_5

FIELD_PHONE_6

public static final int FIELD_PHONE_6

FIELD_PHONE_7

public static final int FIELD_PHONE_7

FIELD_PHONE_8

public static final int FIELD_PHONE_8

FIELD_PHONE_9

public static final int FIELD_PHONE_9

FIELD_PHONE_10

public static final int FIELD_PHONE_10

FIELD_EMAIL_ALL

public static final int FIELD_EMAIL_ALL

FIELD_PHONE_ALL

public static final int FIELD_PHONE_ALL
Constructor Detail

Contact

public Contact()
Method Detail

equals

public abstract boolean equals(Object o)
Overrides:
equals in class Object
Parameters:
o - An object to compare with.
Returns:
True if the two contacts are the same; false if not.

getMatchFieldAndLabel

public abstract String[] getMatchFieldAndLabel(int field)
This is a convenience for getting at the data in the contact that was matched by one of the search methods.

Parameters:
field - A field specification, such as is returned by a match method.
Returns:
String array where field is first element and label is second.

convertMatchFieldToIndex

public abstract int convertMatchFieldToIndex(int fieldspec)
This is a convenience for getting at the data in the contact that was matched by one of the search methods. If the input is FIELD_PHONE_4, returns 3, which can in turn be passed to methods like getPhoneNumberObject(). If the bitfield specifies more than one field, gives priority to phone numbers, and chooses the smallest matching index.

Parameters:
fieldspec - A bitfield specifying a contact field, such as the ones returned by the match methods.
Returns:
A zero-based integer index of the matching item.

toVCard

public abstract String toVCard()
Returns:
A string in vcard/vcf format representing this contact.

getDisplayInfoString

public abstract String getDisplayInfoString()
Returns:
The cached string to display for this contact, given the contact app's current display setting. Either "First Last" or "Last, First".

getFormattedName

public abstract String getFormattedName(int format)
Get the Contact full name using the specified format. The format types are:
  • NAME_FORMAT_FIRST - First name first.
  • NAME_FORMAT_LAST - Last name first.
  • NAME_FORMAT_USE_NICKNAME - Nickname is used in place of First name.
  • NAME_FORMAT_USE_MIDDLENAME - Middle name is included in the returned name string.
  • NAME_FORMAT_BOTH - deprecated : This is a redundant field, since both First and Last names are included in the formatted name if available.
  • .
    example:
    First name first, include middle name :
    getFormattedName(NAME_FORMAT_FIRST & NAME_FORMAT_USE_MIDDLENAME);
    Last name first, include middle name and replace first name with nickname :
    getFormattedName(NAME_FORMAT_LAST & NAME_FORMAT_USE_MIDDLENAME & NAME_FORMAT_USE_NICKNAME);

    Parameters:
    format - A bitmap specifying the name format parameters
    Returns:
    The formatted contact name

    getFirstName

    public abstract String getFirstName()
    Returns:
    The contact's first name.

    getLastName

    public abstract String getLastName()
    Returns:
    The contact's last name.

    getMiddleName

    public abstract String getMiddleName()
    Returns:
    The contact's middle name.

    getNickname

    public abstract String getNickname()
    Returns:
    The contact's nickname.

    getCompany

    public abstract String getCompany()
    Returns:
    The contact's company.

    getTitle

    public abstract String getTitle()
    Returns:
    The contact's title.

    isInTrash

    public abstract boolean isInTrash()
    Returns:
    True if this contact is in the trash.

    isMe

    public abstract boolean isMe()
    Returns:
    True if this contact has been set as the users Contact.
    Since:
    4.5

    isOnSIM

    public abstract boolean isOnSIM()
    Returns:
    True if this contact is from the user's SIM card.

    hasPhoneNumbers

    public abstract boolean hasPhoneNumbers()
    Returns:
    True if this contact has at least one phone number. Faster than getPhoneCount(), because it checks the cached flag.

    hasCustomRingTone

    public abstract boolean hasCustomRingTone()
    Returns:
    True if this contact has a phone number with a custom ring tone.

    getBirthDate

    public abstract int getBirthDate()
    Returns:
    Day of the month of this contact's birthday.

    getBirthMonth

    public abstract int getBirthMonth()
    Returns:
    Month number of this contact's birthday.

    getBirthYear

    public abstract int getBirthYear()
    Returns:
    Year of this contact's birthday.

    getNote

    public abstract String getNote()
    Returns:
    String containing the contents of this contact's notes field.

    getIconIndex

    public abstract int getIconIndex()
    Returns:
    The index of this contact's icon in the icon gallery. -1 if the contact has no icon.

    getIconAsBitmap

    public abstract Bitmap getIconAsBitmap(int size,
                                           boolean circleCrop)
    Parameters:
    size - One of the IconGallery size constants.
    circleCrop - True if this icon should be cropped to a circle.
    Returns:
    A bitmap of the contact's icon. Null if the contact has no icon.

    getIconForPhoneNumber

    public abstract Bitmap getIconForPhoneNumber(String number,
                                                 int size)
    Return the icon associated with this phone number, if it's a favorite. Otherwise, return the contact's icon.

    Parameters:
    number - The phone number to look for custom icons for.
    size - One of the IconGallery size constants.
    Returns:
    A bitmap of the icon. Null if the contact has no icon.

    hasCustomIcon

    public abstract boolean hasCustomIcon()
    Returns:
    True if this contact has a custom photo icon.

    getCustomIconData

    public abstract byte[] getCustomIconData()
    Returns:
    Raw image data for the contact's custom icon, if it has one.

    getEmailCount

    public abstract int getEmailCount()
    Returns:
    Number of email addresses this contact has.

    getEmailLabel

    public abstract String getEmailLabel(int index)
    Parameters:
    index - Zero-based index specifying which email address.
    Returns:
    The label associated with the specified email address.

    getEmailAddress

    public abstract String getEmailAddress(int index)
    Parameters:
    index - Zero-based index specifying which email address.
    Returns:
    The specified email address.

    getIMCount

    public abstract int getIMCount()
    Returns:
    Number of IM accounts this contact has.

    getIMAccount

    public abstract String getIMAccount(int i)
    Parameters:
    i - Zero-based index specifying which IM account.
    Returns:
    The specified IM account.

    getIMLabel

    public abstract String getIMLabel(int i)
    Parameters:
    i - Zero-based index specifying which IM account.
    Returns:
    The label associated with the specified IM account.

    getPhoneLabel

    public abstract String getPhoneLabel(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    The label associated with the specified phone number.

    getPhoneNumber

    public abstract String getPhoneNumber(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    The specified phone number.

    getPhoneNumberObject

    public abstract PhoneNumber getPhoneNumberObject(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    A phone number object representing the specified phone number.

    getSMSRingToneFlags

    public abstract int getSMSRingToneFlags(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    Tone flags to use when playing the custom ring tone for this number when an SMS arrives.

    getSMSRingToneID

    public abstract int getSMSRingToneID(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    Tone flags to use when playing the custom SMS ring tone for this number.

    getRingToneFlags

    public abstract int getRingToneFlags(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    Tone flags to use when playing the custom ring tone for this number.

    getRingToneID

    public abstract int getRingToneID(int index)
    Parameters:
    index - Zero-based index specifying which phone number.
    Returns:
    The ID of a ring tone (if any) associated with this phone number.

    getURLCount

    public abstract int getURLCount()
    Returns:
    Number of web pages this contact has.

    getURLLabel

    public abstract String getURLLabel(int index)
    Parameters:
    index - Zero-based index specifying which URL.
    Returns:
    The label associated with the specified URL.

    getURLAddress

    public abstract String getURLAddress(int index)
    Parameters:
    index - Zero-based index specifying which URL.
    Returns:
    The specified URL.

    getAddressCount

    public abstract int getAddressCount()
    Returns:
    Number of street addresses this contact has.

    getAddressLabel

    public abstract String getAddressLabel(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The label associated with the specified street address.

    getAddress

    public abstract String getAddress(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The specified street address.

    getCity

    public abstract String getCity(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The city for the specified street address.

    getState

    public abstract String getState(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The state or province for specified street address.

    getZipCode

    public abstract String getZipCode(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The zip or postal code for the specified street address.

    getCountry

    public abstract String getCountry(int index)
    Parameters:
    index - Zero-based index specifying which street address.
    Returns:
    The country for the specified street address.

    getUID

    public abstract int getUID()
    Get the UID of this Contact object

    Returns:
    The UID of this Contact

    registerForContactChangeEvents

    public final void registerForContactChangeEvents(Listener listener)
    Use this method to register a Listener for Contact change events. The event types that are broadcast to the Listener are :
  • EVENT_CHANGETYPE_MODIFICATION
  • EVENT_CHANGETYPE_DELETION

  • The event argument field will contain the Contact object for which the change event occured.

    Parameters:
    listener - The Listener that will receive the event notifications
    Since:
    4.5

    unregisterFromContactChangeEvents

    public final void unregisterFromContactChangeEvents(Listener listener)
    Use this method in conjunction with registerForContactChangeEvents(Listener listener)

    Parameters:
    listener - The Listener to unregister from Contact change events
    Since:
    4.5