danger.ui
Class ScreenWindow

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.ScreenWindow
Direct Known Subclasses:
FolderEditor, ImageWindow, PhotoCropper, PhotoPicker


public class ScreenWindow
extends Window

Basic screen window. This is the basic screen window, which covers the entire device display except the title bar area (unless the screen window is a full screen window). This object also handles the title (and sub-title) as shown in the upper left area of the title bar, and the action menu associated with the screen.


Field Summary
 
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
ScreenWindow()
          Construct an instance.
ScreenWindow(boolean fullScreen)
          Construct an instance.
ScreenWindow(CharSequence inTitle)
          Construct an instance.
ScreenWindow(CharSequence inTitle, Bitmap inIcon)
          Construct an instance.
ScreenWindow(String inTitle)
          Construct an instance.
ScreenWindow(String inTitle, Bitmap inIcon)
          Construct an instance.
 
Method Summary
protected  void aboutToHideMenu()
          This method gets called just before the action menu is closed.
protected  void aboutToShowMenu()
          This method gets called just before the action menu is displayed to the user.
 void adjustActionMenuState()
          Deprecated.  deprecated Use adjustActionMenuState(Menu actionMenu) instead.
 void adjustActionMenuState(Menu actionMenu)
          Adjust the action menu state.
 boolean eventKeyUp(char c, Event event)
          Handle a key up event.
 boolean eventShortcut(char shortcut, Event event)
          Handle event shortcuts.
 boolean eventWidgetDown(int inWhichWidget, Event event)
          Handle a button down event.
 boolean eventWidgetUp(int inWhichWidget, Event event)
          Handle a button up event.
 Menu getActionMenu()
          Get the action menu.
 Bitmap getIcon()
          Get the icon associated with this screen.
 String getSubTitle()
          Get the sub-title.
protected  Font getSubTitleFont()
          Get the sub-title font.
 CharSequence getSubTitleSequence()
          Get the sub-title.
 String getTitle()
          Get the title.
protected  Font getTitleFont()
          Get the title font.
 CharSequence getTitleSequence()
          Get the title.
 boolean isActionMenuVisible()
          Determine whether the action menu is currently showing on the screen.
protected  void onScreenWindowActivate()
          Called when the window stack changes such that this screen window is now the active screen window.
protected  void onScreenWindowDeactivate()
          Called when the window stack changes such that this screen window is no longer the active screen window.
protected  void onShortcut(char shortcut, Event event)
          This method is called before eventShortcut gets called.
 void removeAllChildren()
          Remove all children from the screen window.
 void setFullScreen(boolean fullScreen)
          Specify whether the screen should be full screen or not.
 void setIcon(Bitmap inIcon)
          Set the icon.
 void setSubTitle(CharSequence inSubTitle)
          Set the sub-title.
 void setSubTitle(CharSequence inSubTitle, Font inSubTitleFont)
          Set the sub-title and sub-title font.
 void setSubTitle(String inSubTitle)
          Set the sub-title.
 void setSubTitle(String inSubTitle, Font inSubTitleFont)
          Set the sub-title and sub-title font.
 void setTitle(CharSequence inTitle)
          Set the title.
 void setTitle(CharSequence inTitle, Font inFont)
          Set the title and title font.
 void setTitle(String inTitle)
          Set the title.
 void setTitle(String inTitle, Font inFont)
          Set the title and title font.
 
