danger.ui
Class DialogWindow

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
Direct Known Subclasses:
AddToContactsHelper, AlertWindow, AudioPreviewWindow, AudioRecordWindow, DateDialog, ProgressWindow, ToolTipWindow


public class DialogWindow
extends Window

Standard dialog window.

This window class has the standard look and feel of dialog windows, including the title, frame, and frame buttons.


Field Summary
static int APP_ALERT_STYLE
          Constant to be used with setWindowStyle(int) or a constructor.
static int APP_DIALOG_STYLE
          Constant to be used with setWindowStyle(int) or a constructor.
static int BOTTOM_POSITION1
          Specifies the bottom rightmost frame button position.
static int BOTTOM_POSITION2
          Specifies the bottom middle frame button position.
static int BOTTOM_POSITION3
          Specifies the bottom leftmost frame button position.
protected static int BUTTON_HEIGHT
          Deprecated. For internal use only.
protected  boolean m_autoCenter
          Deprecated. Use setAutoCenter(boolean) instead.
protected  int m_bottomBorder
          Deprecated. Use setBorders(int, int, int, int) instead.
protected  int m_leftBorder
          Deprecated. Use setBorders(int, int, int, int) instead.
protected  int m_rightBorder
          Deprecated. Use setBorders(int, int, int, int) instead.
protected  RingToneObject m_showTone
          Deprecated. Use setShowTone(danger.audio.RingToneObject) instead.
protected  int m_showToneID
          Deprecated. Use setShowTone(int) instead.
protected  Alarm m_toneAlarm
          Deprecated. For internal use only.
protected  int m_topBorder
          Deprecated. Use setBorders(int, int, int, int) instead.
protected  boolean mAutoSizeHeight
          Deprecated. Use setAutoSize(boolean) or setAutoSizeHeight(boolean) instead.
protected  boolean mAutoSizeWidth
          Deprecated. Use setAutoSize(boolean) or setAutoSizeWidth(boolean) instead.
protected static int MAX_BOTTOM_BUTTONS
          Deprecated. For internal use only.
protected static int MAX_BUTTONS
          Deprecated. For internal use only.
protected  Event mBackEvent
          Deprecated. Use setBackEvent(danger.app.Event) instead.
protected  int[] mButtonIDs
          Deprecated. For internal use only.
protected  Button[] mButtons
          Deprecated. For internal use only.
protected  Event mCancelEvent
          Deprecated. Use setCancelButtonEvent(danger.app.Event) instead.
protected  boolean mCenterTitle
          Deprecated. Use setCenterTitle(boolean) instead.
protected  Button mDefaultButton
          Deprecated. Use setDefaultFrameButton(Button) instead.
protected  int mDefaultButtonPosition
          Deprecated. Use setDefaultFrameButton(int) instead.
protected  boolean[] mHideOnButton
          Deprecated. Use setHideOnButtonEvent(boolean), setHideOnButtonWithID(int,boolean) or setHideOnButtonWithPosition(int,boolean) instead.
protected  boolean mLayoutButtonsVertically
          Deprecated. Use setLayoutBottomFrameButtonsVertically(boolean) instead.
protected  Listener mListener
          Deprecated. Use setListener(danger.app.Listener) instead.
protected  boolean mNeedToAddBottomFrameButtons
          Deprecated. For internal use only.
protected  boolean mNeedToAddTopFrameButtons
          Deprecated. For internal use only.
protected  boolean mRegisteredForKeyGuardEvent
          Deprecated. For internal use only.
protected  int[] mShortcutModifiers
          Deprecated. For internal use only.
protected  char[] mShortcuts
          Deprecated. For internal use only.
static int SHOW_STATE_HIDDEN
          Constant returned by getShowState().
static int SHOW_STATE_SHOWING
          Constant returned by getShowState().
static int SHOW_STATE_VISIBLE
          Constant returned by getShowState().
static int SYSTEM_ALERT_TYPE_ALARM
          Constant to be used with show(int).
static int SYSTEM_ALERT_TYPE_CONTROL
          Constant to be used with show(int).
static int SYSTEM_ALERT_TYPE_GENERAL
          Constant to be used with show(int).
static int SYSTEM_ALERT_TYPE_INCOMING_CALL
          Constant to be used with show(int).
static int SYSTEM_ALERT_TYPE_MISSED_CALL
          Constant to be used with show(int).
static int SYSTEM_ALERT_TYPE_PERSISTENT_CONTROL
          Constant to be used with show(int).
static int SYSTEM_DIALOG_STYLE
          Constant to be used with setWindowStyle(int) or a constructor.
static int SYSTEM_ERROR_STYLE
          Constant to be used with setWindowStyle(int) or a constructor.
static int TOP_POSITION1
          Specifies the top rightmost frame button position.
static int TOP_POSITION2
          Specifies the top leftmost frame button position.
 
Fields inherited from class danger.ui.Window
mBusyPaintCount, mDefaultListener, 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_LEFTWARD, FOCUS_NONE, FOCUS_RIGHTWARD, FOCUS_UPWARD, mOriginX, mOriginY, mStyle, POSITION_ABOVE, POSITION_ALIGN_BASELINE, POSITION_ALIGN_BOTTOM, POSITION_ALIGN_HORIZONTALLY, POSITION_ALIGN_LEFT, POSITION_ALIGN_PARENT_BOTTOM, POSITION_ALIGN_PARENT_RIGHT, POSITION_ALIGN_RIGHT, POSITION_ALIGN_TOP, POSITION_ALIGN_VERTICALLY, POSITION_BELOW, POSITION_CENTER_HORIZONTALLY, POSITION_CENTER_VERTICALLY, 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_FILL_TO_RIGHT
 
Constructor Summary
DialogWindow()
          Construct an instance.
DialogWindow(boolean showCancel)
          Construct an instance.
DialogWindow(CharSequence inTitle)
          Construct an instance.
DialogWindow(CharSequence inTitle, int windowStyle)
          Construct an instance.
DialogWindow(CharSequence inTitle, int windowStyle, boolean showCancel)
          Construct an instance.
DialogWindow(String inTitle)
          Construct an instance.
DialogWindow(String inTitle, int windowStyle)
          Construct an instance.
DialogWindow(String inTitle, int windowStyle, boolean showCancel)
          Construct an instance.
 
Method Summary
protected  void activateFrameButton(int position)
          Activates the frame button with the given position.
 Button addBottomFrameButton(CharSequence buttonStr, int eventType, int data, Object arg, char shortcut)
           
 Button addBottomFrameButton(String buttonStr, int eventType, int data, Object arg, char shortcut)
          Add a button to the dialog window.
