danger.helpers
Class AddToContactsHelper

java.lang.Object
  extended by danger.app.Listener
      extended by danger.ui.View
          extended by danger.ui.Container
              extended by danger.ui.Window
                  extended by danger.ui.DialogWindow
                      extended by danger.helpers.AddToContactsHelper
All Implemented Interfaces:
TextWatcherSpan


public final class AddToContactsHelper
extends DialogWindow
implements TextWatcherSpan

Dialog to permit the user to quickly add an entry to the address book.


Field Summary
static int INCLUDE_ALL
          Specifies that all fields should be included.
static int INCLUDE_COMPANY
          Specifies that the company field should be included.
static int INCLUDE_FIRSTNAME
          Specifies that the first name field should be included.
static int INCLUDE_IM
          Specifies that the IM name field should be included.
static int INCLUDE_LASTNAME
          Specifies that the last name field should be included.
static int INCLUDE_MAIL
          Specifies that the email address field should be included.
static int INCLUDE_MIDDLENAME
          Specifies that the middle name field should be included.
static int INCLUDE_MULTI_GALLERY_ICON_PICKER
          Specifies that the MultiGallery Icon Picker should be included.
static int INCLUDE_NICKNAME
          Specifies that the nickname field should be included.
static int INCLUDE_PHONE
          Specifies that the phone number field should be included.
static int INCLUDE_PHONE_LABEL
          Specifies that the phone label should be included.
static int INCLUDE_RINGTONE_PICKER
          Specifies that the Ringtone Picker should be included.
 
Fields inherited from class danger.ui.DialogWindow
APP_ALERT_STYLE, APP_DIALOG_STYLE, BOTTOM_POSITION1, BOTTOM_POSITION2, BOTTOM_POSITION3, m_showToneID, mListener, SHOW_STATE_HIDDEN, SHOW_STATE_SHOWING, SHOW_STATE_VISIBLE, SYSTEM_ALERT_TYPE_ALARM, SYSTEM_ALERT_TYPE_CONTROL, SYSTEM_ALERT_TYPE_GENERAL, SYSTEM_ALERT_TYPE_INCOMING_CALL, SYSTEM_ALERT_TYPE_MISSED_CALL, SYSTEM_ALERT_TYPE_PERSISTENT_CONTROL, SYSTEM_DIALOG_STYLE, SYSTEM_ERROR_STYLE, TOP_POSITION1, TOP_POSITION2
 
Fields inherited from class danger.ui.Window
NO_FULL_SCREEN_MARQUEE, SHOW_FULL_SCREEN_MARQUEE, STATE_AUTO_HIDE_IF_IDLE, STATE_DROP_ORPHANED_EVENTS, STATE_FULLSCREEN, STATE_UNUSED1
 
Fields inherited from class danger.ui.View
DEFAULT_SCROLL_FOCUS_MARGIN, FOCUS_DEFAULT, FOCUS_DOWNWARD, FOCUS_FROM_NOWHERE, FOCUS_LEFTWARD, FOCUS_NONE, FOCUS_RIGHTWARD, FOCUS_UPWARD, HEIGHT_AUTO, HEIGHT_FILL_TO_BOTTOM, HEIGHT_FILL_TO_TOP, HEIGHT_MATCH_CONTROL, HEIGHT_PERCENTAGE, POSITION_ABOVE, POSITION_ALIGN_BASELINE, POSITION_ALIGN_BOTTOM, POSITION_ALIGN_HORIZONTALLY, POSITION_ALIGN_LEFT, POSITION_ALIGN_PARENT_BOTTOM, POSITION_ALIGN_PARENT_RIGHT, POSITION_ALIGN_PARENT_TOP, POSITION_ALIGN_RIGHT, POSITION_ALIGN_TOP, POSITION_ALIGN_VERTICALLY, POSITION_BELOW, POSITION_BELOW_GROUP_BOX_HEADING, POSITION_TO_LEFT, POSITION_TO_RIGHT, PREFER_DIRECTION_NONE, PREFER_HORIZONTAL_DIRECTION, PREFER_VERTICAL_DIRECTION, STATE_AT_AND_SPACE_PAGE, STATE_CAN_FOCUS, STATE_DEBUG_BOUNDS, STATE_ENABLED, STATE_FOCUSED, STATE_MAKE_DING, STATE_PARTIAL_FOCUS_OK, STATE_TRANSPARENT, STATE_VISIBLE, WIDTH_AUTO, WIDTH_FILL_TO_LEFT, WIDTH_FILL_TO_RIGHT, WIDTH_MATCH_CONTROL, WIDTH_PERCENTAGE
 