Methods inherited from class danger.ui.Window
advanceFocus, autoHide, autoHideIfIdle, autoHideIfIdle, blocksBackButton, blocksChooser, blocksFloatingControls, blocksKeyGuard, blocksVolumeButtons, centerHorizontal, centerOnScreen, centerUnderTitleBar, centerVertical, disableControlWithID, dropOrphanedEvents, enableControlWithID, forwardQueuedEvents, getApplication, getDefaultFocus, getDescendantWithID, getIDOfChild, getListener, getWindowBelow, hide, hideActiveMenu, hideControlWithID, incrementMaxChildID, isFullScreen, isUnresponsive, onActivate, onDeactivate, onPeriodicPulse, onWindowPaint, receiveMessage, reverseFocus, setDefaultFocus, setDefaultListener, setEventArgForControlWithID, setEventForControlWithID, setMaxChildID, setMaxControlID, setPosition, setSize, setTitled, setTitleFormatDate, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, setTitleFormatText, shouldDropEvent, show, showControlWithID, startQueueingEvents, wantsEndButton, wantsSendButton, 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, getChildWithID, getControlWithID, getFirstChild, getFirstFocusableChild, getFocusableChildInWindow, getFocusedChild, getFocusedLeaf, getInterestingRect, getLastChild, getLastFocusableChild, getLeftMostChild, getNextFocusableChild, getNextFocusableChild, getPageHeight, getPrevFocusableChild, getPrevFocusableChild, getRightMostChild, getRightMostChild, handleButtonShortcut, hideAllChildren, isDescendant, keepRectInView, loseFocus, moveChildToIndex, onChildPositionChanged, onChildSizeChanged, onChildVisibilityChanged, pageToEnd, pageToHome, paint, paintChildren, receiveEvent, reflowChildren, removeChild, setFocusedChild, setFocusedChild, setFocusedChild, setFocusedDescendant, setFocusedDescendant, setFocusedDescendant, setFocusToFirstDescendant, setFormatDateForControlWithID, setFormatDateForTextControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setListenerForAllControls, setReflowAdjustHeight, setWindow, showAllChildren, snapHeightToChildren, snapHeightToChildren, snapToChildren, 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, 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
 

Constructor Detail

ScreenWindow

public ScreenWindow()
Construct an instance. You must call Window.show() to actually show the window.

The screen will not be full screen (see setFullScreen(boolean)).


ScreenWindow

public ScreenWindow(boolean fullScreen)
Construct an instance. You must call Window.show() to actually show the window.

Parameters:
fullScreen - specifies whether the screen is full screen or not. (see setFullScreen(boolean)).

ScreenWindow

public ScreenWindow(String inTitle)
Construct an instance. You must call Window.show() to actually show the window.

The screen will not be full screen (see setFullScreen(boolean)).

Parameters:
inTitle - the title of the screen

ScreenWindow

public ScreenWindow(CharSequence inTitle)
Construct an instance. You must call Window.show() to actually show the window.

The screen will not be full screen (see setFullScreen(boolean)).

Parameters:
inTitle - the title of the screen

ScreenWindow

public ScreenWindow(String inTitle,
                    Bitmap inIcon)
Construct an instance. You must call Window.show() to actually show the window.

The screen will not be full screen (see setFullScreen(boolean)).

Parameters:
inTitle - the title of the screen
inIcon - bitmap to display next to the title

ScreenWindow

public ScreenWindow(CharSequence inTitle,
                    Bitmap inIcon)
Construct an instance. You must call Window.show() to actually show the window.

The screen will not be full screen (see setFullScreen(boolean)).

Parameters:
inTitle - the title of the screen
inIcon - bitmap to display next to the title
Method Detail

setFullScreen

public void setFullScreen(boolean fullScreen)
Specify whether the screen should be full screen or not. A full screen is one without the title bar area. Most screens on the device are not full screen.

Overrides:
setFullScreen in class Window
Parameters:
fullScreen - whether the screen should be full screen or not

setTitle

public void setTitle(String inTitle)
Set the title. This is the text displayed in the top left of the title bar, to the right of the icon (if any). A default font will be used to draw the text.

Overrides:
setTitle in class Window

setTitle

public final void setTitle(CharSequence inTitle)
Set the title. This is the text displayed in the top left of the title bar, to the right of the icon (if any). A default font will be used to draw the text.

Overrides:
setTitle in class Window

setTitle

public void setTitle(String inTitle,
                     Font inFont)
Set the title and title font. This is the text displayed in the top left of the title bar, to the right of the icon (if any).


setTitle

public final void setTitle(CharSequence inTitle,
                           Font inFont)
Set the title and title font. This is the text displayed in the top left of the title bar, to the right of the icon (if any).


setSubTitle

public void setSubTitle(String inSubTitle)
Set the sub-title. This is the text displayed just below the title. A default font will be used to draw the text.


setSubTitle

public void setSubTitle(CharSequence inSubTitle)
Set the sub-title. This is the text displayed just below the title. A default font will be used to draw the text.


setSubTitle

public void setSubTitle(String inSubTitle,
                        Font inSubTitleFont)
Set the sub-title and sub-title font. This is the text displayed just below the title.


setSubTitle

public void setSubTitle(CharSequence inSubTitle,
                        Font inSubTitleFont)