protected  void addBottomFrameButtons()
          Add the bottom frame buttons to the window.
 Button addFrameButton(int position, CharSequence buttonStr, int flags, int eventType, int eventWhat, int data, Object arg, char shortcut, int id)
           
 Button addFrameButton(int position, CharSequence buttonStr, int flags, int eventType, int data, Object arg, char shortcut)
           
 Button addFrameButton(int position, CharSequence buttonStr, int flags, int eventType, int data, Object arg, char shortcut, int id)
           
 Button addFrameButton(int position, CharSequence buttonStr, int eventType, int eventWhat, int data, Object arg, char shortcut, int shortcutModifiers, int id)
           
 Button addFrameButton(int position, CharSequence buttonStr, int eventType, int data, Object arg)
           
 Button addFrameButton(int position, CharSequence buttonStr, int eventType, int data, Object arg, char shortcut)
           
 Button addFrameButton(int position, CharSequence buttonStr, int eventType, int data, Object arg, char shortcut, int id)
           
 Button addFrameButton(int position, CharSequence buttonStr, int eventType, int data, Object arg, char shortcut, int shortcutModifiers, int id)
           
 Button addFrameButton(int position, CharSequence buttonStr, Listener eventListener, int eventType, int eventWhat, int data, Object arg, char shortcut, int shortcutModifiers, int id)
           
 Button addFrameButton(int position, String buttonStr, int flags, int eventType, int eventWhat, int data, Object arg, char shortcut, int id)
          Add a frame button to the dialog.
 Button addFrameButton(int position, String buttonStr, int flags, int eventType, int data, Object arg, char shortcut)
          Add a button to the dialog window.
 Button addFrameButton(int position, String buttonStr, int flags, int eventType, int data, Object arg, char shortcut, int id)
           
 Button addFrameButton(int position, String buttonStr, int eventType, int eventWhat, int data, Object arg, char shortcut, int shortcutModifiers, int id)
           
 Button addFrameButton(int position, String buttonStr, int eventType, int data, Object arg)
           
 Button addFrameButton(int position, String buttonStr, int eventType, int data, Object arg, char shortcut)
           
 Button addFrameButton(int position, String buttonStr, int eventType, int data, Object arg, char shortcut, int id)
           
 Button addFrameButton(int position, String buttonStr, int eventType, int data, Object arg, char shortcut, int shortcutModifiers, int id)
           
 Button addFrameButton(int position, String buttonStr, Listener eventListener, int eventType, int eventWhat, int data, Object arg, char shortcut, int shortcutModifiers, int id)
          Add a button to the dialog window.
 Button addTopFrameButton(CharSequence buttonStr, int eventType, int data, Object arg, char shortcut)
           
 Button addTopFrameButton(String buttonStr, int eventType, int data, Object arg, char shortcut)
          Add a top frame button to the dialog.
protected  void addTopFrameButtons()
          Add the top frame buttons to the window.
 boolean blocksChooser()
          Whether the window blocks from going to the chooser Some applications, such as security/passcode lock and registration block from going to the chooser when the JUMP button is pressed.
protected  int calcBottom()
          This is called automatically to determine positions of vertical frame buttons.
protected  int convertShortcutKeyToButtonIndex(char key, Event event)
          This is called automatically to determine if a shortcut key matches a shortcut for a frame button.
 int convertShortcutKeyToButtonIndex(Event e)
          This is called automatically to determine if a shortcut key matches a shortcut for a frame button.
 void disableBottomRightButtonOnEmptyField(TextField textField)
          Specifies that the bottom right frame button should be disabled whenever the specified text field is empty.
 void disableButtonOnEmptyField(int buttonID, int fieldID)
          Specifies that the specified button should be disabled whenever the specified text field is empty.
protected  void drawDialogStyleFrame(Pen p, int windowStyle)
          Draw the frame for the dialog window.
 boolean eventKeyUp(char c, Event event)
          Processes key releases directed at this container.
 boolean eventShortcut(char shortcut, Event event)
          Handles shortcuts for frame buttons.
 boolean eventWidgetDown(int widget, Event event)
          Handle a button down event.
 boolean eventWidgetUp(int widget, Event event)
          Handle the release of a device widget
protected  Button getCancelButton()
          This method will return the cancel button, if there is any.
 View getChildWithID(int id)
          Get the child view with the given id.
 Rect getContentRect()
          Get the content rect Returns the content rect of the dialog, which does not include the top or bottom frames (or frame buttons).
 Button getDefaultFrameButton()
          Get the frame button with initial focus.
 View getDescendantWithID(int id)
          Get the descendant view with the given id.
protected  Button getFrameButtonWithID(int id)
          Get the frame button with the given id.
 int getNumTopFrameButtons()
           
 int getShowState()
          Get the show state.
 Bitmap getSleepScreenImage()
           
 String getSleepScreenMessage()
          Deprecated. Use getSleepScreenMessageCharSequence instead
 CharSequence getSleepScreenMessageCharSequence()
           
 String getTitle()
          Obtain the title of the window Obtains the title of the window that was set via a constructor or by a call to setTitle(java.lang.String)
 int getTitleBarHeight()
          Get the height of the title bar Currently, this value is a constant.
protected static Font getTitleFont()
          Get the font being used for the dialog title.
 CharSequence getTitleSequence()
          Obtain the title of the window Obtains the title of the window that was set via a constructor or by a call to setTitle(java.lang.String).
 int getWidthToFitTitle()
          Get the dialog width that will fit the title exactly, accounting for any top frame buttons.
 int getWindowStyle()
           
 boolean handleButtonShortcut(char shortcut, Event event)
          Handle shortcuts for buttons in the container.
protected  boolean handleFrameButtonShortcut(int position)
          Handle a frame button shortcut This method is called to handle a shortcut for a particular frame button.
 boolean handleShortcutKey(Event e)
          Handle a shortcut key event.
 boolean hasVisibleFrameButtons()
          Determine whether this dialog has any visible frame buttons.
 void hide()
          Hide the dialog window.
protected  void layoutTopFrameButtons()
          This is called automatically to position the top frame buttons in the dialog.
 void paint(Pen pen)
          Draw the contents of this View.
protected  void positionDialog()
          This method is called to position the dialog.
 boolean receiveEvent(Event e)
          Entry point for event processing.
 void reflowFrameButtons()
           
 void removeAllChildren()
          Remove all child views.
 void removeFrameButtonWithID(int id)
          Remove a frame button.
 void setAutoCenter(boolean autoCenter)
          Use this method to specify whether the dialog should be automatically centered in positionDialog().
 void setAutoSize(boolean doAutoSize)
          Specify whether the window should be automatically resized.
 void setAutoSizeHeight(boolean doAutoSize)
          Specify whether the window's height should be set automatically.
 void setAutoSizeWidth(boolean doAutoSize)
          Specify whether the window's width should be set automatically.
 void setBackEvent(Event e)
          Specifies an event to send when the BACK button is pressed.
 void setBorders(int inLeft, int inTop, int inRight, int inBottom)
          Set the width of the borders.
 void setCancelButtonEvent(Event e)
          Specifies the event to be sent when the user selects the Cancel button.
 void setCenterTitle(boolean center)
          Set a flag that tells the dialog to center its title.
 void setContentSize(int width, int height)
          Resize the window Sets the size of the window such that the content rect is the given size.
 void setDefaultFrameButton(Button button)
          Set the default frame button.
 void setDefaultFrameButton(int which)
          Set the default frame button.
protected  void setDrawBottomFrame(boolean drawFrame)
          Specify whether to draw the bottom frame of the dialog.
 void setEventForControlWithID(int id, Event newEvent)
          Set the event for the control with the given id.
