© 2009-2010 OMTP Ltd. All rights reserved. OMTP and OMTP BONDI are registered trademarks of OMTP Ltd.
To allow widgets to access functions that integrate with the widget runtime user interface.
Menu
WidgetActivateCallback
WidgetDeactivateCallback
WidgetKeyPressCallback
WidgetOrientationChangeCallback
WidgetMenuSelectCallback
UIManager
MenuItem
Preferences
UIManagerObject
| Interface | Method |
|---|---|
| WidgetActivateCallback | void onActivate() |
| WidgetDeactivateCallback | void onDeactivate() |
| WidgetKeyPressCallback | void onKeyPress(unsigned short keyCode) |
| WidgetOrientationChangeCallback | void onOrientationChange() |
| WidgetMenuSelectCallback | void onSelect() |
| UIManager | MenuItem getSoftKey(unsigned short id) void setOnActivate(WidgetActivateCallback handler) void setOnDeactivate(WidgetDeactivateCallback handler) void setOnKeyPress(WidgetKeyPressCallback handler) void beep(unsigned long duration, unsigned short frequency) void startVibrate(unsigned long duration, unsigned short intensity) void stopVibrate() void setOnOrientationChange(WidgetOrientationChangeCallback handler) void lightOn(unsigned long duration, unsigned short intensity, boolean fadeIn) void lightOff(boolean fadeOut) Preferences getPreferences() |
| MenuItem | void setOnMenuSelect(WidgetMenuSelectCallback handler) MenuItem getMenuItemById(unsigned long id) MenuItem appendMenuItem(unsigned long id, DOMString text, WidgetMenuSelectCallback onSelect) void removeMenuItem(unsigned long id) void removeAllMenuItems() |
| Preferences | void setWallpaper(DOMString wallpaper) void setCallRingtone(DOMString ringtone) void setMessageRingtone(DOMString ringtone) |
| UIManagerObject |
Copyright 2010 OMTP Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This module provides a mechanism to interact with the end-user or configure the way in which the user visualizes or navigates Web applications. This includes features such as:
- navigation mechanisms
- soft-key and menu configuration
- effectors, vibration, sounds, screen brightness
- configuration of general appearance, e.g. portrait/landscape, full-screen
- behaviour configuration when moving from foreground to background.
Some ui operations are not supported outside of the widget runtime context. Examples are modifying the device soft key menus, and de-activating a widget. A DeviceAPIError exception is thrown with code NOT_SUPPORTED_ERROR when script attempts to perform an operation that is not supported.
This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions covered is provided.
When the feature
http://bondi.omtp.org/api/1.1/ui
is successfully requested, the interface
UIManager
is instantiated, and the resulting object appears in the global
namespace as
Bondi.ui.
Allow access to the ui module
Device capabilities:
ui
ui
Access to the user interaction capability
Menu
Array of MenuItems.
typedef sequence<MenuItem> Menu;
WidgetActivateCallback
Callback interface to handle widget activation notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetActivateCallback {
void onActivate();
};
onActivate
Method invoked when the widget is activated
void onActivate();
WidgetDeactivateCallback
Callback interface to handle widget deactivation notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetDeactivateCallback {
void onDeactivate();
};
onDeactivate
Method invoked when the widget is deactivated
void onDeactivate();
WidgetKeyPressCallback
Callback interface to handle keypress notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetKeyPressCallback {
void onKeyPress(in unsigned short keyCode);
};
onKeyPress
Method invoked when a key is pressed
void onKeyPress(in unsigned short keyCode);
WidgetOrientationChangeCallback
Callback interface to handle display orientation change notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetOrientationChangeCallback {
void onOrientationChange();
};
onOrientationChange
Method invoked when the display orientation is changed
void onOrientationChange();
WidgetMenuSelectCallback
Callback interface to handle menu selection notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetMenuSelectCallback {
void onSelect();
};
onSelect
Method invoked when a menu option has been selected
void onSelect();
UIManager
UIManager interface.
interface UIManager {
const unsigned short LEFT_SOFT_KEY = 0;
const unsigned short RIGHT_SOFT_KEY = 1;
readonly attribute Preferences preferences;
MenuItem getSoftKey(in unsigned short id)
raises(DeviceAPIError);
void setOnActivate(in WidgetActivateCallback handler)
raises(DeviceAPIError);
void setOnDeactivate(in WidgetDeactivateCallback handler)
raises(DeviceAPIError);
attribute boolean isActive
setraises(DeviceAPIError);
const unsigned short NAVIGATION_CURSOR = 0;
const unsigned short NAVIGATION_TABBED = 1;
attribute unsigned short navigationMode
setraises(DeviceAPIError);
void setOnKeyPress(in WidgetKeyPressCallback handler)
raises(DeviceAPIError);
void beep(in unsigned long duration,in unsigned short frequency);
const unsigned short INFINITE_DURATION = 0;
void startVibrate(in unsigned long duration, in unsigned short intensity);
void stopVibrate();
readonly attribute boolean isRotationSupported;
const unsigned short ORIENTATION_0 = 0;
const unsigned short ORIENTATION_90 = 90;
const unsigned short ORIENTATION_180 = 180;
const unsigned short ORIENTATION_270 = 270;
attribute unsigned short displayOrientation;
void setOnOrientationChange(in WidgetOrientationChangeCallback handler)
raises(DeviceAPIError);
attribute boolean softKeysVisible
setraises(DeviceAPIError);
attribute boolean statusBarVisible
setraises(DeviceAPIError);
void lightOn(in unsigned long duration, in unsigned short intensity, in boolean fadeIn);
void lightOff(in boolean fadeOut);
Preferences getPreferences();
};
This is the top-level interface for the org.omtp.bondi.ui module. It allows widgets to access functions that integrate with the WRT user interface
unsigned short LEFT_SOFT_KEY
Constant for getSoftKey method.
This constant is used in conjunction with getSoftKey to specify which soft key to retrieve.
// Get the left soft key menu item and set the text.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
leftMenu.text = "Close";
unsigned short RIGHT_SOFT_KEY
Constant for getSoftKey method.
This constant is used in conjunction with getSoftKey to specify which soft key to retrieve.
// Get the right soft key menu item and set the text.
var rightMenu = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
rightMenu.text = "Options";
unsigned short NAVIGATION_CURSOR
Constant for navigationMode property.
Indicates that the widget will use a pointer type mode of navigation.
unsigned short NAVIGATION_TABBED
Constant for navigationMode property.
Indicates that the widget wants to receive keyboard navigation.
unsigned short INFINITE_DURATION
Vibration constants.
unsigned short ORIENTATION_0
Constant for displayOrientation property.
unsigned short ORIENTATION_90
Constant for displayOrientation property.
unsigned short ORIENTATION_180
Constant for displayOrientation property.
unsigned short ORIENTATION_270
Constant for displayOrientation property.
readonly
Preferences preferences
Access to the ui Preferences.
This property is read-only.
boolean isActive
Property for access to the foreground status of the widget.
This property can be used to query the foreground status of the widget as well as to send the widget to the background or bring it to the foreground.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Send widget to background.
bondi.ui.isActive = false;
Property for access to the navigation mode.
INVALID_ARGUMENT_ERROR if handler is invalid.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Set the navigation mode.
bondi.ui.navigationMode = bondi.ui.NAVIGATION_TABBED;
readonly
boolean isRotationSupported
Determines if the device supports changes in display orientation.
This property is read-only.
unsigned short displayOrientation
Display orientation property.
This method can be used to query the current display orientation, as well as to set a new display orientation.
// Set the display orientation to 90 degrees.
bondi.ui.displayOrientation = bondi.ui.ORIENTATION_90;
boolean softKeysVisible
Property to set the soft key visibility.
This property can be used to query as well as set the visibility of the device softkey menu bar.
Note: if you hide the softKeys remember to add a means to close/deactivate your widget to the user interface.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Hide the softkeys.
bondi.ui.softKeysVisible = false;
boolean statusBarVisible
Property to set the status bar visibility.
This property can be used to query as well as set the visibility of the device status bar.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Go fullscreen.
bondi.ui.softKeysVisible = false;
bondi.ui.statusBarVisible = false;
getSoftKey
Access the top-level menuitem object.
MenuItem getSoftKey(in unsigned short id);
Used to access the top-level menuitem object of the device soft-key for the specified side.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Get the left soft-key.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
// Set the soft-key text.
leftMenu.text = 'Close';
// Set a handler so that when the soft-key is pressed the widget is sent to the background.
leftMenu.setOnMenuSelect(function() { bondi.ui.isActive = false; });
setOnActivate
Set handler for widget activation notification.
void setOnActivate(in WidgetActivateCallback handler);
Notifies when the widget is activated and brought to the foreground.
INVALID_ARGUMENT_ERROR if handler is invalid.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Request to be notified when the widget is activated.
function goToForeground()
{
// Widget is now in the foreground.
// Start processor intensive routine...
}
bondi.ui.setOnActivate(goToForeground);
setOnDeactivate
Set handler for widget de-activation notification.
void setOnDeactivate(in WidgetDeactivateCallback handler);
Notifies when the widget is de-activated and sent to the background.
INVALID_ARGUMENT_ERROR if handler is invalid.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
// Request to be notified when the widget is de-activated.
function goToBackground()
{
// Widget is now in the background.
// kill processor intensive routine...
}
bondi.ui.setOnDeactivate(goToBackground);
setOnKeyPress
Sets the handler to receive key input.
void setOnKeyPress(in WidgetKeyPressCallback handler);
This handler is called if the navigation mode is set to NAVIGATION_TABBED.
INVALID_ARGUMENT_ERROR if handler is invalid.
NOT_SUPPORTED_ERROR if called from a web-page rather than a widget.
beep
Produce a beep from the device.
void beep(in unsigned long duration, in unsigned short frequency);
Note: duration and frequency parameters are ignored in this implementation.
startVibrate
Switch on the device vibration for the specified period and intensity.
void startVibrate(in unsigned long duration, in unsigned short intensity);
Note: intensity parameter is ignored in this implementation.
stopVibrate
Switches off the device vibration.
void stopVibrate();
setOnOrientationChange
Sets a handler to receive notification when screen orientation changes.
void setOnOrientationChange(in WidgetOrientationChangeCallback handler);
INVALID_ARGUMENT_ERROR if handler is invalid.
lightOn
Switches the backlight on for the given duration.
void lightOn(in unsigned long duration, in unsigned short intensity, in boolean fadeIn);
lightOff
Switches the backlight off.
void lightOff(in boolean fadeOut);
getPreferences
Gets a reference to the the preferences object
Preferences getPreferences();
MenuItem
MenuItem interface.
interface MenuItem {
readonly attribute unsigned long id;
attribute DOMString text;
void setOnMenuSelect(in WidgetMenuSelectCallback handler)
raises(DeviceAPIError);
readonly attribute Menu menuItems;
MenuItem getMenuItemById(in unsigned long id);
MenuItem appendMenuItem(in unsigned long id, in DOMString text, in WidgetMenuSelectCallback onSelect)
raises(DeviceAPIError);
void removeMenuItem(in unsigned long id)
raises(DeviceAPIError);
void removeAllMenuItems();
};
This interface provides the ability to interact with and modify the widget runtime soft-key menus. MenuItem has access to the collection of child menu items via menuItems array.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
leftMenu.text = "refresh";
readonly
unsigned long id
Get the id of this menu item.
This property is read-only.
var id = menuItem.id;
DOMString text
Gets/Sets the text of the menu item.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Options";
Gets the child items of this menu item.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var subMenu = menuItem.menuItems;
setOnMenuSelect
Sets the handler to be called when the menu item is selected.
void setOnMenuSelect(in WidgetMenuSelectCallback handler);
INVALID_ARGUMENT_ERROR if handler is invalid.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Say hello";
menuItem.setOnMenuSelect(function() { alert("hello!"); });
getMenuItemById
Retrieves a menu item from the child nodes (menuItems) using the id.
MenuItem getMenuItemById(in unsigned long id);
appendMenuItem
Adds a child menu item to this menu item.
MenuItem appendMenuItem(in unsigned long id, in DOMString text, in WidgetMenuSelectCallback onSelect);
INVALID_ARGUMENT_ERROR if any arguments are invalid.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Options";
var colourMenu = menuItem.appendMenuItem(0,"Change colour",onColourChange);
removeMenuItem
Removes the menu item with the given id from the child nodes (menuItems).
void removeMenuItem(in unsigned long id);
INVALID_ARGUMENT_ERROR if no item exists with given id.
removeAllMenuItems
Removes all child menu items from this menu item.
void removeAllMenuItems();
Preferences
Preferences interface.
interface Preferences {
attribute unsigned long callRingtoneVolume;
attribute unsigned long messageRingtoneVolume;
attribute boolean isVibrationActive;
void setWallpaper(in DOMString wallpaper)
raises(DeviceAPIError);
void setCallRingtone(in DOMString ringtone)
raises(DeviceAPIError);
void setMessageRingtone(in DOMString ringtone)
raises(DeviceAPIError);
};
It allows widgets to configure the settings linked to the device User Experience such as ringtones, wallpapers, volume...
unsigned long callRingtoneVolume
Incoming call ringtone volume
The range of possible values is from 0 (no sound) to 100 (maximum value)
bondi.ui.preferences.callRingtoneVolume = 100;
unsigned long messageRingtoneVolume
Incoming message ringtone volume
The range of possible values is from 0 (no sound) to 100 (maximum value)
bondi.ui.preferences.messageRingtoneVolume = 100;
boolean isVibrationActive
Incoming event vibration setting
If false the device will not vibrate upon an incoming event, if true the device will vibrate.
if (bondi.ui.preferences.isVibrationActive == true)
alert("Vibration is set to active);
else
alert("The device won't vibrate);
setWallpaper
Set idle screen wallpaper.
void setWallpaper(in DOMString wallpaper);
Configures the idle screen wallpaper with the image file passed as input parameter. In case the file format is not supported or the file is invalid an INVALID_ARGUMENT_ERROR will be raised.
INVALID_ARGUMENT_ERROR if the wallpaper is invalid or the format is not supported
var myImage = "/pictures/myImage.jpg"); bondi.ui.preferences.setWallpaper(myImage);
setCallRingtone
Set default ringtone for incoming calls.
void setCallRingtone(in DOMString ringtone);
Configures the default ringtone for incoming calls with the sound file passed as input parameter. In case the file format is not supported or the file is invalid and INVALID_ARGUMENT_ERROR will be raised.
INVALID_ARGUMENT_ERROR if the ringtone is invalid or the format is not supported
var mySound = "/sounds/ring.wav"); bondi.ui.preferences.setCallRingtone(mySound);
setMessageRingtone
Set default ringtone for incoming messages.
void setMessageRingtone(in DOMString ringtone);
Configures the default ringtone for incoming messages with the sound file passed as input parameter. In case the file format is not supported or the file is invalid and INVALID_ARGUMENT_ERROR will be raised.
INVALID_ARGUMENT_ERROR if the ringtone is invalid or the format is not supported
var mySound = "/sounds/message.wav"); bondi.ui.preferences.setMessageRingtone(mySound);
UIManagerObject
Specifies what is instantiated at feature request
interface UIManagerObject {
readonly attribute UIManager ui;
};
Bondi implements UIManagerObject;