Set the sub-title and sub-title font. This is the text displayed just below the title.


setIcon

public void setIcon(Bitmap inIcon)
Set the icon. This is display in the far left of the title bar, just to the left of the title and sub-title (if any).

The icon should be a 16x16 icon or smaller. The small application icon is most commonly used.


getTitle

public String getTitle()
Get the title. Note that overriding this does not get you much because the window manager peeks directly inside mTitle.

Overrides:
getTitle in class Window

getTitleSequence

public final CharSequence getTitleSequence()
Get the title. This method is a mess so that if somebody has overridden getTitle() directly it will use that instead of what it thinks internally the title should be.

Overrides:
getTitleSequence in class Window

getTitleFont

protected Font getTitleFont()
Get the title font.


getSubTitle

public String getSubTitle()
Get the sub-title. Note that overriding this does not get you much because the window manager peeks directly inside mSubTitle.


getSubTitleSequence

public final CharSequence getSubTitleSequence()
Get the sub-title.


getSubTitleFont

protected Font getSubTitleFont()
Get the sub-title font.


getIcon

public Bitmap getIcon()
Get the icon associated with this screen.


getActionMenu

public Menu getActionMenu()
Get the action menu. Most commonly, you will want to call this method from within adjustActionMenuState(), which you will sometimes need to override.


isActionMenuVisible

public boolean isActionMenuVisible()
Determine whether the action menu is currently showing on the screen.

Overrides:
isActionMenuVisible in class Window
See Also:
adjustActionMenuState()

eventShortcut

public boolean eventShortcut(char shortcut,
                             Event event)
Handle event shortcuts. ScreenWindow automatically handles shortcuts in the action menu here. Override this method and call Container.handleButtonShortcut(char, danger.app.Event) if you also want to handle button shortcuts.

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

onShortcut

protected final void onShortcut(char shortcut,
                                Event event)
This method is called before eventShortcut gets called. ScreenWindow handles shortcuts for opening sub-menus here.

Overrides:
onShortcut in class View

eventKeyUp

public boolean eventKeyUp(char c,
                          Event event)
Handle a key up event. ScreenWindow handles shortcuts which do not require the MENU button here. If you override this method, be sure to call super.eventKeyUp.

Overrides:
eventKeyUp in class Container
Parameters:
c - the character being released.

eventWidgetDown

public boolean eventWidgetDown(int inWhichWidget,
                               Event event)
Handle a button down event.

Overrides:
eventWidgetDown in class Window
Parameters:
inWhichWidget - the widget that went up
Returns:
whether or not the event was consumed

eventWidgetUp

public boolean eventWidgetUp(int inWhichWidget,
                             Event event)
Handle a button up event. ScreenWindow handles showing the action menu here, as well as the BACk menu shortcut (if any). If you override this method, be sure to call super.eventWidgetUp.

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

adjustActionMenuState

public void adjustActionMenuState()
Deprecated.  deprecated Use adjustActionMenuState(Menu actionMenu) instead.


adjustActionMenuState

public void adjustActionMenuState(Menu actionMenu)
Adjust the action menu state.

This method is called before the action menu is displayed to the user, and also before menu item shortcuts are executed.

You will generally want to override this method in order to enable/disable, and hide/show menu items appropriately.

If you override this method, be sure to call super.adjustActionMenuState just before returning. Doing so will assure the menu gets redrawn properly, and that BaseMenu.updateTextEditItems(danger.ui.Window) will be called automatically on the action menu.

Overrides:
adjustActionMenuState in class Window
See Also:
adjustActionMenuState()

removeAllChildren

public void removeAllChildren()
Remove all children from the screen window.

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

aboutToShowMenu

protected void aboutToShowMenu()
This method gets called just before the action menu is displayed to the user. The ScreenWindow implementation of this method does nothing. Override this method if you need to. Generally, you will instead do any menu adjusting in adjustActionMenuState().


aboutToHideMenu

protected void aboutToHideMenu()
This method gets called just before the action menu is closed. The ScreenWindow implementation of this method does nothing. Override this method if you need to.


onScreenWindowActivate

protected void onScreenWindowActivate()
Called when the window stack changes such that this screen window is now the active screen window.


onScreenWindowDeactivate

protected void onScreenWindowDeactivate()
Called when the window stack changes such that this screen window is no longer the active screen window. If you override this method, be sure to call the super class implementation.