protected  boolean setEventForFrameButtonWithID(int id, Event newEvent)
          Set the event for the frame button with the given id.
 void setFocusedChild(View inNewFocus)
          Convenience method which simply calls setFocusedChild(newFocus, true).
 void setFocusedDescendant(View inNewFocus, boolean inFromAbove)
          Set the focus for the container to be the child which is, or which has as a descendant, the given view.
 void setForceDrawBottomFrame(boolean drawFrame)
          Specify whether the bottom frame should be drawn, even if there's nothing in the frame.
 void setFrameButtonShortcut(int position, char shortcut)
          Set the shortcut for a frame button The shortcut will not display or require any modifier keys (MENU, ALT, or SHIFT).
 void setFrameButtonShortcut(int position, char shortcut, int modifiers)
          Set the shortcut for a frame button
 void setHideOnButtonEvent(boolean hide)
          Use this method to specify whether the dialog should be automatically hidden when the user selects a frame button.
 void setHideOnButtonWithID(int id, boolean hide)
          Use this method to specify whether the dialog should be automatically hidden when the user selects the frame button with the specified id.
 void setHideOnButtonWithPosition(int position, boolean hide)
          Use this method to specify whether the dialog should be automatically hidden when the user selects the frame button with the specified position.
 void setLayoutBottomFrameButtonsVertically(boolean flag)
          Layout buttons vertically instead of horizontally.
 void setListener(Listener inListener)
          Set the listener for the dialog.
 void setNoDefaultFrameButton()
          Specify that no frame button should be focused when the dialog is first displayed.
 void setShowCancel(boolean showCancel)
          Specify whether a cancel button should be displayed.
 void setShowTone(int resourceID)
          Specify a tone to play while the dialog is showing.
 void setShowTone(RingToneObject tone)
          Specify a tone to play while the dialog is showing.
 void setSize(int width, int height)
          Set the size of the dialog.
 void setSleepScreenMessage(CharSequence message)
          Set the message to display on the sleep screen when this dialog is up while the device is in keyguard mode
 void setSleepScreenMessage(String message)
          Set the message to display on the sleep screen when this dialog is up while the device is in keyguard mode
 void setTitle(CharSequence inTitle)
          Specifies the title of the window Sets the title to appear in the upper left of the window.
 void setTitle(String inTitle)
          Specifies the title of the window Sets the title to appear in the upper left of the window.
 void setWidthToFitTitle()
          Resize the window to fit the title This method changes the width of the dialog to fit the title exactly, accounting for any top frame buttons.
 void setWindowStyle(int windowStyle)
          Set the window style.
 void show()
          Show the dialog.
 void show(int alertType)
          Show the dialog.
 void show(int alertType, boolean withPendingSound)
          Show the dialog.
protected  void showInternal()
          Actually shows the dialog.
 void snapToChildren(int inLeft, int inTop, int inRight, int inBottom)
          Resize the dialog to fit the children, with the given gaps.
protected  void startShowTone()
          Starts playing the tone specified with setShowTone(danger.audio.RingToneObject).
protected  void stopShowTone()
          Stops playing the tone specified with setShowTone(danger.audio.RingToneObject).
protected  void updateBottomButtonWidths()
          This is called automatically to set the width of the bottom frame buttons.
protected  void updateFrameButtonColors()
          This is called automatically to change the color of the buttons depending on the window style.
 boolean wantsEndButton()
          Whether the window wants to receive END button events instead of page down.
 boolean wantsSendButton()
          Whether the window wants to receive SEND button events instead of page down.
 
Methods inherited from class danger.ui.Window
adjustActionMenuState, advanceFocus, autoHide, autoHideIfIdle, autoHideIfIdle, blocksBackButton, blocksFloatingControls, blocksKeyGuard, blocksVolumeButtons, centerHorizontal, centerOnScreen, centerUnderTitleBar, centerVertical, disableControlWithID, dropOrphanedEvents, enableControlWithID, forwardQueuedEvents, getApplication, getDefaultFocus, getIDOfChild, getListener, getWindowBelow, hideActiveMenu, hideControlWithID, incrementMaxChildID, isActionMenuVisible, isFullScreen, isUnresponsive, onActivate, onDeactivate, onPeriodicPulse, onWindowPaint, receiveMessage, reverseFocus, setDefaultFocus, setDefaultListener, setEventArgForControlWithID, setFullScreen, setMaxChildID, setMaxControlID, setPosition, setTitled, setTitleFormatDate, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, shouldDropEvent, showControlWithID, startQueueingEvents, 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, 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, invalidate, invalidateIndependentOfOrigin, invalidateIndependentOfOrigin, isEnabled, isFocusable, isFocused, isOnScreen, isTransparent, isVisible, isVisibleInHierarchy, isVisibleOnScreen, justSetVisible, localToGlobal, localToGlobal, localToGlobalH, localToGlobalV, localToWindow, moveBy, notifyWhenParentSizeChanges, notifyWhenPositionChanges, notifyWhenSizeChanges, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onEnabledStateChanged, onHide, onPositionChanged, onRemovedFromParent, onShortcut, onShortcut, onShortcutConsumed, onShow, onSizeChanged, onStyleChanged, onViewPositionChanged, onViewSizeChanged, playLimitSound, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setAtAndSpacePage, setBackground, setBackgroundColor, setBottom, setDebugBounds, setDynamicPosition, setDynamicWidth, setEnabled, setFocusTraversalDirection, setFocusTraversalFrom, setFocusTraversalPolicy, setFrame, setHeight, setKeyedValue, setLabelFont, setLeft, setMakeLimitNoise, setOrigin, setOrigin, setPartialFocusOK, setPreferredDirection, setRight, setScrollFocusMargin, setStyle, setStyleColor, setStyleFont, setStyleFrameColor, setTop, setTransparent, 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

mAutoSizeWidth

protected boolean mAutoSizeWidth
Deprecated. Use setAutoSize(boolean) or setAutoSizeWidth(boolean) instead.

mAutoSizeHeight

protected boolean mAutoSizeHeight
Deprecated. Use setAutoSize(boolean) or setAutoSizeHeight(boolean) instead.

mBackEvent

protected Event mBackEvent
Deprecated. Use setBackEvent(danger.app.Event) instead.

mCancelEvent

protected Event mCancelEvent
Deprecated. Use setCancelButtonEvent(danger.app.Event) instead.

m_leftBorder

protected int m_leftBorder
Deprecated. Use setBorders(int, int, int, int) instead.

m_rightBorder

protected int m_rightBorder
Deprecated. Use setBorders(int, int, int, int) instead.

m_topBorder

protected int m_topBorder
Deprecated. Use setBorders(int, int, int, int) instead.

m_bottomBorder

protected int m_bottomBorder
Deprecated. Use setBorders(int, int, int, int) instead.

m_autoCenter

protected boolean m_autoCenter
Deprecated. Use setAutoCenter(boolean) instead.

m_showTone

protected RingToneObject m_showTone
Deprecated. Use setShowTone(danger.audio.RingToneObject) instead.

m_showToneID

protected int m_showToneID
Deprecated. Use setShowTone(int) instead.

mNeedToAddTopFrameButtons

protected boolean mNeedToAddTopFrameButtons
Deprecated. For internal use only.

mNeedToAddBottomFrameButtons

protected boolean mNeedToAddBottomFrameButtons
Deprecated. For internal use only.

mButtons

protected Button[] mButtons
Deprecated. For internal use only.

mShortcuts

protected char[] mShortcuts
Deprecated. For internal use only.

mShortcutModifiers

protected int[] mShortcutModifiers
Deprecated. For internal use only.

mButtonIDs

protected int[] mButtonIDs
Deprecated. For internal use only.

mDefaultButtonPosition

protected int mDefaultButtonPosition
Deprecated. Use setDefaultFrameButton(int) instead.

mDefaultButton

protected Button mDefaultButton
Deprecated. Use setDefaultFrameButton(Button) instead.

mHideOnButton

protected boolean[] mHideOnButton
Deprecated. Use setHideOnButtonEvent(boolean), setHideOnButtonWithID(int,boolean) or setHideOnButtonWithPosition(int,boolean) instead.

mLayoutButtonsVertically

protected boolean mLayoutButtonsVertically
Deprecated. Use setLayoutBottomFrameButtonsVertically(boolean) instead.

mListener

protected Listener mListener
Deprecated. Use setListener(danger.app.Listener) instead.

mRegisteredForKeyGuardEvent

protected boolean mRegisteredForKeyGuardEvent
Deprecated. For internal use only.

m_toneAlarm

protected Alarm m_toneAlarm
Deprecated. For internal use only.

mCenterTitle

protected boolean mCenterTitle
Deprecated. Use setCenterTitle(boolean) instead.

BUTTON_HEIGHT

protected static final int BUTTON_HEIGHT
Deprecated. For internal use only.
See Also:
Constant Field Values

BOTTOM_POSITION1

public static final int BOTTOM_POSITION1
Specifies the bottom rightmost frame button position.

See Also:
Constant Field Values

BOTTOM_POSITION2

public static final int BOTTOM_POSITION2
Specifies the bottom middle frame button position.

