UgiUiUtil is a collection of static UI utilities for showing alert dialogs.
It is used by UgiDefaultConfigurationUi to show UI for configuration
Static Public Member Functions | |
static int | getThemeColorToUse () |
Color for the currently active UgiUiActivity. More... | |
static int | getTextColorOnThemeColorToUse () |
Color for the currently active UgiUiActivity. More... | |
static int | getButtonColorToUse () |
Color for the currently active UgiUiActivity. More... | |
static int | getButtonPressedColorToUse () |
Color for the currently active UgiUiActivity. More... | |
static int | getTextColorOnBackgroundToUse () |
Color for the currently active UgiUiActivity. More... | |
static View | traverseSubviews (View v, TraverseSubviewsCallback callback) |
Traverse all subviews of the given view. More... | |
static Activity | getParentActivity (View view) |
Get the parent activity for a view. More... | |
static int | lightenColor (int color, double degree) |
Make a color lighter. More... | |
static int | darkenColor (int color, double degree) |
Make a color darker. More... | |
static double | getColorLuminance (int color) |
Get the perceived luminance of a color. More... | |
static String | colorToString (int color) |
Get a string description of a color (mostl;y for debugging) More... | |
static int | modifyColorToBeSufficientlyDarkForText (int textColor, int backgroundColor) |
Modify a color to be sufficiently dark (or light) to appear on the given background color. More... | |
static boolean | getUseUGrokItStyleAlerts () |
Get whether U Grok It style alert dialogs are being used. More... | |
static void | setUseUGrokItStyleAlerts (boolean b) |
Set whether U Grok It style alert dialogs should be used. More... | |
static Object | showCustomAlert (Context context, String title, View view, boolean cancelable, boolean showCloseButton, Runnable closeCompletion) |
Show an alert with a custom view. More... | |
static void | hideUI (Object o) |
Dismiss a UI component shown with one of the showXXX methods. More... | |
static void | updateAlertTitle (Object o, String title) |
Update the title in an alert dialog. More... | |
static void | updateAlert (Object o, String message) |
Update the message in an alert dialog. More... | |
static Object | showOkNeutralCancel (Context context, String title, String message, String okButtonTitle, String neutralButtonTitle, String cancelButtonTitle, final Runnable completion, final Runnable neutralCompletion, final Runnable cancelCompletion) |
Show an alert dialog with ok, neutral and cancel buttons. More... | |
static Object | showOkNeutralCancel (Context context, String title, String message, String okButtonTitle, String neutralButtonTitle, String cancelButtonTitle, final Runnable completion, final Runnable neutralCompletion, final Runnable cancelCompletion, final Dialog.OnKeyListener onKeyListener) |
Show an alert dialog with ok, neutral and cancel buttons. More... | |
static Object | showOkCancel (Context context, String title, String message, String okButtonTitle, String cancelButtonTitle, final Runnable completion, final Runnable cancelCompletion) |
Show an alert dialog with ok and cancel buttons. More... | |
static Object | showOkCancel (Context context, String title, String message, String okButtonTitle, String cancelButtonTitle, final Runnable completion, final Runnable cancelCompletion, final Dialog.OnKeyListener onKeyListener) |
Show an alert dialog with ok and cancel buttons. More... | |
static Object | showOk (Context context, String title, String message, String okButtonTitle, final Runnable completion) |
Show an alert dialog with an ok button. More... | |
static Object | showOk (Context context, String title, String message, String okButtonTitle, final Runnable completion, final Dialog.OnKeyListener onKeyListener) |
Show an alert dialog with an ok button. More... | |
static Object | showOk (Context context, String title, String message) |
Show an alert dialog with an ok button. More... | |
static Object | showCancel (Context context, String title, String message, final Runnable completion) |
Show an alert dialog with a cancel button. More... | |
static Object | showChoices (final Context context, final String[] choices, int initialSelectedIndex, final String title, String message, String actionButtonTitle, boolean canCancel, final ShowChoicesCompletion actionCompletion, final ShowChoicesConfirmationCompletion confirmationCompletion, final Runnable cancelCompletion) |
Show UI to choose from a list of choices. More... | |
static Object | showMenu (final Context context, String title, final Runnable cancelCompletion, final MenuTitleAndHandler... items) |
Display a menu. More... | |
static void | showToast (final Context context, String title, String message, double interval) |
Show a "toast" (a temporary message) More... | |
static void | showToast (final Context context, String title, String message) |
Show a "toast" (a temporary message) for the default time. More... | |
static Object | showTextInput (Context context, String title, String message, String actionButtonTitle, String initialText, int inputType, String switchText, boolean switchInitialValue, final ShowTextInputCompletion actionCompletion, final Runnable cancelCompletion, final ShowTextInputShouldEnableForTextCompletion shouldEnableForTextCompletion) |
Input a text string from the user. More... | |
static void | showWaiting (Context context, String message, final Runnable cancelCompletion) |
Show "waiting" alert dialog, call completion if cancelled. More... | |
static void | showWaiting (Context context, String message, final Runnable cancelCompletion, final Dialog.OnKeyListener onKeyListener) |
Show "waiting" alert dialog. More... | |
static void | showWaiting (Context context, String message) |
Show "waiting" alert dialog without cancel. More... | |
static void | hideWaiting () |
Hide "waiting" alert dialog. | |
static void | updateWaiting (String message) |
Update the message in the waiting dialog. More... | |
static boolean | isWaitingShown () |
See if the waiting alert is shown. More... | |
static void | stopInventoryWithCompletionShowWaiting (Context context, final UgiInventory.StopInventoryCompletion completion) |
Stop running inventory, showing a waiting dialog. More... | |
static void | stopInventoryWithShownAlert (final Context context, final Object alert, final Runnable completion) |
Stop running inventory, showing a waiting alert if the given alert is dismissed before inventory stops. More... | |
static void | startDisconnectedAlert (final Context context, final Runnable cancelCompletion) |
Start showing a "disconnected, please connect your grokker" dialog if appropriate. More... | |
static void | stopDisconnectedAlert () |
Stop showing disconnected dialog. More... | |
static boolean | isDisconnectedAlertActive () |
See if the disconnected alert is active. More... | |
static Object | showInventoryError (Context context, int result) |
Show an alert if there was an inventory error. More... | |
static Object | showInventoryError (Context context, int result, Runnable completion) |
Show an alert if there was an inventory error. More... | |
static Object | showInventoryError (Context context, int result, Runnable completion, final Dialog.OnKeyListener onKeyListener) |
Show an alert if there was an inventory error. More... | |
static String | getTagAccessErrorMessage (UgiInventory.TagAccessReturnValues result) |
Get the error message for a tag access return value. More... | |
static String | getInventoryErrorMessage (int result) |
Get the error message for an inventory result. More... | |
static String | getBarcodeScanErrorMessage () |
Get the appropriate error message if barcode scan failed. More... | |
static Object | showBarcodeError (Context context, Runnable completion) |
Show an alert with a message after barcode scan failed. More... | |
static Object | showBarcodeError (Context context, Runnable completion, Dialog.OnKeyListener onKeyListener) |
Show an alert with a message after barcode scan failed. More... | |
static Object | showVersionAlert (Context context, String title, final boolean showExtraInfo) |
Show an alert with version information. More... | |
static String | getStringWithDeviceName (String s) |
Substitute the device name for "PD20" in a string. More... | |
Classes | |
class | MenuTitleAndHandler |
Information for a menu item. More... | |
interface | ShowChoicesCompletion |
Completion for showChoices() More... | |
interface | ShowChoicesConfirmationCompletion |
Completion for showChoices() More... | |
interface | ShowTextInputCompletion |
Completion for showTextInput() More... | |
interface | ShowTextInputShouldEnableForTextCompletion |
Completion for showTextInput() More... | |
interface | TraverseSubviewsCallback |
Callback type used by traverseSubviews. More... | |
Static Public Attributes | |
static final int | NULL_COLOR = Color.argb(0x45, 0x12, 0x23, 0x34) |
Color to use for "no color". | |
static final int | UI_COLOR = Color.rgb(0x44, 0x6b, 0xcd) |
Ugi defaults. | |
static final int | DEFAULT_THEME_COLOR = UI_COLOR |
Default color (a constant) | |
static final int | DEFAULT_TEXT_COLOR_ON_THEME_COLOR = Color.WHITE |
Default color (a constant) | |
static final int | DEFAULT_BUTTON_COLOR = UI_COLOR |
Default color (a constant) | |
static final int | DEFAULT_BUTTON_PRESSED_COLOR = Color.BLACK |
Default color (a constant) | |
static final int | DEFAULT_TEXT_COLOR_ON_BACKGROUND = Color.BLACK |
Default color (a constant) | |
static int | themeColor = DEFAULT_THEME_COLOR |
Default color for the app, defaults to DEFAULT_THEME_COLOR. | |
static int | textColorOnThemeColor = DEFAULT_TEXT_COLOR_ON_THEME_COLOR |
Default color for the app, defaults to DEFAULT_TEXT_COLOR_ON_THEME_COLOR. | |
static int | buttonColor = DEFAULT_BUTTON_COLOR |
Default color for the app, defaults to DEFAULT_BUTTON_COLOR. | |
static int | buttonPressedColor = DEFAULT_BUTTON_PRESSED_COLOR |
Default color for the app, defaults to DEFAULT_BUTTON_PRESSED_COLOR. | |
static int | textColorOnBackground = DEFAULT_TEXT_COLOR_ON_BACKGROUND |
Default color for the app, defaults to DEFAULT_TEXT_COLOR_ON_BACKGROUND. | |
static final String | DIALOG_MESSAGE_LEFT_JUSTIFY = "@left@" |
Prefix to message string to left justify. | |
static final String | DIALOG_MESSAGE_SMALLER_TEXT = "@smaller@" |
Prefix to message string to use smaller text. | |
static final int | DEFAULT_INPUT_TYPE = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT |
Default type for showTextInput() | |
|
static |
Color for the currently active UgiUiActivity.
|
static |
Color for the currently active UgiUiActivity.
|
static |
Color for the currently active UgiUiActivity.
|
static |
Color for the currently active UgiUiActivity.
|
static |
Color for the currently active UgiUiActivity.
|
static |
Traverse all subviews of the given view.
v | View to traverse |
callback | Callback to call |
|
static |
Get the parent activity for a view.
view | View to get the parent activity of |
|
static |
Make a color lighter.
color | Color to change |
degree | Degree to lighten: 0 = white, 1 = no change |
|
static |
Make a color darker.
color | Color to change |
degree | Degree to darken: 0 = black, 1 = no change |
|
static |
Get the perceived luminance of a color.
color | The color to get the luminance of |
|
static |
Get a string description of a color (mostl;y for debugging)
color | The color |
|
static |
Modify a color to be sufficiently dark (or light) to appear on the given background color.
textColor | text color to modify, if needed |
backgroundColor | background color that the text will appear on |
|
static |
Get whether U Grok It style alert dialogs are being used.
|
static |
Set whether U Grok It style alert dialogs should be used.
b | true if U Grok It style alert dialogs are being used |
|
static |
Show an alert with a custom view.
context | Activity to show to alert dialog on |
title | Title for the alert |
view | Custom view |
cancelable | true ifthe alert can be cancelled |
showCloseButton | true to show a close button (X) |
closeCompletion | Block to execute when the alert closes |
|
static |
Dismiss a UI component shown with one of the showXXX methods.
o | The UI dialog to dismiss |
|
static |
Update the title in an alert dialog.
o | The alert to update |
title | New title for the alert dialog |
|
static |
Update the message in an alert dialog.
o | The alert to update |
message | Text for the body of the alert dialog |
|
static |
Show an alert dialog with ok, neutral and cancel buttons.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or nil for no ok button |
neutralButtonTitle | Text for the neutral button, or null for no ok button |
cancelButtonTitle | Text for the "cancel" button, or "" for the default, or null for no cancel button |
completion | Block to execute for "ok" |
neutralCompletion | Block to execute for neutral |
cancelCompletion | Block to execute for "cancel" |
|
static |
Show an alert dialog with ok, neutral and cancel buttons.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or nil for no ok button |
neutralButtonTitle | Text for the neutral button, or null for no ok button |
cancelButtonTitle | Text for the "cancel" button, or "" for the default, or null for no cancel button |
completion | Block to execute for "ok" |
neutralCompletion | Block to execute for neutral |
cancelCompletion | Block to execute for "cancel" |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Show an alert dialog with ok and cancel buttons.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
cancelButtonTitle | Text for the "cancel" button, or "" for the default, or null for no cancel button |
completion | Block to execute for "ok" |
cancelCompletion | Block to execute for "cancel" |
|
static |
Show an alert dialog with ok and cancel buttons.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
cancelButtonTitle | Text for the "cancel" button, or "" for the default, or null for no cancel button |
completion | Block to execute for "ok" |
cancelCompletion | Block to execute for "cancel" |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Show an alert dialog with an ok button.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
completion | Block to execute for "ok" |
|
static |
Show an alert dialog with an ok button.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
okButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
completion | Block to execute for "ok" |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Show an alert dialog with an ok button.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
|
static |
Show an alert dialog with a cancel button.
context | Activity to show to alert dialog on |
title | Title for the alert |
message | Text for the body of the alert |
completion | Block to execute for "cancel" |
|
static |
Show UI to choose from a list of choices.
context | context to show to alert dialog on |
choices | Choices to choose from |
initialSelectedIndex | Choice to select initially |
title | Title for the alert |
message | Text for the body of the alert |
actionButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
canCancel | true if the user can cancel |
actionCompletion | Block to execute for "ok" |
confirmationCompletion | Block to execute to confirm the choice, or null of no confirmation |
cancelCompletion | Block to execute for "cancel" |
|
static |
Display a menu.
context | context to show to alert dialog on |
title | Title for the alert |
cancelCompletion | Block to execute for "cancel" |
items | menu items |
|
static |
Show a "toast" (a temporary message)
context | context to show to alert dialog on |
title | Title for the toast |
message | Text for the body of the toast |
interval | Duration to display the toast |
|
static |
Show a "toast" (a temporary message) for the default time.
context | context to show to alert dialog on |
title | Title for the toast |
message | Text for the body of the toast |
|
static |
Input a text string from the user.
context | context to show to alert dialog on |
title | Title for the alert |
message | Message for the alert |
actionButtonTitle | Text for the "ok" button, or "" for the default, or null for no ok button |
initialText | Initial text |
inputType | Type of text input: android.text.InputType.XXX |
switchText | Text for an on/off switch (if null then no switch) |
switchInitialValue | Initial value for the switch |
actionCompletion | Block to execute for "ok" |
cancelCompletion | Block to execute for "cancel" |
shouldEnableForTextCompletion | Code to determine whether the action button should be enabled |
|
static |
Show "waiting" alert dialog, call completion if cancelled.
context | context to show to alert dialog on |
message | Text for the body of the alert dialog |
cancelCompletion | Block to execute for "cancel" (or null if cancel is not an option) |
|
static |
Show "waiting" alert dialog.
Includes a completion for cancelling, as well as an OnKeyListener.
context | Context to show to alert dialog on |
message | Text for the body of the alert dialog |
cancelCompletion | Block to execute for "cancel" (or null if cancel is not an option) |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Show "waiting" alert dialog without cancel.
context | context to show to alert dialog on |
message | Text for the body of the alert dialog |
|
static |
Update the message in the waiting dialog.
message | New message |
|
static |
See if the waiting alert is shown.
|
static |
Stop running inventory, showing a waiting dialog.
context | Context to show waiting alert on |
completion | Completion to run after inventory stops |
|
static |
Stop running inventory, showing a waiting alert if the given alert is dismissed before inventory stops.
context | Context to show waiting alert on |
alert | Alter being shown |
completion | Completion to run after inventory stops and the alert is dismissed |
|
static |
Start showing a "disconnected, please connect your grokker" dialog if appropriate.
Normally called just after calling startInventory()
context | context to show to alert dialog on |
cancelCompletion | Completion to call if user cancels |
|
static |
Stop showing disconnected dialog.
Normally called just before calling stopInventory()
|
static |
See if the disconnected alert is active.
|
static |
Show an alert if there was an inventory error.
context | context to show to alert dialog on |
result | Result passed to inventoryDidStop |
|
static |
Show an alert if there was an inventory error.
context | context to show to alert dialog on |
result | Result passed to inventoryDidStop |
completion | Code to run after the alert is dismissed |
|
static |
Show an alert if there was an inventory error.
context | context to show to alert dialog on |
result | Result passed to inventoryDidStop |
completion | Code to run after the alert is dismissed. If there is no inventory error, this will run immediately. Can be null if no completion is desired. |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Get the error message for a tag access return value.
result | Result passed to completion for readTag, lockUnlockTag, or others |
|
static |
Get the error message for an inventory result.
result | Result passed to inventoryDidStop |
|
static |
Get the appropriate error message if barcode scan failed.
|
static |
Show an alert with a message after barcode scan failed.
context | context to show to alert dialog on |
completion | Block to execute when the alert is completed |
|
static |
Show an alert with a message after barcode scan failed.
context | context to show to alert dialog on |
completion | Block to execute when the alert is completed |
onKeyListener | A listener for key events. Useful for detecting PD67 side button presses. |
|
static |
Show an alert with version information.
context | Context to show to alert dialog on |
title | Title, no nulkl to use app's name and version |
showExtraInfo | true to show debugging info |
|
static |
Substitute the device name for "PD20" in a string.
s | string |