|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.android_scripting.jsonrpc.RpcReceiver
com.googlecode.android_scripting.facade.ui.UiFacade
public class UiFacade
User Interface Facade.
Usage Notes
The UI facade provides access to a selection of dialog boxes for general user interaction, and
also hosts the webViewShow(java.lang.String, java.lang.Boolean) call which allows interactive use of html pages.
The general use of the dialog functions is as follows:
dialogCreateInput(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
dialogCreateAlert(java.lang.String, java.lang.String)
dialogCreateDatePicker(java.lang.Integer, java.lang.Integer, java.lang.Integer)
dialogCreateHorizontalProgress(java.lang.String, java.lang.String, java.lang.Integer)
dialogCreatePassword(java.lang.String, java.lang.String)
dialogCreateSeekBar(java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String)
dialogCreateSpinnerProgress(java.lang.String, java.lang.String, java.lang.Integer)
dialogSetItems(JSONArray) Set a list of items. Used like a menu.
dialogSetMultiChoiceItems(JSONArray, JSONArray) Set a multichoice list of items.
dialogSetSingleChoiceItems(JSONArray, java.lang.Integer) Set a single choice list of items.
dialogSetPositiveButtonText(java.lang.String)
dialogSetNeutralButtonText(java.lang.String)
dialogSetNegativeButtonText(java.lang.String)
dialogSetMaxProgress(java.lang.Integer) Set max progress for your progress bar.
dialogShow()
dialogGetResponse(), which will wait until the user performs an action to close
the dialog box, or
dialogGetSelectedItems(), which
returns an array of numeric indices to your list. For a single choice list, there will only ever
be one of these.
dialogDismiss() to remove the dialog.
dialogShow()
and fullShow(java.lang.String).
clearOptionsMenu()
addOptionsMenuItem(java.lang.String, java.lang.String, java.lang.Object, java.lang.String)
dialogGetInput(java.lang.String, java.lang.String, java.lang.String) and dialogGetPassword(java.lang.String, java.lang.String) are
convenience functions that create, display and return the relevant dialogs in one call.
| Constructor Summary | |
|---|---|
UiFacade(FacadeManager manager)
|
|
| Method Summary | |
|---|---|
void |
addContextMenuItem(java.lang.String label,
java.lang.String event,
java.lang.Object data)
Context menus are used primarily with webViewShow(java.lang.String, java.lang.Boolean) |
void |
addOptionsMenuItem(java.lang.String label,
java.lang.String event,
java.lang.Object data,
java.lang.String iconName)
Example (python) |
void |
clearContextMenu()
|
void |
clearOptionsMenu()
|
void |
dialogCreateAlert(java.lang.String title,
java.lang.String message)
Example (python) |
void |
dialogCreateDatePicker(java.lang.Integer year,
java.lang.Integer month,
java.lang.Integer day)
|
void |
dialogCreateHorizontalProgress(java.lang.String title,
java.lang.String message,
java.lang.Integer max)
|
void |
dialogCreateInput(java.lang.String title,
java.lang.String message,
java.lang.String text,
java.lang.String inputType)
For inputType, see InputTypes. |
java.lang.String |
dialogCreateNFCBeamMaster(java.lang.String title,
java.lang.String message,
java.lang.String inputType)
|
java.lang.String |
dialogCreateNFCBeamSlave(java.lang.String title,
java.lang.String message)
|
void |
dialogCreatePassword(java.lang.String title,
java.lang.String message)
|
void |
dialogCreateSeekBar(java.lang.Integer progress,
java.lang.Integer max,
java.lang.String title,
java.lang.String message)
Will produce "dialog" events on change, containing: "progress" - Position chosen, between 0 and max "which" = "seekbar" "fromuser" = true/false change is from user input Response will contain a "progress" element. |
void |
dialogCreateSpinnerProgress(java.lang.String title,
java.lang.String message,
java.lang.Integer max)
|
void |
dialogCreateTimePicker(java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Boolean is24hour)
|
void |
dialogDismiss()
|
java.lang.String |
dialogGetInput(java.lang.String title,
java.lang.String message,
java.lang.String text)
The result is the user's input, or None (null) if cancel was hit. |
java.lang.String |
dialogGetPassword(java.lang.String title,
java.lang.String message)
|
java.lang.Object |
dialogGetResponse()
|
java.util.Set<java.lang.Integer> |
dialogGetSelectedItems()
|
void |
dialogSetCurrentProgress(java.lang.Integer current)
|
void |
dialogSetItems(JSONArray items)
This effectively creates list of options. |
void |
dialogSetMaxProgress(java.lang.Integer max)
|
void |
dialogSetMultiChoiceItems(JSONArray items,
JSONArray selected)
This creates a list of check boxes. |
void |
dialogSetNegativeButtonText(java.lang.String text)
|
void |
dialogSetNeutralButtonText(java.lang.String text)
|
void |
dialogSetPositiveButtonText(java.lang.String text)
|
void |
dialogSetSingleChoiceItems(JSONArray items,
java.lang.Integer selected)
This creates a list of radio buttons. |
void |
dialogShow()
|
void |
fullDismiss()
|
JSONArray |
fullKeyOverride(JSONArray keycodes,
java.lang.Boolean enable)
This will override the default behaviour of keys while in the fullscreen mode. |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
fullQuery()
|
java.util.Map<java.lang.String,java.lang.String> |
fullQueryDetail(java.lang.String id)
|
java.lang.String |
fullSetList(java.lang.String id,
JSONArray items)
|
java.lang.String |
fullSetProperty(java.lang.String id,
java.lang.String property,
java.lang.String value)
|
java.util.List<java.lang.String> |
fullShow(java.lang.String layout)
See wiki page for more detail. |
java.lang.String |
NFCBeamMessage(java.lang.String content,
java.lang.String title,
java.lang.String message)
|
void |
onCreateContextMenu(ContextMenu menu,
View v,
ContextMenuInfo menuInfo)
|
boolean |
onPrepareOptionsMenu(Menu menu)
|
void |
shutdown()
Invoked when the receiver is shut down. |
void |
webViewShow(java.lang.String url,
java.lang.Boolean wait)
See wiki page for more detail. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UiFacade(FacadeManager manager)
| Method Detail |
|---|
@Rpc(description="Create a text input dialog.")
public void dialogCreateInput(@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="Value")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Please enter value:")
java.lang.String message,
@RpcParameter(name="defaultText",description="text to insert into the input box")@RpcOptional
java.lang.String text,
@RpcParameter(name="inputType",description="type of input data, ie number or text")@RpcOptional
java.lang.String inputType)
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Create a password input dialog.")
public void dialogCreatePassword(@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="Password")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Please enter password:")
java.lang.String message)
@Rpc(description="Queries the user for a text input.")
public java.lang.String dialogGetInput(@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="Value")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Please enter value:")
java.lang.String message,
@RpcParameter(name="defaultText",description="text to insert into the input box")@RpcOptional
java.lang.String text)
throws java.lang.InterruptedException
import android
droid=android.Android()
print droid.dialogGetInput("Title","Message","Default").result
java.lang.InterruptedException
@Rpc(description="Queries the user for a password.")
public java.lang.String dialogGetPassword(@RpcParameter(name="title",description="title of the password box")@RpcDefault(value="Password")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Please enter password:")
java.lang.String message)
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Create a qpython beam master.")
public java.lang.String dialogCreateNFCBeamMaster(@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="QPython BEAM With NFC")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Input message and Beam")
java.lang.String message,
@RpcParameter(name="inputType",description="type of input data, ie number or text")@RpcOptional
java.lang.String inputType)
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Create a qpython beam master to send directory message.")
public java.lang.String NFCBeamMessage(@RpcParameter(name="content",description="message you want to sent")@RpcDefault(value="Message you want to beam")
java.lang.String content,
@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="QPython Beam With NFC")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Beam Message")
java.lang.String message)
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Create a qpython beam slave.")
public java.lang.String dialogCreateNFCBeamSlave(@RpcParameter(name="title",description="title of the input box")@RpcDefault(value="QPython Beam With NFC")
java.lang.String title,
@RpcParameter(name="message",description="message to display above the input box")@RpcDefault(value="Wait for beam message")
java.lang.String message)
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Create a spinner progress dialog.")
public void dialogCreateSpinnerProgress(@RpcParameter(name="title")@RpcOptional
java.lang.String title,
@RpcParameter(name="message")@RpcOptional
java.lang.String message,
@RpcParameter(name="maximum progress")@RpcDefault(value="100")
java.lang.Integer max)
@Rpc(description="Create a horizontal progress dialog.")
public void dialogCreateHorizontalProgress(@RpcParameter(name="title")@RpcOptional
java.lang.String title,
@RpcParameter(name="message")@RpcOptional
java.lang.String message,
@RpcParameter(name="maximum progress")@RpcDefault(value="100")
java.lang.Integer max)
@Rpc(description="Create alert dialog.")
public void dialogCreateAlert(@RpcParameter(name="title")@RpcOptional
java.lang.String title,
@RpcParameter(name="message")@RpcOptional
java.lang.String message)
import android
droid=android.Android()
droid.dialogCreateAlert("I like swords.","Do you like swords?")
droid.dialogSetPositiveButtonText("Yes")
droid.dialogSetNegativeButtonText("No")
droid.dialogShow()
response=droid.dialogGetResponse().result
droid.dialogDismiss()
if response.has_key("which"):
result=response["which"]
if result=="positive":
print "Yay! I like swords too!"
elif result=="negative":
print "Oh. How sad."
elif response.has_key("canceled"): # Yes, I know it's mispelled.
print "You can't even make up your mind?"
else:
print "Unknown response=",response
print "Done"
@Rpc(description="Create seek bar dialog.")
public void dialogCreateSeekBar(@RpcParameter(name="starting value")@RpcDefault(value="50")
java.lang.Integer progress,
@RpcParameter(name="maximum value")@RpcDefault(value="100")
java.lang.Integer max,
@RpcParameter(name="title")
java.lang.String title,
@RpcParameter(name="message")
java.lang.String message)
@Rpc(description="Create time picker dialog.")
public void dialogCreateTimePicker(@RpcParameter(name="hour")@RpcDefault(value="0")
java.lang.Integer hour,
@RpcParameter(name="minute")@RpcDefault(value="0")
java.lang.Integer minute,
@RpcParameter(name="is24hour",description="Use 24 hour clock")@RpcDefault(value="false")
java.lang.Boolean is24hour)
@Rpc(description="Create date picker dialog.")
public void dialogCreateDatePicker(@RpcParameter(name="year")@RpcDefault(value="1970")
java.lang.Integer year,
@RpcParameter(name="month")@RpcDefault(value="1")
java.lang.Integer month,
@RpcParameter(name="day")@RpcDefault(value="1")
java.lang.Integer day)
@Rpc(description="Dismiss dialog.") public void dialogDismiss()
@Rpc(description="Show dialog.")
public void dialogShow()
throws java.lang.InterruptedException
java.lang.InterruptedException
@Rpc(description="Set progress dialog current value.")
public void dialogSetCurrentProgress(@RpcParameter(name="current")
java.lang.Integer current)
@Rpc(description="Set progress dialog maximum value.")
public void dialogSetMaxProgress(@RpcParameter(name="max")
java.lang.Integer max)
@Rpc(description="Set alert dialog positive button text.")
public void dialogSetPositiveButtonText(@RpcParameter(name="text")
java.lang.String text)
@Rpc(description="Set alert dialog button text.")
public void dialogSetNegativeButtonText(@RpcParameter(name="text")
java.lang.String text)
@Rpc(description="Set alert dialog button text.")
public void dialogSetNeutralButtonText(@RpcParameter(name="text")
java.lang.String text)
@Rpc(description="Set alert dialog list items.")
public void dialogSetItems(@RpcParameter(name="items")
JSONArray items)
@Rpc(description="Set dialog single choice items and selected item.")
public void dialogSetSingleChoiceItems(@RpcParameter(name="items")
JSONArray items,
@RpcParameter(name="selected",description="selected item index")@RpcDefault(value="0")
java.lang.Integer selected)
dialogGetSelectedItems() to find out what was
selected.
@Rpc(description="Set dialog multiple choice items and selection.")
public void dialogSetMultiChoiceItems(@RpcParameter(name="items")
JSONArray items,
@RpcParameter(name="selected",description="list of selected items")@RpcOptional
JSONArray selected)
throws JSONException
dialogGetSelectedItems() to find out what was
selected.
JSONException@Rpc(description="Returns dialog response.") public java.lang.Object dialogGetResponse()
@Rpc(description="This method provides list of items user selected.",
returns="Selected items")
public java.util.Set<java.lang.Integer> dialogGetSelectedItems()
@Rpc(description="Display a WebView with the given URL.")
public void webViewShow(@RpcParameter(name="url")
java.lang.String url,
@RpcParameter(name="wait",description="block until the user exits the WebView")@RpcOptional
java.lang.Boolean wait)
throws java.io.IOException
java.io.IOException
@Rpc(description="Adds a new item to context menu.")
public void addContextMenuItem(@RpcParameter(name="label",description="label for this menu item")
java.lang.String label,
@RpcParameter(name="event",description="event that will be generated on menu item click")
java.lang.String event,
@RpcParameter(name="eventData")@RpcOptional
java.lang.Object data)
webViewShow(java.lang.String, java.lang.Boolean)
@Rpc(description="Adds a new item to options menu.")
public void addOptionsMenuItem(@RpcParameter(name="label",description="label for this menu item")
java.lang.String label,
@RpcParameter(name="event",description="event that will be generated on menu item click")
java.lang.String event,
@RpcParameter(name="eventData")@RpcOptional
java.lang.Object data,
@RpcParameter(name="iconName",description="Android system menu icon, see http://developer.android.com/reference/android/R.drawable.html")@RpcOptional
java.lang.String iconName)
import android
droid=android.Android()
droid.addOptionsMenuItem("Silly","silly",None,"star_on")
droid.addOptionsMenuItem("Sensible","sensible","I bet.","star_off")
droid.addOptionsMenuItem("Off","off",None,"ic_menu_revert")
print "Hit menu to see extra options."
print "Will timeout in 10 seconds if you hit nothing."
while True: # Wait for events from the menu.
response=droid.eventWait(10000).result
if response==None:
break
print response
if response["name"]=="off":
break
print "And done."
@Rpc(description="Removes all items previously added to context menu.") public void clearContextMenu()
@Rpc(description="Removes all items previously added to options menu.") public void clearOptionsMenu()
public void onCreateContextMenu(ContextMenu menu,
View v,
ContextMenuInfo menuInfo)
public boolean onPrepareOptionsMenu(Menu menu)
@Rpc(description="Show Full Screen.")
public java.util.List<java.lang.String> fullShow(@RpcParameter(name="layout",description="String containing View layout")
java.lang.String layout)
throws java.lang.InterruptedException
java.lang.InterruptedException@Rpc(description="Dismiss Full Screen.") public void fullDismiss()
@Rpc(description="Get Fullscreen Properties") public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> fullQuery()
@Rpc(description="Get fullscreen properties for a specific widget")
public java.util.Map<java.lang.String,java.lang.String> fullQueryDetail(@RpcParameter(name="id",description="id of layout widget")
java.lang.String id)
@Rpc(description="Set fullscreen widget property")
public java.lang.String fullSetProperty(@RpcParameter(name="id",description="id of layout widget")
java.lang.String id,
@RpcParameter(name="property",description="name of property to set")
java.lang.String property,
@RpcParameter(name="value",description="value to set property to")
java.lang.String value)
@Rpc(description="Attach a list to a fullscreen widget")
public java.lang.String fullSetList(@RpcParameter(name="id",description="id of layout widget")
java.lang.String id,
@RpcParameter(name="list",description="List to set")
JSONArray items)
@Rpc(description="Override default key actions")
public JSONArray fullKeyOverride(@RpcParameter(name="keycodes",description="List of keycodes to override")
JSONArray keycodes,
@RpcParameter(name="enable",description="Turn overriding or off")@RpcDefault(value="true")
java.lang.Boolean enable)
throws JSONException
droid.fullKeyOverride([24,25],True)This will override the default behaviour of the volume keys (codes 24 and 25) so that they do not actually adjust the volume.
JSONExceptionpublic void shutdown()
RpcReceiver
shutdown in class RpcReceiver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||