mozilla

Revision 235457 of Creating a User Interface

  • Revision slug: Extensions/Mobile/Creating_a_User_Interface
  • Revision title: Creating a User Interface
  • Revision id: 235457
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment page created, 188 words added

Revision Content

NativeWindow allows add-on developers to manipulate the native Android UI. The API gives you access to:

  • Android Menu
  • Doorhanger Notifications
  • Context Menus (in web content)
  • Android popup toast alerts

The basic API is here:

/*
label: menu label
icon: file:// or data: URI for an icon
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
*/
menuID = NativeWindow.menu.add(label, icon, callback);
NativeWindow.menu.remove(menuID);
/*
message: displayed text
value: string based tag
buttons: array of JS objects used to create buttons in the notification
tabID: tab associated with this notification
options: JS object that has 'persistence' and 'timeout' options
*/
NativeWindow.doorhanger.show(message, value, buttons, tabID, options);
NativeWindow.doorhanger.hide(value, tabID);
/*
label: menu label
selector: JS object that has a 'matches(element)' function. Used to show the menu.
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
*/
menuID = NativeWindow.contextmenu.add(label, selector, callback);
NativeWindow.contextmenu.add(menuID);
/*
message: displayed text
duration: "short" or "long"; Used for alert timeout
*/
NativeWindow.toast.show(message, duration);

Revision Source

<p><code>NativeWindow</code> allows add-on developers to manipulate the native Android UI. The API gives you access to:</p>
<ul> <li>Android Menu</li> <li>Doorhanger Notifications</li> <li>Context Menus (in web content)</li> <li>Android popup toast alerts</li>
</ul>
<p>The basic API is here:</p>
<pre>/*
label: menu label
icon: file:// or data: URI for an icon
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
*/
menuID = NativeWindow.menu.add(label, icon, callback);
NativeWindow.menu.remove(menuID);
</pre>
<pre>/*
message: displayed text
value: string based tag
buttons: array of JS objects used to create buttons in the notification
tabID: tab associated with this notification
options: JS object that has 'persistence' and 'timeout' options
*/
NativeWindow.doorhanger.show(message, value, buttons, tabID, options);
NativeWindow.doorhanger.hide(value, tabID);
</pre>
<pre>/*
label: menu label
selector: JS object that has a 'matches(element)' function. Used to show the menu.
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
*/
menuID = NativeWindow.contextmenu.add(label, selector, callback);
NativeWindow.contextmenu.add(menuID);
</pre>
<pre>/*
message: displayed text
duration: "short" or "long"; Used for alert timeout
*/
NativeWindow.toast.show(message, duration);
</pre>
Revert to this revision