See Also:
Constant Field Values

BOTTOM_POSITION3

public static final int BOTTOM_POSITION3
Specifies the bottom leftmost frame button position.

See Also:
Constant Field Values

TOP_POSITION1

public static final int TOP_POSITION1
Specifies the top rightmost frame button position.

See Also:
Constant Field Values

TOP_POSITION2

public static final int TOP_POSITION2
Specifies the top leftmost frame button position.

See Also:
Constant Field Values

MAX_BUTTONS

protected static final int MAX_BUTTONS
Deprecated. For internal use only.
See Also:
Constant Field Values

MAX_BOTTOM_BUTTONS

protected static final int MAX_BOTTOM_BUTTONS
Deprecated. For internal use only.
See Also:
Constant Field Values

APP_DIALOG_STYLE

public static final int APP_DIALOG_STYLE
Constant to be used with setWindowStyle(int) or a constructor.

Specifies that the window is a standard application dialog.

See Also:
Constant Field Values

SYSTEM_DIALOG_STYLE

public static final int SYSTEM_DIALOG_STYLE
Constant to be used with setWindowStyle(int) or a constructor.

Specifies that the window is a system dialog, with a light blue border. System dialogs float over other all applications. They also cause a pending notification ring if the user has not turned that system setting off.

See Also:
Constant Field Values

SYSTEM_ERROR_STYLE

public static final int SYSTEM_ERROR_STYLE
Constant to be used with setWindowStyle(int) or a constructor.

Specifies that the window is a system error dialog. The only difference between this and a system dialog is that a red border appears in the dialog.

See Also:
Constant Field Values

APP_ALERT_STYLE

public static final int APP_ALERT_STYLE
Constant to be used with setWindowStyle(int) or a constructor.

Specifies that the window is an application dialog with a red border.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_GENERAL

public static final int SYSTEM_ALERT_TYPE_GENERAL
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies a general alert type.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_INCOMING_CALL

public static final int SYSTEM_ALERT_TYPE_INCOMING_CALL
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies that the dialog is a result of an incoming phone call.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_MISSED_CALL

public static final int SYSTEM_ALERT_TYPE_MISSED_CALL
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies that the dialog is a result of a missed phone call.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_ALARM

public static final int SYSTEM_ALERT_TYPE_ALARM
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies that the dialog is a result of a calendar alarm.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_CONTROL

public static final int SYSTEM_ALERT_TYPE_CONTROL
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies that the dialog is the sound controls dialog.

See Also:
Constant Field Values

SYSTEM_ALERT_TYPE_PERSISTENT_CONTROL

public static final int SYSTEM_ALERT_TYPE_PERSISTENT_CONTROL
Constant to be used with show(int). Only relevant for system dialogs and system error dialogs.

Specifies that the dialog is a persistent control. It will appear behind all other system alerts.

See Also:
Constant Field Values

SHOW_STATE_HIDDEN

public static final int SHOW_STATE_HIDDEN
Constant returned by getShowState().

See Also:
Constant Field Values

SHOW_STATE_SHOWING

public static final int SHOW_STATE_SHOWING
Constant returned by getShowState().

See Also:
Constant Field Values

SHOW_STATE_VISIBLE

public static final int SHOW_STATE_VISIBLE
Constant returned by getShowState().

See Also:
Constant Field Values
Constructor Detail

DialogWindow

public DialogWindow()
Construct an instance. This default constructor creates a dialog with APP_DIALOG_STYLE, no title, and a cancel button.


DialogWindow

public DialogWindow(boolean showCancel)
Construct an instance. This constructor creates a dialog with APP_DIALOG_STYLE and no title.

Parameters:
showCancel - whether to show the cancel button or not

DialogWindow

public DialogWindow(String inTitle)
Construct an instance. This constructor creates a dialog with APP_DIALOG_STYLE and a cancel button.

Parameters:
inTitle - the title of the dialog

DialogWindow

public DialogWindow(CharSequence inTitle)
Construct an instance. This constructor creates a dialog with APP_DIALOG_STYLE and a cancel button.

Parameters:
inTitle - the title of the dialog

DialogWindow

public DialogWindow(String inTitle,
                    int windowStyle)
Construct an instance. If you specify APP_DIALOG_STYLE as the style, then the dialog includes a cancel button; otherwise, it does not.

Parameters:
inTitle - the title of the dialog
windowStyle - the window style. This should be one of APP_DIALOG_STYLE, APP_ALERT_STYLE, SYSTEM_DIALOG_STYLE, or SYSTEM_ERROR_STYLE. See setWindowStyle for a description of the styles.

DialogWindow

public DialogWindow(CharSequence inTitle,
                    int windowStyle)
Construct an instance. If you specify APP_DIALOG_STYLE as the style, then the dialog includes a cancel button; otherwise, it does not.

Parameters:
inTitle - the title of the dialog
windowStyle - the window style. This should be one of APP_DIALOG_STYLE, APP_ALERT_STYLE, SYSTEM_DIALOG_STYLE, or SYSTEM_ERROR_STYLE. See setWindowStyle for a description of the styles.

DialogWindow

public DialogWindow(String inTitle,
                    int windowStyle,
                    boolean showCancel)
Construct an instance.

Parameters:
inTitle - the title of the dialog
windowStyle - the window style. This should be one of APP_DIALOG_STYLE, APP_ALERT_STYLE, SYSTEM_DIALOG_STYLE, or SYSTEM_ERROR_STYLE. See setWindowStyle for a description of the styles.
showCancel - whether to show the cancel button or not

DialogWindow

public DialogWindow(CharSequence inTitle,
                    int windowStyle,
                    boolean showCancel)
Construct an instance.

Parameters:
inTitle - the title of the dialog
windowStyle - the window style. This should be one of APP_DIALOG_STYLE, APP_ALERT_STYLE, SYSTEM_DIALOG_STYLE, or SYSTEM_ERROR_STYLE. See setWindowStyle for a description of the styles.
showCancel - whether to show the cancel button or not
Method Detail

wantsSendButton

public boolean wantsSendButton()
Description copied from class: Window
Whether the window wants to receive SEND button events instead of page down.

Overrides:
wantsSendButton in class Window
Returns:
A boolean containing true if the window wants to receive EVENT_WIDGET_{DOWN,UP}(DEVICE_BUTTON_SEND) for the SEND button instead of EVENT_WIDGET_DOWN(DEVICE_WHEEL_PAGE_DOWN)

wantsEndButton

public boolean wantsEndButton()
Description copied from class: Window
Whether the window wants to receive END button events instead of page down.

Overrides:
wantsEndButton in class Window
Returns:
A boolean containing true if the window wants to receive EVENT_WIDGET_{DOWN,UP}(DEVICE_BUTTON_END) for the END button instead of EVENT_WIDGET_UP(DEVICE_WHEEL_PAGE_UP)

setWindowStyle

public void setWindowStyle(int windowStyle)
Set the window style. This method should not be called after calling show(). The window style determines not only appearance, but also behavior. Dialogs with SYSTEM_DIALOG_STYLE or SYSTEM_ERROR_STYLE float over all applications. They also cause a pending notification ring if the user has not turned that system setting off. The only difference between SYSTEM_DIALOG_STYLE and SYSTEM_ERROR_STYLE is that the error style dialogs have a red border. They otherwise appear and behave the same.

Parameters:
windowStyle - the window style. This should be one of APP_DIALOG_STYLE, APP_ALERT_STYLE, SYSTEM_DIALOG_STYLE, or SYSTEM_ERROR_STYLE.

getWindowStyle

public int getWindowStyle()

removeAllChildren

public void removeAllChildren()
Remove all child views.

Overrides:
removeAllChildren in class Container
See Also:
Container.removeAllChildren()

disableButtonOnEmptyField