Fields inherited from interface danger.text.span.TextWatcherSpan
TEXT_WATCHER_SPAN_TYPE
 
Method Summary
 void afterTextChanged(Spanned text)
          Called after the text of the buffer has changed.
 boolean eventWidgetUp(int widget, Event event)
          Handle the release of a device widget
static AddToContactsHelper newContactHelper(int includedFields, int inNumContacts)
          Create a dialog with the specified fields.
static AddToContactsHelper newEmailInterface(int inNumContacts)
          Create a dialog with fields for name, company, and email address.
static AddToContactsHelper newIMInterface(int inNumContacts)
          Create a dialog with fields for name, company, and IM name.
static AddToContactsHelper newPhoneInterface(int inNumContacts)
          Create a dialog with fields for name, company, and phone number.
protected  void onShow()
          This method is called when this view is shown, via the method View.show().
 boolean receiveEvent(Event e)
          Entry point for event processing.
 void setCompany(int inIndex, String inCompany)
          Set the company of the specified contact.
 void setEmail(int inIndex, String inEmail)
          Set the email address of the specified contact.
 void setFavoriteIcon(int galleryID, int index)
           
 void setFirstName(int inIndex, String inFirstName)
          Set the first name of the specified contact.
 void setIM(int inIndex, String inIM)
          Set the IM name of the specified contact.
 void setIMService(String inIMService)
          Set the IM service of the specified contact.
 void setLastName(int inIndex, String inLastName)
          Set the last name of the specified contact.
 void setMiddleName(int inIndex, String inMiddleName)
          Set the middle name of the specified contact.
 void setName(int inIndex, String inName)
          Set the name of the specified contact.
 void setNickname(int inIndex, String inNickname)
          Set the nickname of the specified contact.
 void setOnAddEvent(Event e)
          Specify an event to send when a contact is added.
 void setPhone(int inIndex, String inPhone)
          Set the phone number of the specified contact.
 void setPhoneLabel(int inIndex, String inPhoneLabel)
          Set the phone label of the specified contact.
 void setRingTonePickerID(int ringToneID)
           
 void textChanged(Spanned text, int offset, int before, int after)
          Called when the text of the buffer has changed.
 void textWillChange(Spanned text, int offset, int len)
          Called when the text of the buffer is about to change.
 
Methods inherited from class danger.ui.DialogWindow
activateFrameButton, addBottomFrameButton, addBottomFrameButton, addBottomFrameButtons, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addFrameButton, addTopFrameButton, addTopFrameButton, addTopFrameButtons, blocksChooser, calcBottom, convertShortcutKeyToButtonIndex, convertShortcutKeyToButtonIndex, disableBottomRightButtonOnEmptyField, disableButtonOnEmptyField, drawDialogStyleFrame, eventKeyUp, eventShortcut, eventWidgetDown, getCancelButton, getChildWithID, getContentRect, getDefaultFrameButton, getDescendantWithID, getFrameButtonListener, getFrameButtonWithID, getMaxWidth, getNumTopFrameButtons, getShowState, getShowToneID, getSleepScreenImage, getSleepScreenMessageCharSequence, getTitle, getTitleBarHeight, getTitleFont, getTitleSequence, getWidthToFitTitle, getWindowStyle, handleButtonShortcut, handleFrameButtonShortcut, handleShortcutKey, hasVisibleFrameButtons, hide, layoutTopFrameButtons, paint, positionDialog, reflowFrameButtons, removeAllChildren, removeFrameButtonWithID, setAutoCenter, setAutoSize, setAutoSizeHeight, setAutoSizeWidth, setBackEvent, setBorders, setCancelButtonEvent, setCenterTitle, setContentSize, setDefaultFrameButton, setDefaultFrameButton, setDrawBottomFrame, setEventForControlWithID, setEventForFrameButtonWithID, setFocusedChild, setFocusedDescendant, setForceDrawBottomFrame, setFrameButtonShortcut, setFrameButtonShortcut, setHideOnButtonEvent, setHideOnButtonWithID, setHideOnButtonWithPosition, setLayoutBottomFrameButtonsVertically, setListener, setNoDefaultFrameButton, setOverrideMaxWidth, setShowCancel, setShowTone, setShowTone, setSize, setSleepScreenImage, setSleepScreenMessage, setSleepScreenMessage, setTitle, setTitle, setWidthToFitTitle, setWindowStyle, show, show, show, showInternal, snapToChildren, snapToChildren, startShowTone, startShowTone, startShowTone, startShowTone, stopShowTone, updateBottomButtonWidths, updateFrameButtonColors, wantsEndButton, wantsSendButton
 
