webview_android.h
The Android webview backend -- the plugin's page in an Android WebView, over the app's activity.
#include <sonore/webview_android.h>- 1type
- Guides: The web editor
On this page
Design notes
A plugin with a page of its own (SONORE_UI_HTML) shows it in a webview on every platform, and on Android that is android.webkit.WebView: a Java view, made, placed and fed through SonoreBridge (sdk/android/java), the Java the APK carries. The page reaches the app through window.sonoreAndroid.post -- a @JavascriptInterface object, the third channel gui.h's bridge script tries, after WebView2's and WebKit's -- which Java calls on a thread of its own; each message is handed to the main thread (MessageManager) before onMessage sees it, as every other backend delivers on the UI thread.
What Android does differently:
- The bridge is put INTO the page, at the top of its head, rather than injected at document start: a WebView offers no start-of-document hook an app can rely on, and a script that comes first in the document runs before anything the page itself declares.
- The page is laid over the activity's own surface, inside the system bars, and sized in device pixels; its CSS pixels are the display's density-independent ones, as a page expects.
- No timer of its own: the app's frame clock calls tick(), which runs onTick at about 30 Hz.
Needs the activity (android_app.h) and the APK's classes.dex; without them create() says so and returns false, and the native editor opens instead.
Types 1
The plugin's page in an Android WebView. The shape every backend has.