[Jetpack] UI on Android

Continuing the discussion from [Support] ClickGuard:
https://addons.mozilla.org/en-US/firefox/addon/clickguard/

The SDK high-level API module sdk/ui is not supported on Fennec.
Our add-on ClickGuard needs per-tab toggle user experience for Android (and no more than that). We are using a hotkey (!) now. We want to avoid writing require("chrome") where possible. Must we wait for WebExtensions? Is there any option available?
Thanks.

Android has a “PageActions.jsm” that you can require() in the SDK. While this is not require("chrome") it is still considered a non-SDK API. I couldn’t find any documentation of its API on MDN, however you can find its source here: https://dxr.mozilla.org/mozilla-central/source/mobile/android/modules/PageActions.jsm

To load it with the SDK you’d do something like:

const { PageActions } = require("resource://gre/modules/PageActions.jsm");

PageActions.add(...);

If you want a button in the overflow menu or a context menu item NativeWindow is the API to use.

1 Like