Methods inherited from class danger.ui.Window
addTranslucentRegion, addTranslucentRegion, adjustActionMenuState, advanceFocus, autoHide, autoHideIfIdle, autoHideIfIdle, blocksAutomaticKeyGuard, blocksBackButton, blocksFloatingControls, blocksKeyGuard, blocksVolumeButtons, centerHorizontal, centerOnScreen, centerUnderTitleBar, centerVertical, disableControlWithID, dropOrphanedEvents, enableControlWithID, forwardQueuedEvents, getApplication, getDefaultFocus, getDefaultListener, getEffectiveWindow, getIDOfChild, getListener, getWindowBelow, hideActiveMenu, hideControlWithID, incrementMaxChildID, invalidate, isActionMenuVisible, isFullScreen, isUnresponsive, onActivate, onDeactivate, onPeriodicPulse, onWindowPaint, receiveMessage, removeTranslucentRegions, reverseFocus, setDefaultFocus, setDefaultListener, setEventArgForControlWithID, setFullScreen, setMaxChildID, setMaxControlID, setPosition, setShowFullScreenMarquee, setTitled, setTitleFormatDate, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTransparent, shouldDropEvent, showControlWithID, startQueueingEvents, wantsMenuTrackball, willPassEventToWindow
 
Methods inherited from class danger.ui.Container
addChild, addChild, addChildAt, addChildAt, addFromContainerResource, addFromContainerResource, addFromContainerResource, addFromDialogResource, addFromDialogResource, advanceFocusInWindow, childCount, childIsOnScreen, disable, enable, eventKeyDown, eventKeyHeld, eventKeyRepeat, eventPeriodicPulse, eventRawKeyDown, eventRawKeyHeld, eventRawKeyRepeat, eventRawKeyUp, eventWidgetHeld, focusedDescendantIsValid, getBottomChild, getBottomChild, getChildAt, getChildIndex, getControlWithID, getFirstChild, getFirstFocusableChild, getFocusableChildInWindow, getFocusedChild, getFocusedLeaf, getInterestingRect, getLastChild, getLastFocusableChild, getLeftMostChild, getNextFocusableChild, getNextFocusableChild, getPageHeight, getPrevFocusableChild, getPrevFocusableChild, getRightMostChild, getRightMostChild, hideAllChildren, isDescendant, keepRectInView, loseFocus, moveChildToIndex, onChildPositionChanged, onChildSizeChanged, onChildVisibilityChanged, pageToEnd, pageToHome, paintChildren, reflowChildren, removeChild, setFocusedChild, setFocusedChild, setFocusedDescendant, setFocusedDescendant, setFocusToFirstDescendant, setFormatDateForControlWithID, setFormatDateForTextControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setListenerForAllControls, setReflowAdjustHeight, setWindow, showAllChildren, snapHeightToChildren, snapHeightToChildren, snapWidthToChildren, snapWidthToChildren, takeFocus, willFocusWithin, willFocusWithin
 