public void disableButtonOnEmptyField(int buttonID,
                                      int fieldID)
Specifies that the specified button should be disabled whenever the specified text field is empty. Call this method once and the enabling/disabling will be handled automatically.

Parameters:
buttonID - the id of the button to disable
fieldID - the id of the text field to monitor

disableBottomRightButtonOnEmptyField

public void disableBottomRightButtonOnEmptyField(TextField textField)
Specifies that the bottom right frame button should be disabled whenever the specified text field is empty. Call this method once and the enabling/disabling will be handled automatically.

Parameters:
textField - the text field to monitor

addTopFrameButtons

protected void addTopFrameButtons()
Add the top frame buttons to the window. This method adds any top frame buttons to the window by calling addChild(). Generally, you should not have to call or override this method. You should instead use addTopFrameButton(java.lang.String, int, int, java.lang.Object, char) or addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char) to specify a top frame button to add. The dialog will keep track of these buttons and then add them using this method automatically.


getNumTopFrameButtons

public int getNumTopFrameButtons()

hasVisibleFrameButtons

public boolean hasVisibleFrameButtons()
Determine whether this dialog has any visible frame buttons.


addBottomFrameButtons

protected void addBottomFrameButtons()
Add the bottom frame buttons to the window. This method adds any bottom frame buttons to the window by calling addChild(). Generally, you should not have to call or override this method. You should instead use addBottomFrameButton(java.lang.String, int, int, java.lang.Object, char) or addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char) to specify a bottom frame button to add. The dialog will keep track of these buttons and then add them using this method automatically.


setShowCancel

public void setShowCancel(boolean showCancel)
Specify whether a cancel button should be displayed. This method should not be called after calling show(). If the cancel button is displayed, it will appear in the top right of the dialog, with no shortcut. You may specify an event to be sent when the user selects the button, by using the method setCancelButtonEvent(danger.app.Event). Unless you call setHideOnButtonEvent(boolean), the dialog will be automatically be hidden when the user selects this button. If you want the cancel button in a different position, or with a shortcut, then you should use addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char).

Parameters:
showCancel - whether to show the cancel button or not

setListener

public void setListener(Listener inListener)
Set the listener for the dialog. This method sets the listener for the window. The listener is the object that will receive events that occur in the dialog window.

Parameters:
inListener - A Listener that will receive events from the window.

getChildWithID

public View getChildWithID(int id)
Get the child view with the given id. This will return the child (direct descendant) with the given id, as long as that child has been added with a call to Container.addChild(danger.ui.View). It will also return a frame button with the given id, even if that button has not yet been automatically added with Container.addChild(danger.ui.View). Returns null if there is no direct descendant with the given id. It is generally better to call getDescendantWithID(int), which works even if the view is nested inside other containers. getDescendantWithID(int) is also slightly faster. Use getChildWithID(int) only when you need the behavior that it returns null if it's not a direct descendant.

Overrides:
getChildWithID in class Container
Parameters:
id - the id of the child to obtain
Returns:
the child view with the given id
See Also:
Container.getChildWithID(int)

getDescendantWithID

public View getDescendantWithID(int id)
Get the descendant view with the given id. This will return the descendant with the given id, as long as that descendant has been added to this window or a descendant of this window, with a call to Container.addChild(danger.ui.View). It will also return a frame button with the given id, even if that button has not yet been automatically added with Container.addChild(danger.ui.View). Returns null if there is no descendant with the given id.

Overrides:
getDescendantWithID in class Window
Parameters:
id - the id of the descendant to obtain
Returns:
the descendant view with the given id
See Also:
Container.getChildWithID(int)

getCancelButton

protected Button getCancelButton()
This method will return the cancel button, if there is any.

Returns:
the cancel button, or null if there is none

getFrameButtonWithID

protected Button getFrameButtonWithID(int id)
Get the frame button with the given id. This will return a frame button with the given id. You can alternatively call getChildWithID(int).

Parameters:
id - the id of the frame button to obtain
Returns:
the frame button with the given id

setEventForControlWithID

public void setEventForControlWithID(int id,
                                     Event newEvent)
Set the event for the control with the given id. This method will set the event for the control with the given id. This works for any descendant control, and also for any frame button.

Overrides:
setEventForControlWithID in class Window
Parameters:
id - the id of the control
newEvent - the new event to be used
See Also:
Window.setEventForControlWithID(int, danger.app.Event)

setEventForFrameButtonWithID

protected boolean setEventForFrameButtonWithID(int id,
                                               Event newEvent)
Set the event for the frame button with the given id. You can alternatively call setEventForControlWithID(int, danger.app.Event).

Parameters:
id - the id of the frame button
newEvent - the new event to be used

addBottomFrameButton

public Button addBottomFrameButton(String buttonStr,
                                   int eventType,
                                   int data,
                                   Object arg,
                                   char shortcut)
Add a button to the dialog window. Adds a new button to the dialog window. Up to three buttons can be defined. By default, the buttons are laid out across the bottom of the window in order from right to left. The first two buttons are right justified and the third is left justified. To have the buttons layed out vertically, see the layoutBottomFrameButtonsVertically method.


addBottomFrameButton

public Button addBottomFrameButton(CharSequence buttonStr,
                                   int eventType,
                                   int data,
                                   Object arg,
                                   char shortcut)

addTopFrameButton

public Button addTopFrameButton(String buttonStr,
                                int eventType,
                                int data,
                                Object arg,
                                char shortcut)
Add a top frame button to the dialog. Specifies a new button to be added to the top of the dialog. You can specify up to two top frame buttons. The button is placed in the top right position if that is not already occupied. Otherwise, it is placed in the top left position. If both top positions are full, then the method returns null and does not add the button. The button is not actually added until show() is called. If you need more control (for example, specifying a button id, or an explicit position), then use addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char) instead.

Parameters:
buttonStr - the title of the button
eventType - the event type for the button event
data - the data for the button event
arg - the argument for the button event
shortcut - the shortcut for the button
Returns:
null-ok; the button, or null if there is no room

addTopFrameButton

public Button addTopFrameButton(CharSequence buttonStr,
                                int eventType,
                                int data,
                                Object arg,
                                char shortcut)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int flags,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut)
Add a button to the dialog window. Adds a new button to the dialog window. Up to three buttons can be defined. By default, the buttons are laid out across the bottom of the window in order from right to left. The first two buttons are right justified and the third is left justified. To have the buttons layed out vertically, see setLayoutBottomFrameButtonsVertically


addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int flags,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int flags,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int flags,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int flags,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)
Add a frame button to the dialog. Specifies a new button to be added to the dialog. The button is not actually added until show() is called.

Parameters:
position - where to put the button. This should be one of TOP_POSITION1 (top right), TOP_POSITION2, BOTTOM_POSITION1 (bottom right), BOTTOM_POSITION2, or BOTTOM_POSITION3 (bottom left).
buttonStr - the title of the button
flags - some combination of AlertResourceDecoder constants ALERT_BUTTON_FLAG_*_BUTTON, ALERT_BUTTON_FLAG_MENU_SHORTCUT, ALERT_BUTTON_FLAG_SHIFT_SHORTCUT, ALERT_BUTTON_FLAG_ALT_SHORTCUT, ALERT_BUTTON_FLAG_DONT_HIDE_ON_BUTTON_EVENT, and ALERT_BUTTON_FLAG_DEFAULT_BUTTON. The first four flags specify the title; if you use one of these flags, then buttonStr is ignored.
eventType - the event type for the button event
eventWhat - the Event.what parameter for the button event
data - the data for the button event
arg - the argument for the button event
shortcut - the shortcut for the button
id - the id of the button
Returns:
the button

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int flags,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int eventType,
                             int data,
                             Object arg)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int eventType,
                             int data,
                             Object arg)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int id)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int eventType,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)
See Also:
"below"

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)

