|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.Listener
danger.ui.View
danger.ui.Container
danger.ui.Window
danger.ui.DialogWindow
danger.ui.AlertWindow
public class AlertWindow
This class is a UI object that displays a standard alert to the user.
The corresponding resource object is an object of type "alert".

| Field Summary | |
|---|---|
protected static int |
GAP3
Deprecated. For internal use only. |
protected static int |
IMAGE_TEXT_GAP
Deprecated. For internal use only. |
protected boolean |
m_autoDismiss
Deprecated. Use setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismiss()
instead. |
protected Event |
m_autoDismissEvent
Deprecated. Use setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismissEvent()
instead. |
protected int |
m_autoDismissMS
Deprecated. Use setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismissMS()
instead. |
protected Timer |
m_autoDismissTimer
Deprecated. For internal use only. |
protected boolean |
m_forceNoButtons
Deprecated. Use setForceNoButtons(boolean) instead. |
static int |
MAX_BITMAP_SIZE
Maximum pixels per side for the bitmap. |
protected ImageView |
mImageView
Deprecated. Use getImageView() instead. |
protected int |
mImageViewHeight
Deprecated. Use getImageView() and View.getHeight() instead. |
protected int |
mImageViewWidth
Deprecated. Use getImageView() and View.getWidth() instead. |
protected StaticTextBox |
mMessageView
Deprecated. Use getMessageView() instead. |
protected boolean |
mNeedLayout
Deprecated. For internal use only. |
protected ScrollView |
mScrollView
Deprecated. Use getScrollView() instead. |
protected static int |
TOP_ICON_MARGIN
Deprecated. For internal use only. |
| Fields inherited from class danger.ui.Window |
|---|
mBusyPaintCount, mDefaultListener, STATE_AUTO_HIDE_IF_IDLE, STATE_DROP_ORPHANED_EVENTS, STATE_FULLSCREEN, STATE_UNUSED1 |
| Constructor Summary | |
|---|---|
AlertWindow()
Constructs an alert window with with the DialogWindow.APP_DIALOG_STYLE style
and no title, message, or cancel button |
|
AlertWindow(CharSequence message)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no title or cancel button |
|
AlertWindow(CharSequence message,
boolean showCancel)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no title. |
|
AlertWindow(String message)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no title or cancel button |
|
AlertWindow(String message,
boolean showCancel)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no title. |
|
AlertWindow(String title,
CharSequence message)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no cancel button |
|
AlertWindow(String title,
CharSequence message,
boolean showCancel)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style. |
|
AlertWindow(String title,
CharSequence message,
boolean showCancel,
int windowStyle)
Constructs an alert window with the specified message and title. |
|
AlertWindow(String title,
String message)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style
and no cancel button |
|
AlertWindow(String title,
String message,
boolean showCancel)
Constructs an alert window with the DialogWindow.APP_DIALOG_STYLE style. |
|
AlertWindow(String title,
String message,
boolean showCancel,
int windowStyle)
Constructs an alert window with the specified message and title. |
|
| Method Summary | |
|---|---|
void |
addChildBelowMessageArea(View child,
int hOffset,
int vOffset)
Add a child below the alert's icon and message. |
boolean |
getAutoDismiss()
Get whether the alert is self-dismissing or not. |
Event |
getAutoDismissEvent()
Get the event to be sent when the alert auto-dismisses. |
int |
getAutoDismissMS()
Get the number of milliseconds this alert is to be displayed before auto-dismissing. |
Bitmap |
getBitmap()
Get the bitmap for the alert. |
boolean |
getForceNoButtons()
Return the value set by setForceNoButtons(boolean). |
ImageView |
getImageView()
Returns the ImageView containing the bitmap. |
protected int |
getMaxMessageHeight()
Get the maximum height that can be used for the message. |
String |
getMessage()
Get the message for the alert. |
Font |
getMessageFont()
Get the message font for the alert. |
CharSequence |
getMessageSequence()
|
StaticTextBox |
getMessageView()
Returns the StaticTextBox containing the message. |
ScrollView |
getScrollView()
If the message is too large to fit on the screen, then the alert will automatically use this ScrollView, and place
the message view (getMessageView()) inside it. |
Bitmap |
getSleepScreenImage()
Get the message to image in the sleep screen. |
String |
getSleepScreenMessage()
Deprecated. Use getSleepScreenMessageCharSequence instead |
CharSequence |
getSleepScreenMessageCharSequence()
Return the sleep screen message for this alert. |
protected boolean |
layout()
Positions and adds the alert's contents. |
protected void |
layoutBitmap(Rect contentRect)
Lay out the alert bitmap. |
protected int |
layoutMessage(int textColLeft,
int textColWidth,
int textTop,
int minBottom)
Lay out the alert message. |
protected void |
onHide()
This method is called when this view is hidden, via the method View.hide(). |
void |
paint(Pen pen)
Draw the contents of this View. |
boolean |
receiveEvent(Event e)
Receive an event from the alert window. |
protected void |
removeContentChildren()
Remove the alert's children. |
void |
setAutoDismiss(int ms,
Event event)
Specify that this alert should auto-dismiss after the given number of milliseconds. |
void |
setAutoDismiss(int ms,
int eventType,
int eventData,
Object eventArg,
Listener listener)
Specify that this alert should auto-dismiss. |
void |
setBitmap(Bitmap inBitmap)
Set the bitmap for the alert. |
void |
setForceNoButtons(boolean noButtons)
Specify whether to force this alert not to have any buttons. |
void |
setMessage(CharSequence msg)
Set the message for the alert window. |
void |
setMessage(String msg)
Set the message for the alert window. |
void |
setMessageFont(Font inFont)
Set the font of the message in the alert window. |
void |
setMessageFormatDate(Date inDate)
Set the format date for the message. |
void |
setMessageFormatText(CharSequence[] inArgs)
See setMessageFormatText(String inArg0) |
void |
setMessageFormatText(String inArg0)
Set the format text for the message. |
void |
setMessageFormatText(String[] inArgs)
See setMessageFormatText(String inArg0) |
void |
setMessageFormatText(String inArg0,
String inArg1)
See setMessageFormatText(String inArg0) |
void |
setMessageFormatText(String inArg0,
String inArg1,
String inArg2)
See setMessageFormatText(String inArg0) |
void |
setWindowStyle(int style)
Set the dialog window style. |
protected void |
showInternal()
Actually shows the dialog. |
| 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 |
|---|
protected int mImageViewWidth
getImageView() and View.getWidth() instead.protected int mImageViewHeight
getImageView() and View.getHeight() instead.protected boolean mNeedLayout
protected boolean m_forceNoButtons
setForceNoButtons(boolean) instead.protected Event m_autoDismissEvent
setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismissEvent()
instead.protected boolean m_autoDismiss
setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismiss()
instead.protected int m_autoDismissMS
setAutoDismiss(int, int, int, java.lang.Object, danger.app.Listener) and getAutoDismissMS()
instead.protected Timer m_autoDismissTimer
protected ImageView mImageView
getImageView() instead.protected StaticTextBox mMessageView
getMessageView() instead.protected ScrollView mScrollView
getScrollView() instead.public static final int MAX_BITMAP_SIZE
protected static final int TOP_ICON_MARGIN
protected static final int IMAGE_TEXT_GAP
protected static final int GAP3
| Constructor Detail |
|---|
public AlertWindow()
DialogWindow.APP_DIALOG_STYLE style
and no title, message, or cancel button
public AlertWindow(String message)
DialogWindow.APP_DIALOG_STYLE style
and no title or cancel button
public AlertWindow(CharSequence message)
DialogWindow.APP_DIALOG_STYLE style
and no title or cancel button
public AlertWindow(String title,
String message)
DialogWindow.APP_DIALOG_STYLE style
and no cancel button
public AlertWindow(String title,
CharSequence message)
DialogWindow.APP_DIALOG_STYLE style
and no cancel button
public AlertWindow(String message,
boolean showCancel)
DialogWindow.APP_DIALOG_STYLE style
and no title.
public AlertWindow(CharSequence message,
boolean showCancel)
DialogWindow.APP_DIALOG_STYLE style
and no title.
public AlertWindow(String title,
String message,
boolean showCancel)
DialogWindow.APP_DIALOG_STYLE style.
public AlertWindow(String title,
CharSequence message,
boolean showCancel)
DialogWindow.APP_DIALOG_STYLE style.
public AlertWindow(String title,
String message,
boolean showCancel,
int windowStyle)
Creates an alert window. All constructors create an alert window with an OK button in the bottom right, with BACK as the shortcut. The alert window is not displayed until its show method is called.
title - A String containing the title of the alertmessage - A String containing the alert message to be displayed.showCancel - whether to display the cancel button or not. If
displayed, it will appear in the upper right of the dialog, and
will not have a shortcut.windowStyle - one of DialogWindow.APP_DIALOG_STYLE,
DialogWindow.APP_ALERT_STYLE,
DialogWindow.SYSTEM_DIALOG_STYLE,
DialogWindow.SYSTEM_ERROR_STYLE.
See DialogWindow.setWindowStyle(int).
public AlertWindow(String title,
CharSequence message,
boolean showCancel,
int windowStyle)
Creates an alert window. All constructors create an alert window with an OK button in the bottom right, with BACK as the shortcut. The alert window is not displayed until its show method is called.
title - A String containing the title of the alertmessage - A String containing the alert message to be displayed.showCancel - whether to display the cancel button or not. If
displayed, it will appear in the upper right of the dialog, and
will not have a shortcut.windowStyle - one of DialogWindow.APP_DIALOG_STYLE,
DialogWindow.APP_ALERT_STYLE,
DialogWindow.SYSTEM_DIALOG_STYLE,
DialogWindow.SYSTEM_ERROR_STYLE.
See DialogWindow.setWindowStyle(int).| Method Detail |
|---|
public void setBitmap(Bitmap inBitmap)
The bitmap can be no larger than MAX_BITMAP_SIZE x MAX_BITMAP_SIZE (64x64).
If setBitmap is not called, then a default icon will be used. The default icon depends on whether the alert is a system alert or application alert. If you do not want a default bitmap to be displayed, then call setBitmap(null).
inBitmap - the bitmap to be usedpublic Bitmap getBitmap()
setBitmap(danger.ui.Bitmap), or it will return the default icon
that will be used if setBitmap(danger.ui.Bitmap) has not been called.
public void setMessage(String msg)
DialogWindow.show()
to display the window.
msg - A String containing the message to be displayed in the alert window.public final void setMessage(CharSequence msg)
This method sets the message that will be displayed in the
alert window. Use this method before calling DialogWindow.show()
to display the window.
msg - The message to be displayed in the alert window.public String getSleepScreenMessage()
getSleepScreenMessage in class DialogWindowpublic CharSequence getSleepScreenMessageCharSequence()
DialogWindow.setSleepScreenMessage(java.lang.String),
then the alert message (as set by setMessage(java.lang.String) is returned.
getSleepScreenMessageCharSequence in class DialogWindowpublic String getMessage()
public CharSequence getMessageSequence()
public void setMessageFont(Font inFont)
inFont - A font object.public Font getMessageFont()
public final ImageView getImageView()
ImageView containing the bitmap.
public final StaticTextBox getMessageView()
StaticTextBox containing the message.
public final ScrollView getScrollView()
ScrollView, and place
the message view (getMessageView()) inside it.
public void setWindowStyle(int style)
setBitmap(danger.ui.Bitmap) has not
been called, then this will result in a call to setBitmap(danger.ui.Bitmap)
to set the default icon for this dialog.
setWindowStyle in class DialogWindowstyle - the window style. This should be one of
DialogWindow.APP_DIALOG_STYLE,
DialogWindow.APP_ALERT_STYLE,
DialogWindow.SYSTEM_DIALOG_STYLE, or
DialogWindow.SYSTEM_ERROR_STYLE.DialogWindow.setWindowStyle(int)public void setForceNoButtons(boolean noButtons)
DialogWindow.setShowCancel(boolean) if
needed.
noButtons - if true, specifies that there should not be
any buttons in this alertpublic final boolean getForceNoButtons()
setForceNoButtons(boolean).
public void setAutoDismiss(int ms,
int eventType,
int eventData,
Object eventArg,
Listener listener)
A convenience method which just calls
setAutoDismiss(int ms, Event event). Specify
0 for the eventType if you do not wish to specify an event.
ms - number of milliseconds after which to automatically
dismiss this alert.eventType - the event typeeventData - the event dataeventArg - the event argumentlistener - the event listener
public void setAutoDismiss(int ms,
Event event)
After the specified time, or when the user hits a key or button (whichever comes first), the alert will automatically dismiss, and the specified event will be sent.
This method must be called before calling DialogWindow.show().
ms - number of milliseconds after which to automatically
dismiss this alert.event - null-ok; the event to send when this alert is dismissed.public final boolean getAutoDismiss()
setAutoDismiss(int,int,int,Object,Listener) and
setAutoDismiss(int,Event).
public final int getAutoDismissMS()
getAutoDismiss()
is false.
See setAutoDismiss(int,int,int,Object,Listener) and
setAutoDismiss(int,Event).
public final Event getAutoDismissEvent()
setAutoDismiss(int,int,int,Object,Listener) and
setAutoDismiss(int,Event).
protected int getMaxMessageHeight()
Returns the height which is the maximum height of the alert, minus the frames and any frame buttons.
protected void layoutBitmap(Rect contentRect)
Generally, you should not have to call or override this method.
This method is automatically called from layout() to
position and add the alert bitmap.
Note: It is not safe to call this method while the alert is already visible. You should ensure that the alert is hidden (or not yet shown) before calling this method.
contentRect - the content rect of the window, obtained by
a call to (@link DialogWindow#getContentRect}.
protected int layoutMessage(int textColLeft,
int textColWidth,
int textTop,
int minBottom)
Generally, you should not have to call or override this method.
This method is automatically called from layout() to
position and add the alert message.
Note: It is not safe to call this method while the alert is already visible. You should ensure that the alert is hidden (or not yet shown) before calling this method.
textColLeft - the left edge of the message texttextColWidth - the width of the message texttextTop - the top edge of the message textminBottom - the bottom edge of the alert bitmap.
If the message is short than the image, then the message is
centered to the image.
public void addChildBelowMessageArea(View child,
int hOffset,
int vOffset)
Container.addChild(danger.ui.View) to add a child to an AlertWindow.
Note: Be sure to set the size of the child before making this call.
child - the child to addhOffset - the horizontal offset of the child, relative to
the left edge of the message area. If there is an icon, then
the offset is relative to the left edge of the icon. Positive
offsets move the child to the right.vOffset - the vertical offset of the child, relative to the
bottom edge of the message area. If the message is taller than
the icon, then the offset is relative to the bottom edge of the
message. Positive offsets move the child down.protected void removeContentChildren()
This method does not remove the frame buttons. It will remove the alert message, bitmap, and scroll view (if any).
Note: It is not safe to call this method while the alert is already visible. You should ensure that the alert is hidden (or not yet shown) before calling this method.
public void paint(Pen pen)
ViewThe 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.
paint in class DialogWindowpen - non-null; the pen to use for drawing operationsView.paint(danger.ui.Pen)protected boolean layout()
This method positions and adds the alert's message, bitmap, and OK button (if any).
It calls removeContentChildren(), layoutBitmap(danger.ui.Rect),
and layoutMessage(int, int, int, int).
Generally, you should not have to call or override this method.
It is called automatically in showInternal().
Note: It is not safe to call this method while the alert is already visible. You should ensure that the alert is hidden (or not yet shown) before calling this method.
public boolean receiveEvent(Event e)
Called whenever the alert window receives an event. The default behavior is to create and send an event to the listener for the alert window. Override this method to receive and process the events yourself.
receiveEvent in class DialogWindowe - An Event containing the event received.
true) or not (false) this
method actually handled the event to completionListener.receiveEvent(danger.app.Event)protected void onHide()
ViewView.hide(). It is called as the very last thing done by that
method, and it is only ever called if the view was not already
hidden. Overriding this method is the recommended way to get special
behavior when a view gets hidden .
The implementation in this class does nothin.
onHide in class Viewprotected void showInternal()
DialogWindowDialogWindow.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.
showInternal in class DialogWindowDialogWindow.showInternal()public Bitmap getSleepScreenImage()
The image returned by this method is displayed if this
is a system alert and the device is in keyguard mode.
The image is displayed alongside the message returned by
getSleepScreenMessage().
It is automatically called by the Notification Manager.
It returns the value of getBitmap(). Over-ride
if you want to display a different image in the sleep
screen.
getSleepScreenImage in class DialogWindowpublic void setMessageFormatText(String inArg0)
inArg0 - the argument to replace ^0 with.StringFormat
public void setMessageFormatText(String inArg0,
String inArg1)
setMessageFormatText(String inArg0)
inArg0 - the argument to replace ^0 with.inArg1 - the argument to replace ^1 with.StringFormat
public void setMessageFormatText(String inArg0,
String inArg1,
String inArg2)
setMessageFormatText(String inArg0)
inArg0 - the argument to replace ^0 with.inArg1 - the argument to replace ^1 with.inArg2 - the argument to replace ^2 with.StringFormatpublic void setMessageFormatText(String[] inArgs)
setMessageFormatText(String inArg0)
inArgs - the arguments to replace ^0, ^1, etc. with.StringFormatpublic void setMessageFormatText(CharSequence[] inArgs)
setMessageFormatText(String inArg0)
inArgs - the arguments to replace ^0, ^1, etc. with.StringFormatpublic void setMessageFormatDate(Date inDate)
inDate - the date to useDateFormat
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||