Methods inherited from class danger.ui.View
boundsIntersect, boundsIntersect, canLoseFocus, clear, clear, copyStyle, getAcceptFocus, getBackgroundColor, getBottom, getBounds, getBounds, getData, getFocusTraversalDirection, getFocusTraversalFrom, getFocusTraversalPolicy, getFrame, getFrame, getGlobalBottom, getGlobalLeft, getGlobalRight, getGlobalTop, getHeight, getID, getInterestingRect, getLabelFont, getLabelFont, getLeft, getOrigin, getOrigin, getOriginX, getOriginY, getParent, getParentContainer, getPartialFocusOK, getRight, getScrollFocusMargin, getSibling, getState, getStyle, getStyleColor, getStyleFont, getTop, getWidth, getWindow, globalToLocal, globalToLocalH, globalToLocalV, invalidate, invalidate, invalidateIndependentOfOrigin, invalidateIndependentOfOrigin, isEnabled, isFocusable, isFocused, isObscured, isOnScreen, isTransparent, isVisible, isVisibleInHierarchy, isVisibleOnScreen, justSetVisible, localToGlobal, localToGlobal, localToGlobalH, localToGlobalV, localToWindow, moveBy, notifyWhenFocusChanges, notifyWhenObscurityChanges, notifyWhenParentSizeChanges, notifyWhenPositionChanges, notifyWhenSizeChanges, notifyWhenVisibilityChanges, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onEnabledStateChanged, onHide, onPositionChanged, onRemovedFromParent, onShortcut, onShortcut, onShortcutConsumed, onSizeChanged, onStyleChanged, onSystemFontChanged, onViewFocusChanged, onViewObscurityChanged, onViewPositionChanged, onViewSizeChanged, onViewVisibilityChanged, playLimitSound, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setAtAndSpacePage, setBackground, setBackgroundColor, setBottom, setData, setDebugBounds, setDynamicHeight, setDynamicPosition, setDynamicWidth, setEnabled, setFocusTraversalDirection, setFocusTraversalFrom, setFocusTraversalPolicy, setFrame, setHeight, setKeyedValue, setLabelFont, setLeft, setMakeLimitNoise, setOrigin, setOrigin, setPartialFocusOK, setPreferredDirection, setRight, setScrollFocusMargin, setStyle, setStyleColor, setStyleFont, setStyleFrameColor, setTop, setVisible, setWidth, showContextMenu, styleIsDefault, swapStyleColors, windowToLocal
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE_FIRSTNAME

public static final int INCLUDE_FIRSTNAME

Specifies that the first name field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_MIDDLENAME

public static final int INCLUDE_MIDDLENAME

Specifies that the middle name field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_LASTNAME

public static final int INCLUDE_LASTNAME

Specifies that the last name field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_NICKNAME

public static final int INCLUDE_NICKNAME

Specifies that the nickname field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_COMPANY

public static final int INCLUDE_COMPANY

Specifies that the company field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_PHONE

public static final int INCLUDE_PHONE

Specifies that the phone number field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_MAIL

public static final int INCLUDE_MAIL

Specifies that the email address field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_IM

public static final int INCLUDE_IM

Specifies that the IM name field should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values

INCLUDE_MULTI_GALLERY_ICON_PICKER

public static final int INCLUDE_MULTI_GALLERY_ICON_PICKER

Specifies that the MultiGallery Icon Picker should be included.

See Also:
Constant Field Values

INCLUDE_RINGTONE_PICKER

public static final int INCLUDE_RINGTONE_PICKER

Specifies that the Ringtone Picker should be included.

See Also:
Constant Field Values

INCLUDE_PHONE_LABEL

public static final int INCLUDE_PHONE_LABEL

Specifies that the phone label should be included.

See Also:
Constant Field Values

INCLUDE_ALL

public static final int INCLUDE_ALL

Specifies that all fields should be included.

To be used with newContactHelper(int, int).

See Also:
Constant Field Values
Method Detail

newEmailInterface

public static AddToContactsHelper newEmailInterface(int inNumContacts)
Create a dialog with fields for name, company, and email address.

Parameters:
inNumContacts - the number of contacts to add
Returns:
The dialog. You will subsequently need to call DialogWindow.show().

newPhoneInterface

public static AddToContactsHelper newPhoneInterface(int inNumContacts)
Create a dialog with fields for name, company, and phone number.

Parameters:
inNumContacts - the number of contacts to add
Returns:
The dialog. You will subsequently need to call DialogWindow.show().

newIMInterface

public static AddToContactsHelper newIMInterface(int inNumContacts)
Create a dialog with fields for name, company, and IM name.

Parameters:
inNumContacts - the number of contacts to add
Returns:
The dialog. You will subsequently need to call DialogWindow.show().

newContactHelper

public static AddToContactsHelper newContactHelper(int includedFields,
                                                   int inNumContacts)
Create a dialog with the specified fields.

Parameters:
includedFields - some combination of the following fields: INCLUDE_FIRSTNAME, INCLUDE_MIDDLENAME, INCLUDE_LASTNAME, INCLUDE_NICKNAME, INCLUDE_COMPANY, INCLUDE_PHONE, INCLUDE_MAIL, INCLUDE_IM. Alternatively, this may be INCLUDE_ALL.
inNumContacts - the number of contacts to add
Returns:
The dialog. You will subsequently need to call DialogWindow.show().