addFrameButton

public Button addFrameButton(int position,
                             String buttonStr,
                             Listener eventListener,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)
Add a button to the dialog window. Adds a new button to the dialog window. Up to three buttons can be defined. The buttonStr is the name of the button. The eventType, data, and arg parameters are used when creating the new event to be sent to the ReceiveEvent method of the listener. The shortcut (1-3) maps to one of the devicewidgets: 1 = Menu, 2 = Jump, and 3 = Back. By default, the buttons are laid out across the bottom of the window in order from right(#1 button) to left(#3 button). The first two buttons are right justified and the third is left justified. To have the buttons layed out vertically, see the layoutBottomFrameButtonsVertically method. Currently, the shortcut modifiers are displayed correctly but only Shortcut.MODIFIER_MENU is actually handled correctly.

Parameters:
position - values of 1-3, indicates which button to assign.
buttonStr - A String containing the label for the button.
eventListener - Listener for the button event
eventType - An int containing the event type to be sent when the button is chosen.
eventWhat - An int containing the Event.what parameter to be sent when the button is chosen.
data - An int containing any additional data to be sent in the event.
arg - An Object containing an object reference to be sent in the event.
shortcut - A char specifying the shortcut to be used for the button.
shortcutModifiers - Some combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT.
id - An id which can be used to reference the button in the future.
See Also:
Shortcut

addFrameButton

public Button addFrameButton(int position,
                             CharSequence buttonStr,
                             Listener eventListener,
                             int eventType,
                             int eventWhat,
                             int data,
                             Object arg,
                             char shortcut,
                             int shortcutModifiers,
                             int id)

removeFrameButtonWithID

public void removeFrameButtonWithID(int id)
Remove a frame button. Removes a frame button with the given id. You should use this call, rather than Container.removeChild(danger.ui.View) or View.hide(). The frame button should have been added using a call to addTopFrameButton(java.lang.String, int, int, java.lang.Object, char), addBottomFrameButton(java.lang.String, int, int, java.lang.Object, char), or addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char).

Parameters:
id - the id of the frame button to remove.

setFrameButtonShortcut

public void setFrameButtonShortcut(int position,
                                   char shortcut)
Set the shortcut for a frame button The shortcut will not display or require any modifier keys (MENU, ALT, or SHIFT).

Parameters:
position - the position of the button to modify. This should be one of TOP_POSITION1, TOP_POSITION2, etc.
shortcut - the new shortcut key

setFrameButtonShortcut

public void setFrameButtonShortcut(int position,
                                   char shortcut,
                                   int modifiers)
Set the shortcut for a frame button

Parameters:
position - the position of the button to modify. This should be one of TOP_POSITION1, TOP_POSITION2, etc.
shortcut - the new shortcut key
modifiers - Some combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT. Currently, only Shortcut.MODIFIER_MENU is handled correctly. The others are displayed correctly, but not handled correctly. Specify 0 if no modifiers are required.

setDefaultFrameButton

