QuickContactBadge


public class QuickContactBadge
extends ImageView implements View.OnClickListener

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.ImageView
       ↳ android.widget.QuickContactBadge


Widget used to show an image with the standard QuickContact badge and on-click behavior.

Summary

Inherited XML attributes

Inherited constants

Fields

protected String[] mExcludeMimes

Inherited fields

Public constructors

QuickContactBadge(Context context)
QuickContactBadge(Context context, AttributeSet attrs)
QuickContactBadge(Context context, AttributeSet attrs, int defStyleAttr)
QuickContactBadge(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

void assignContactFromEmail(String emailAddress, boolean lazyLookup, Bundle extras)

Assign a contact based on an email address.

void assignContactFromEmail(String emailAddress, boolean lazyLookup)

Assign a contact based on an email address.

void assignContactFromPhone(String phoneNumber, boolean lazyLookup)

Assign a contact based on a phone number.

void assignContactFromPhone(String phoneNumber, boolean lazyLookup, Bundle extras)

Assign a contact based on a phone number.

void assignContactUri(Uri contactUri)

Assign the contact uri that this QuickContactBadge should be associated with.

void drawableHotspotChanged(float x, float y)

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

CharSequence getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

void onClick(View v)

Called when a view has been clicked.

void setExcludeMimes(String[] excludeMimes)

Set a list of specific MIME-types to exclude and not display.

void setImageToDefault()

Resets the contact photo to the default state.

void setMode(int size)

This call has no effect anymore, as there is only one QuickContact mode

void setOverlay(Drawable overlay)

Assigns the drawable that is to be drawn on top of the assigned contact photo.

void setPrioritizedMimeType(String prioritizedMimeType)

Set which mimetype should be prioritized in the QuickContacts UI.

Protected methods

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDraw(Canvas canvas)

Implement this to do your drawing.

Inherited methods

Fields

mExcludeMimes

Added in API level 5
protected String[] mExcludeMimes

Public constructors

QuickContactBadge

Added in API level 5
public QuickContactBadge (Context context)

Parameters
context Context

QuickContactBadge

Added in API level 5
public QuickContactBadge (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

QuickContactBadge

Added in API level 5
public QuickContactBadge (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

QuickContactBadge

Added in API level 21
public QuickContactBadge (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

assignContactFromEmail

Added in API level 18
public void assignContactFromEmail (String emailAddress, 
                boolean lazyLookup, 
                Bundle extras)

Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.

Parameters
emailAddress String: The email address of the contact.

lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

extras Bundle: A bundle of extras to populate the contact edit page with if the contact is not found and the user chooses to add the email address to an existing contact or create a new contact. Uses the same string constants as those found in ContactsContract.Intents.Insert

assignContactFromEmail

Added in API level 5
public void assignContactFromEmail (String emailAddress, 
                boolean lazyLookup)

Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.

Parameters
emailAddress String: The email address of the contact.

lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

assignContactFromPhone

Added in API level 5
public void assignContactFromPhone (String phoneNumber, 
                boolean lazyLookup)

Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.

Parameters
phoneNumber String: The phone number of the contact.

lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

assignContactFromPhone

Added in API level 18
public void assignContactFromPhone (String phoneNumber, 
                boolean lazyLookup, 
                Bundle extras)

Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.

Parameters
phoneNumber String: The phone number of the contact.

lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

extras Bundle: A bundle of extras to populate the contact edit page with if the contact is not found and the user chooses to add the phone number to an existing contact or create a new contact. Uses the same string constants as those found in ContactsContract.Intents.Insert

assignContactUri

Added in API level 5
public void assignContactUri (Uri contactUri)

Assign the contact uri that this QuickContactBadge should be associated with. Note that this is only used for displaying the QuickContact window and won't bind the contact's photo for you. Call ImageView.setImageDrawable(android.graphics.drawable.Drawable) to set the photo.

Parameters
contactUri Uri: Either a Contacts#CONTENT_URI or Contacts#CONTENT_LOOKUP_URI style URI.

drawableHotspotChanged

Added in API level 21
public void drawableHotspotChanged (float x, 
                float y)

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

Dispatching to child views is handled by dispatchDrawableHotspotChanged(float, float).

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
x float: hotspot x coordinate

y float: hotspot y coordinate

getAccessibilityClassName

Added in API level 23
public CharSequence getAccessibilityClassName ()

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

onClick

Added in API level 5
public void onClick (View v)

Called when a view has been clicked.

Parameters
v View: The view that was clicked.

setExcludeMimes

Added in API level 5
public void setExcludeMimes (String[] excludeMimes)

Set a list of specific MIME-types to exclude and not display. For example, this can be used to hide the Contacts#CONTENT_ITEM_TYPE profile icon.

Parameters
excludeMimes String

setImageToDefault

Added in API level 11
public void setImageToDefault ()

Resets the contact photo to the default state.

setMode

Added in API level 5
public void setMode (int size)

This call has no effect anymore, as there is only one QuickContact mode

Parameters
size int

setOverlay

Added in API level 21
public void setOverlay (Drawable overlay)

Assigns the drawable that is to be drawn on top of the assigned contact photo.

Parameters
overlay Drawable: Drawable to be drawn over the assigned contact photo. Must have a non-zero instrinsic width and height.

setPrioritizedMimeType

Added in API level 23
public void setPrioritizedMimeType (String prioritizedMimeType)

Set which mimetype should be prioritized in the QuickContacts UI. For example, passing the value Email#CONTENT_ITEM_TYPE can cause emails to be displayed more prominently in QuickContacts.

Parameters
prioritizedMimeType String

Protected methods

drawableStateChanged

Added in API level 5
protected void drawableStateChanged ()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

onAttachedToWindow

Added in API level 5
protected void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
If you override this method you must call through to the superclass implementation.

onDraw

Added in API level 5
protected void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn This value cannot be null.