textWillChange

public void textWillChange(Spanned text,
                           int offset,
                           int len)
Description copied from interface: TextWatcherSpan
Called when the text of the buffer is about to change.

Specified by:
textWillChange in interface TextWatcherSpan
Parameters:
text - the buffer where the change will be made
offset - the point where the change will begin
len - the number of existing characters that will be affected (0 if this is an insertion)

textChanged

public void textChanged(Spanned text,
                        int offset,
                        int before,
                        int after)
Description copied from interface: TextWatcherSpan
Called when the text of the buffer has changed.

Specified by:
textChanged in interface TextWatcherSpan
Parameters:
text - the buffer where the change was made
offset - the point where the change began
before - the number of characters that were affected (0 if this was an insertion)
after - the number of characters that replaced the previous set of characters (0 if this is was a deletion)

afterTextChanged

public void afterTextChanged(Spanned text)
Description copied from interface: TextWatcherSpan
Called after the text of the buffer has changed. If you need to make text changes from a text watcher, set marks in textChanged() to keep track of where you want to make them, and then set them here.

Specified by:
afterTextChanged in interface TextWatcherSpan
Parameters:
text - the buffer where the change was made

onShow

protected void onShow()
Description copied from class: View
This method is called when this view is shown, via the method View.show(). It is called as the very last thing done by that method, and it is only ever called if the view was not already visible. Overriding this method is the recommended way to get special behavior when a view gets shown. The implementation in this class does nothing.

Overrides:
onShow in class View

setOnAddEvent

public void setOnAddEvent(Event e)
Specify an event to send when a contact is added.

The event is sent when the user selects the "Add" button.

Parameters:
e - the event to send

setName

public final void setName(int inIndex,
                          String inName)
Set the name of the specified contact.

You can use this to pre-populate the name fields.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inName - the new name. The name can be of the form Last, First or First Last.

setFirstName

public final void setFirstName(int inIndex,
                               String inFirstName)
Set the first name of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inFirstName - the first name of the contact

setMiddleName

public final void setMiddleName(int inIndex,
                                String inMiddleName)
Set the middle name of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inMiddleName - the middle name of the contact

setLastName

public final void setLastName(int inIndex,
                              String inLastName)
Set the last name of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inLastName - the last name of the contact

setNickname

public final void setNickname(int inIndex,
                              String inNickname)
Set the nickname of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inNickname - the nickname of the contact

setCompany

public final void setCompany(int inIndex,
                             String inCompany)
Set the company of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inCompany - the company of the contact

setEmail

public final void setEmail(int inIndex,
                           String inEmail)
Set the email address of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inEmail - the email address of the contact

setPhone

public final void setPhone(int inIndex,
                           String inPhone)
Set the phone number of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inPhone - the phone number of the contact

setPhoneLabel

public final void setPhoneLabel(int inIndex,
                                String inPhoneLabel)
Set the phone label of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inPhoneLabel - the phone label of the contact

setIM

public final void setIM(int inIndex,
                        String inIM)
Set the IM name of the specified contact.

Parameters:
inIndex - the index of the contact to change. The first index is 0.
inIM - the IM name of the contact

setIMService

public final void setIMService(String inIMService)
Set the IM service of the specified contact.

Parameters:
inIMService - the IM service of the contact

receiveEvent

public final boolean receiveEvent(Event e)
Description copied from class: Listener
Entry point for event processing. This method is called from a Dispatcher when it reads an Event in its queue that is targetted at this instance. This base class implementation handles event methods as specified by the eventMethod keyword in .rsrc files. If you override this method, be sure to call super.receiveEvent.

Overrides:
receiveEvent in class DialogWindow
Parameters:
e - non-null; the event to process
Returns:
whether (true) or not (false) this method actually handled the event to completion

eventWidgetUp

public boolean eventWidgetUp(int widget,
                             Event event)
Description copied from class: Container
Handle the release of a device widget

Overrides:
eventWidgetUp in class DialogWindow
Parameters:
widget - the widget that went down
Returns:
whether or not the event was consumed

setRingTonePickerID

public void setRingTonePickerID(int ringToneID)
Since:
4.0

setFavoriteIcon

public void setFavoriteIcon(int galleryID,
                            int index)
Since:
4.0