public void setDefaultFrameButton(int which)
Set the default frame button. Note: {#link #setDefaultFocus} has precedence over setDefaultFrameButton(int). In other words, if you call both setDefaultFrameButton(int) and Window.setDefaultFocus(danger.ui.View), then whatever was set with Window.setDefaultFocus(danger.ui.View) will be focused.

Parameters:
which - the position of the frame button that should have default focus when the dialog is first displayed. This should be one of TOP_POSITION1, TOP_POSITION2, etc.

setDefaultFrameButton

public void setDefaultFrameButton(Button button)
Set the default frame button. Note: {#link #setDefaultFocus} has precedence over setDefaultFrameButton(int). In other words, if you call both setDefaultFrameButton(int) and Window.setDefaultFocus(danger.ui.View), then whatever was set with Window.setDefaultFocus(danger.ui.View) will be focused.

Parameters:
button - the button that should have default focus when the dialog is first displayed

setNoDefaultFrameButton

public void setNoDefaultFrameButton()
Specify that no frame button should be focused when the dialog is first displayed.


getDefaultFrameButton

public Button getDefaultFrameButton()
Get the frame button with initial focus.

Returns:
the button that would receive initial focus when the dialog is first displayed.

setLayoutBottomFrameButtonsVertically

public void setLayoutBottomFrameButtonsVertically(boolean flag)
Layout buttons vertically instead of horizontally. Pass true to this method when you want the buttons layed out vertically from top to bottom along the left side of the window. Button 1 will closest to the top, button 3 will be closest to the bottom. When false is passed, the default horizontal layout will be performed.


updateFrameButtonColors

protected void updateFrameButtonColors()
This is called automatically to change the color of the buttons depending on the window style. You generally will not have to call or override this method.


layoutTopFrameButtons

protected void layoutTopFrameButtons()
This is called automatically to position the top frame buttons in the dialog. You generally will not have to call or override this method.


calcBottom

protected int calcBottom()
This is called automatically to determine positions of vertical frame buttons. You generally will not have to call or override this method.


updateBottomButtonWidths

protected void updateBottomButtonWidths()
This is called automatically to set the width of the bottom frame buttons. You generally will not have to call or override this method.


convertShortcutKeyToButtonIndex

public int convertShortcutKeyToButtonIndex(Event e)
This is called automatically to determine if a shortcut key matches a shortcut for a frame button. You generally will not have to call or override this method.

Parameters:
e - the event to test
Returns:
null-ok; the position of the button whose shortcut this event matches, or null if there is no match

convertShortcutKeyToButtonIndex

protected int convertShortcutKeyToButtonIndex(char key,
                                              Event event)
This is called automatically to determine if a shortcut key matches a shortcut for a frame button. You generally will not have to call or override this method.

Parameters:
key - the key to test
event - the event, which can be used to match modifier keys
Returns:
null-ok; the position of the button whose shortcut this event matches, or null if there is no match

handleShortcutKey

public boolean handleShortcutKey(Event e)
Handle a shortcut key event. This method is called when the user presses a key. The default behavior is to see if the key matches any of the shortcuts for the frame buttons and act accordingly. Override this method if you want to handle these events yourself.

Parameters:
e - An Event containing the shortcut event that was received.

handleFrameButtonShortcut

protected boolean handleFrameButtonShortcut(int position)
Handle a frame button shortcut This method is called to handle a shortcut for a particular frame button. The default behavior is to call activateFrameButton(int), which results in sending an appropriate event. Override this method if you want to handle this yourself.

Parameters:
position - the position of the button whose shortcut this should handle. One of TOP_POSITION1, TOP_POSITION2, etc.

handleButtonShortcut

public boolean handleButtonShortcut(char shortcut,
                                    Event event)
Description copied from class: Container
Handle shortcuts for buttons in the container. This method is not called automatically, because doing so for every possible shortcut may degrade performance. However, if that is not an issue, then you can call this method yourself from within Container.eventShortcut(char, danger.app.Event) in your Window.

Overrides:
handleButtonShortcut in class Container

eventShortcut

public boolean eventShortcut(char shortcut,
                             Event event)
Handles shortcuts for frame buttons. This method calls handleShortcutKey(danger.app.Event) to handle the shortcut.

Overrides:
eventShortcut in class Container
Parameters:
shortcut - the key that was pressed
event - the event associated with the key press
Returns:
true if the shortcut was handled
See Also:
View.eventShortcut(char, danger.app.Event)

activateFrameButton

protected void activateFrameButton(int position)
Activates the frame button with the given position. This method sends an event to the window. The event is one of EVENT_BUTTON1, EVENT_BUTTON2, ..., EVENT_BUTTON5. The event is then handled in receiveEvent(danger.app.Event), where the event associated with this button (in addFrameButton(int, java.lang.String, int, int, int, java.lang.Object, char) is sent, and the window is hidden unless setHideOnButtonEvent(boolean) has been called.

Parameters:
position - the position of the button to activate. One of TOP_POSITION1, TOP_POSITION2, etc.

setCancelButtonEvent

public void setCancelButtonEvent(Event e)
Specifies the event to be sent when the user selects the Cancel button. The Cancel button must have been automatically added, either by using an appopriate constructor, or by calling setShowCancel(boolean).

Parameters:
e - the event to be sent

setBackEvent

public void setBackEvent(Event e)
Specifies an event to send when the BACK button is pressed. Frame button shortcuts supercede this action. In other words, if a frame button has BACK as the shortcut, and the user presses BACK, then the event associated with that frame button is sent, rather than the event specified here.

Parameters:
e - the event to be sent

setTitle

public void setTitle(String inTitle)
Specifies the title of the window Sets the title to appear in the upper left of the window.

Overrides:
setTitle in class Window
Parameters:
inTitle - the title of the window

setTitle

public final void setTitle(CharSequence inTitle)
Specifies the title of the window Sets the title to appear in the upper left of the window.

Overrides:
setTitle in class Window
Parameters:
inTitle - the title of the window

getTitle

public String getTitle()
Obtain the title of the window Obtains the title of the window that was set via a constructor or by a call to setTitle(java.lang.String)

Overrides:
getTitle in class Window
Returns:
the title of the window

getTitleSequence

public final CharSequence getTitleSequence()
Obtain the title of the window Obtains the title of the window that was set via a constructor or by a call to setTitle(java.lang.String). This method is a mess so that if somebody has overridden getTitle() it will use that instead of what it thinks internally the title should be.

Overrides:
getTitleSequence in class Window
Returns:
the title of the window

getTitleBarHeight

public int getTitleBarHeight()
Get the height of the title bar Currently, this value is a constant.

Returns:
the height of the title bar

setWidthToFitTitle

public void setWidthToFitTitle()
Resize the window to fit the title This method changes the width of the dialog to fit the title exactly, accounting for any top frame buttons. It calls getWidthToFitTitle() to determine the width. Please note that this method may grow or shrink the dialog, so if you don't want it to shrink, you may want to first call getWidthToFitTitle() and compare it with the current width.


getWidthToFitTitle

public int getWidthToFitTitle()
Get the dialog width that will fit the title exactly, accounting for any top frame buttons.


getContentRect

public Rect getContentRect()
Get the content rect Returns the content rect of the dialog, which does not include the top or bottom frames (or frame buttons). The left and right sides of the rect correspond to the edges of the top and bottom frames.

Returns:
the content rect

setContentSize

public void setContentSize(int width,
                           int height)
Resize the window Sets the size of the window such that the content rect is the given size. After calling this method, a call to getContentRect() will return a rect with the given width and height.

Parameters:
width - the width of the content rect
height - the height of the content rect

setAutoSize

public void setAutoSize(boolean doAutoSize)
Specify whether the window should be automatically resized. This method does not resize the dialog immediately. Rather, it specifies whether to resize the dialog when show() is called. See setBorders(int, int, int, int) for more information.

Parameters:
doAutoSize - whether to automatically resize the dialog

setAutoSizeWidth

public void setAutoSizeWidth(boolean doAutoSize)
Specify whether the window's width should be set automatically. This sets this attribute independent of the height, which can be set using setAutoSizeHeight(boolean). Use setAutoSize(boolean) to set both attributes at the same time. This method does not resize the dialog immediately. Rather, it specifies how to resize the dialog when show() is called. See setBorders(int, int, int, int) for more information.

Parameters:
doAutoSize - whether to automatically set the dialog's width

setAutoSizeHeight

public void setAutoSizeHeight(boolean doAutoSize)
Specify whether the window's height should be set automatically. This sets this attribute independent of the width, which can be set using setAutoSizeWidth(boolean). Use setAutoSize(boolean) to set both attributes at the same time. This method does not resize the dialog immediately. Rather, it specifies how to resize the dialog when show() is called. See setBorders(int, int, int, int) for more information.

Parameters:
doAutoSize - whether to automatically set the dialog's height

setSize

public void setSize(int width,
                    int height)
Set the size of the dialog. Resizes the dialog to the given size. Also calls layoutTopFrameButtons() to account for the new width.

Overrides:
setSize in class Window
Parameters:
width - the width of the dialog
height - the height of the dialog

setFocusedChild

public void setFocusedChild(View inNewFocus)
Description copied from class: Container
Convenience method which simply calls setFocusedChild(newFocus, true).

Overrides:
setFocusedChild in class Container
Parameters:
inNewFocus - null-ok; the child which should assume focus or null if no child should have focus
See Also:
Container.setFocusedChild(danger.ui.View, boolean)

setFocusedDescendant

public void setFocusedDescendant(View inNewFocus,
                                 boolean inFromAbove)
Description copied from class: Container
Set the focus for the container to be the child which is, or which has as a descendant, the given view. This also sets the focus for each view in the heritage from this view to the given one, as necessary, so that, after this call completes, all of the views from the immediate child of this container down to the given view have focus. If the given view or any of its ancestors (not including this container) cannot take focus, then this method does nothing. If you pass null, then this indicates that whatever child currently has focus should lose focus, and if it has a child with focus, then that child should lose it too (etc.). This method throws an exception if you pass a non-null view that is not a descendant of this instance. It also throws an exception if any of the views in the heritage between this instance and the given view are not instances of Container.

Overrides:
setFocusedDescendant in class Container
Parameters:
inNewFocus - null-ok; the descendant which should assume focus or null if no descendant should have focus
inFromAbove - whether or not focus is coming in from above
See Also:
Container.setFocusedDescendant(danger.ui.View, boolean)

show

public void show()
Show the dialog. If the dialog is a system dialog, it is sent to the NotificationManager and will cause a pending alert notification sound.

Overrides:
show in class Window

show

public void show(int alertType)
Show the dialog. If the dialog is a system dialog, it is sent to the NotificationManager with the type depending on alertType. The dialog will cause a pending alert notification sound.

Parameters:
alertType - the type of alert. This is only relevant for system dialogs. This should be one of SYSTEM_ALERT_TYPE_GENERAL, SYSTEM_ALERT_TYPE_INCOMING_CALL, SYSTEM_ALERT_TYPE_MISSED_CALL, SYSTEM_ALERT_TYPE_ALARM, SYSTEM_ALERT_TYPE_CONTROL, or SYSTEM_ALERT_TYPE_PERSISTENT_CONTROL.

getShowState

public int getShowState()
Get the show state. Usually a dialog will be either hidden (SHOW_STATE_HIDDEN) or visible (SHOW_STATE_VISIBLE). However, system dialogs have a third, transitory state. When show() is called for a system dialog, an event is sent to the notification manager. At some time in the future, the dialog is actually shown. During this (usually brief) time, the dialog's state will be reported as SHOW_STATE_SHOWING.


show

public void show(int alertType,
                 boolean withPendingSound)
Show the dialog. If the dialog is a system dialog, it is sent to the NotificationManager with the type depending on alertType.

Parameters:
alertType - the type of alert. This is only relevant for system dialogs. This should be one of SYSTEM_ALERT_TYPE_GENERAL, SYSTEM_ALERT_TYPE_INCOMING_CALL, SYSTEM_ALERT_TYPE_MISSED_CALL, SYSTEM_ALERT_TYPE_ALARM, SYSTEM_ALERT_TYPE_CONTROL, or SYSTEMA_ALERT_TYPE_PERSISTENT_CONTROL.
withPendingSound - if this is a system dialog, then this parameter determines whether this dialog should cause a pending alert notification sound.

setShowTone

public void setShowTone(RingToneObject tone)
Specify a tone to play while the dialog is showing. The given tone is played when the dialog is shown. As soon as the dialog is hidden, or after one minute (whichever comes first), the tone will stop playing. The tone will not play while the device is in key guard mode.

Parameters:
tone - the tone to play

setShowTone

public void setShowTone(int resourceID)
Specify a tone to play while the dialog is showing. The given tone is played when the dialog is shown. As soon as the dialog is hidden, or after one minute (whichever comes first), the tone will stop playing. The tone will not play while the device is in key guard mode.

Parameters:
resourceID - resource id of the tone to play

reflowFrameButtons

public void reflowFrameButtons()

showInternal

protected void showInternal()
Actually shows the dialog. showInternal is called by show() if the dialog is an application dialog. Otherwise, it is called indirectly by the Notification Manager when it is time to show the dialog. Generally, you should not have to call or override this method.


hide

public void hide()
Hide the dialog window. Any associated ring tones (as specified by setShowTone(danger.audio.RingToneObject) will be stopped.

Overrides:
hide in class Window

startShowTone

protected void startShowTone()
Starts playing the tone specified with setShowTone(danger.audio.RingToneObject). Generally, you should not have to call or override this method.


stopShowTone

protected void stopShowTone()
Stops playing the tone specified with setShowTone(danger.audio.RingToneObject). Generally, you should not have to call or override this method.


positionDialog

protected void positionDialog()
This method is called to position the dialog. At the time that this method is called, the dialog's size has already been set. By default, positionDialog will center the dialog on the screen. Override this method if you want some other position. Alternatively, if you simply do not want positionDialog to center the dialog, then call setAutoCenter(boolean).


setAutoCenter

public void setAutoCenter(boolean autoCenter)
Use this method to specify whether the dialog should be automatically centered in positionDialog().

Parameters:
autoCenter - whether the dialog should be centered or not

getSleepScreenMessage

public String getSleepScreenMessage()
Deprecated. Use getSleepScreenMessageCharSequence instead


getSleepScreenMessageCharSequence

public CharSequence getSleepScreenMessageCharSequence()
Returns:
the message to display on the sleep screen when this dialog is up while the device is in keyguard mode

setSleepScreenMessage

public void setSleepScreenMessage(String message)
Set the message to display on the sleep screen when this dialog is up while the device is in keyguard mode


setSleepScreenMessage

public void setSleepScreenMessage(CharSequence message)
Set the message to display on the sleep screen when this dialog is up while the device is in keyguard mode


getSleepScreenImage

public Bitmap getSleepScreenImage()
Returns:
the image to display on the sleep screen when this dialog is up while the device is in keyguard mode

snapToChildren

public void snapToChildren(int inLeft,
                           int inTop,
                           int inRight,
                           int inBottom)
Resize the dialog to fit the children, with the given gaps. Generally, you should not call this method. Instead, use the call setBorders(int, int, int, int). snapToChildren is automatically called when you call show().

Overrides:
snapToChildren in class Container
Parameters:
inLeft - the width of the left border
inTop - the width of the top border
inRight - the width of the right border
inBottom - the width of the bottom border

paint

public void paint(Pen pen)
Description copied from class: View
Draw the contents of this View. This method is called by the graphics system when the View needs to be repainted. A Pen will be provided which is appropriately clipped and translated for drawing on this View.

The implementation of this method in this class will merely call clear() pen, if this View is opaque (not transparent), and will do nothing otherwise. If you don't need this behavior, then there is no point in calling super.paint() in an overriding method.

Overrides:
paint in class Container
Parameters:
pen - non-null; the pen to use for drawing operations
See Also:
View.paint(danger.ui.Pen)

drawDialogStyleFrame

protected void drawDialogStyleFrame(Pen p,
                                    int windowStyle)
Draw the frame for the dialog window. Generally, you should not have to call or override this method.

Parameters:
p - the pen to use
windowStyle - the type of window style frame to draw

receiveEvent

public 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. The default behavior is to do nothing and return false. Subclasses are expected to override this method to do something more useful.

Overrides:
receiveEvent in class Container
Parameters:
e - non-null; the event to process
Returns:
whether (true) or not (false) this method actually handled the event to completion
See Also:
Listener.receiveEvent(danger.app.Event)

blocksChooser

public boolean blocksChooser()
Description copied from class: Window
Whether the window blocks from going to the chooser Some applications, such as security/passcode lock and registration block from going to the chooser when the JUMP button is pressed.

Overrides:
blocksChooser in class Window
Returns:
A boolean containing true if the application blocks the chooser.

eventKeyUp

public boolean eventKeyUp(char c,
                          Event event)
Description copied from class: Container
Processes key releases directed at this container.

Overrides:
eventKeyUp in class Container
Parameters:
c - the character being released.
See Also:
View.eventKeyUp(char, danger.app.Event)

eventWidgetUp

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

Overrides:
eventWidgetUp in class Window
Parameters:
widget - the widget that went down
Returns:
whether or not the event was consumed
See Also:
View.eventWidgetUp(int, danger.app.Event)

eventWidgetDown

public boolean eventWidgetDown(int widget,
                               Event event)
Description copied from class: Window
Handle a button down event.

Overrides:
eventWidgetDown in class Window
Parameters:
widget - the widget that went up
Returns:
whether or not the event was consumed
See Also:
View.eventWidgetDown(int, danger.app.Event)

setDrawBottomFrame

protected void setDrawBottomFrame(boolean drawFrame)
Specify whether to draw the bottom frame of the dialog. Generally, you should not have to call or override this method.


setForceDrawBottomFrame

public void setForceDrawBottomFrame(boolean drawFrame)
Specify whether the bottom frame should be drawn, even if there's nothing in the frame. By default, it is not drawn if there are no buttons in it.


getTitleFont

protected static Font getTitleFont()
Get the font being used for the dialog title.


setHideOnButtonEvent

public void setHideOnButtonEvent(boolean hide)
Use this method to specify whether the dialog should be automatically hidden when the user selects a frame button. By default, this value is true. If you set it to false, you will have to manually hide the dialog for all button events. This method affects ALL frame buttons in the dialog. If you only want to make this change on one button, use setHideOnButtonWithID(int, boolean).

Parameters:
hide - whether the dialog should be hidden

setHideOnButtonWithID

public void setHideOnButtonWithID(int id,
                                  boolean hide)
Use this method to specify whether the dialog should be automatically hidden when the user selects the frame button with the specified id. By default, this value is true. If you set it to false, you will have to manually hide the dialog when the user selects the frame button with the specified id. If you want to make this change for ALL buttons in the dialog, then use setHideOnButtonEvent(boolean).

Parameters:
id - the id of the frame button
hide - whether the dialog should be hidden

setHideOnButtonWithPosition

public void setHideOnButtonWithPosition(int position,
                                        boolean hide)
Use this method to specify whether the dialog should be automatically hidden when the user selects the frame button with the specified position. By default, this value is true. If you set it to false, you will have to manually hide the dialog when the user selects the frame button with the specified position. If you want to make this change for ALL buttons in the dialog, then use setHideOnButtonEvent(boolean).

Parameters:
position - the position of the frame button (TOP_POSITION1, TOP_POSITION2, etc.)
hide - whether the dialog should be hidden

setBorders

public void setBorders(int inLeft,
                       int inTop,
                       int inRight,
                       int inBottom)
Set the width of the borders. This method is only relevant is auto size is turned on (it is by default; call setAutoSize(false) to turn it off). If auto size is turned on, then the dialog will be resized to fit its children with the given borders. All borders are specified in number of pixels. The default is 0 for all borders except the top border, which is 3. You should call this method before calling show().

Parameters:
inLeft - the width of the left border
inTop - the width of the top border
inRight - the width of the right border
inBottom - the width of the bottom border

setCenterTitle

public void setCenterTitle(boolean center)
Set a flag that tells the dialog to center its title. The dialog title is usually drawn left justified, use this method to center the title.

Parameters:
center - whether to center the dialog title.