canmove, Confirmed users, Bureaucrats and Sysops emeriti
2,798
edits
MarkFinkle (talk | contribs) (Created page with "=Firefox Android: Add-ons in a Native World= Firefox on Android supports add-ons using the exact same extension system used by all other Gecko-based applications. We did not inv...") |
MarkFinkle (talk | contribs) (→TODO) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= | =Building Add-ons for Firefox on Android= | ||
Firefox on Android supports add-ons using the exact same extension system used by all other Gecko-based applications. We did not invent a new add-on system. This means that building an add-on for Firefox on Android is the same process that would be used for desktop Firefox. Add-ons that work with desktop Firefox '''do not''' automatically work in Firefox on Android. The user interfaces are just too different. | Firefox on Android supports add-ons using the exact same extension system used by all other Gecko-based applications. We did not invent a new add-on system. This means that building an add-on for Firefox on Android is the same process that would be used for desktop Firefox. Add-ons that work with desktop Firefox '''do not''' automatically work in Firefox on Android. The user interfaces are just too different. | ||
| Line 25: | Line 25: | ||
==NativeWindow== | ==NativeWindow== | ||
We wanted to give add-on developers some APIs to manipulate the native Android UI, so we create a helper object called NativeWindow. The API | We wanted to give add-on developers some APIs to manipulate the native Android UI, so we create a helper object called <code>NativeWindow</code>. 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 | label: menu label | ||
icon: file:// or data: URI for an icon | icon: file:// or data: URI for an icon | ||
callback: JS function called when menu is tapped | callback: JS function called when menu is tapped | ||
returns a menu ID that can be used to remove the menu | returns a menu ID that can be used to remove the menu | ||
*/ | */ | ||
menuID = NativeWindow.menu.add(label, icon, callback); | menuID = NativeWindow.menu.add(label, icon, callback); | ||
NativeWindow.menu.remove(menuID); | NativeWindow.menu.remove(menuID); | ||
/* | /* | ||
message: displayed text | message: displayed text | ||
value: string based tag | value: string based tag | ||
| Line 43: | Line 48: | ||
tabID: tab associated with this notification | tabID: tab associated with this notification | ||
options: JS object that has 'persistence' and 'timeout' options | options: JS object that has 'persistence' and 'timeout' options | ||
*/ | */ | ||
NativeWindow.doorhanger.show(message, value, buttons, tabID, options); | NativeWindow.doorhanger.show(message, value, buttons, tabID, options); | ||
NativeWindow.doorhanger.hide(value, tabID); | NativeWindow.doorhanger.hide(value, tabID); | ||
/* | /* | ||
label: menu label | label: menu label | ||
selector: JS object that has a 'matches(element)' function. Used to show the menu. | selector: JS object that has a 'matches(element)' function. Used to show the menu. | ||
callback: JS function called when menu is tapped | callback: JS function called when menu is tapped | ||
returns a menu ID that can be used to remove the menu | returns a menu ID that can be used to remove the menu | ||
*/ | */ | ||
menuID = NativeWindow.contextmenu.add(label, selector, callback); | menuID = NativeWindow.contextmenu.add(label, selector, callback); | ||
NativeWindow.contextmenu.add(menuID); | NativeWindow.contextmenu.add(menuID); | ||
/* | /* | ||
message: displayed text | message: displayed text | ||
duration: "short" or "long"; Used for alert timeout | duration: "short" or "long"; Used for alert timeout | ||
*/ | */ | ||
NativeWindow.toast.show(message, duration); | NativeWindow.toast.show(message, duration); | ||
==TODO== | |||
* Add links to other add-on docs | |||
* Add info on inline-options | |||
* Add links to skeleton add-ons | |||
* Add info on other APIs like nsIHapticFeedback | |||
* Add some code snippets | |||