public class ReactWebViewManager extends SimpleViewManager<android.webkit.WebView>
WebView
Can accept following commands: - GO_BACK - GO_FORWARD - RELOAD
WebView
instances could emit following direct events: - topLoadingFinish -
topLoadingStart - topLoadingError
Each event will carry the following properties: - target - view's react tag - url - url set for the webview - loading - whether webview is in a loading state - title - title of the current page - canGoBack - boolean, whether there is anything on a history stack to go back - canGoForward - boolean, whether it is possible to request GO_FORWARD command
Modifier and Type | Class and Description |
---|---|
protected static class |
ReactWebViewManager.ReactWebView
Subclass of
WebView that implements LifecycleEventListener interface in order
to call WebView.destroy() on activity destroy event and also to clear the client |
protected static class |
ReactWebViewManager.ReactWebViewClient |
NativeModule.NativeMethod
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BLANK_URL |
protected static java.lang.String |
BRIDGE_NAME |
static int |
COMMAND_GO_BACK |
static int |
COMMAND_GO_FORWARD |
static int |
COMMAND_INJECT_JAVASCRIPT |
static int |
COMMAND_POST_MESSAGE |
static int |
COMMAND_RELOAD |
static int |
COMMAND_STOP_LOADING |
protected static java.lang.String |
HTML_ENCODING |
protected static java.lang.String |
HTML_MIME_TYPE |
protected static java.lang.String |
HTTP_METHOD_POST |
protected android.webkit.WebView.PictureListener |
mPictureListener |
protected WebViewConfig |
mWebViewConfig |
static java.lang.String |
REACT_CLASS |
PROP_NATIVE_ID, PROP_TEST_ID
METHOD_TYPE_ASYNC, METHOD_TYPE_PROMISE, METHOD_TYPE_SYNC
Constructor and Description |
---|
ReactWebViewManager() |
ReactWebViewManager(WebViewConfig webViewConfig) |
Modifier and Type | Method and Description |
---|---|
protected void |
addEventEmitters(ThemedReactContext reactContext,
android.webkit.WebView view)
Subclasses can override this method to install custom event emitters on the given View.
|
protected ReactWebViewManager.ReactWebView |
createReactWebViewInstance(ThemedReactContext reactContext) |
protected android.webkit.WebView |
createViewInstance(ThemedReactContext reactContext)
Subclasses should return a new View instance of the proper type.
|
protected static void |
dispatchEvent(android.webkit.WebView webView,
Event event) |
java.util.Map<java.lang.String,java.lang.Integer> |
getCommandsMap()
Subclasses of
ViewManager that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray) should override this method returning the
map between names of the commands and IDs that are then used in ViewManager.receiveCommand(T, int, com.facebook.react.bridge.ReadableArray) method
whenever the command is dispatched for this particular ViewManager . |
java.lang.String |
getName() |
protected android.webkit.WebView.PictureListener |
getPictureListener() |
void |
onDropViewInstance(android.webkit.WebView webView)
Called when view is detached from view hierarchy and allows for some additional cleanup by
the
ViewManager subclass. |
void |
receiveCommand(android.webkit.WebView root,
int commandId,
ReadableArray args)
Subclasses may use this method to receive events/commands directly from JS through the
UIManager . |
void |
setAllowFileAccess(android.webkit.WebView view,
java.lang.Boolean allowFileAccess) |
void |
setAllowUniversalAccessFromFileURLs(android.webkit.WebView view,
boolean allow) |
void |
setDomStorageEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setGeolocationEnabled(android.webkit.WebView view,
java.lang.Boolean isGeolocationEnabled) |
void |
sethardwareAccelerationEnabledExperimental(android.webkit.WebView view,
boolean enabled) |
void |
setInjectedJavaScript(android.webkit.WebView view,
java.lang.String injectedJavaScript) |
void |
setJavaScriptEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setMediaPlaybackRequiresUserAction(android.webkit.WebView view,
boolean requires) |
void |
setMessagingEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setMixedContentMode(android.webkit.WebView view,
java.lang.String mixedContentMode) |
void |
setOnContentSizeChange(android.webkit.WebView view,
boolean sendContentSizeChangeEvents) |
void |
setOriginWhitelist(android.webkit.WebView view,
ReadableArray originWhitelist) |
void |
setSaveFormDataDisabled(android.webkit.WebView view,
boolean disable) |
void |
setScalesPageToFit(android.webkit.WebView view,
boolean enabled) |
void |
setSource(android.webkit.WebView view,
ReadableMap source) |
void |
setThirdPartyCookiesEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setUrlPrefixesForDefaultIntent(android.webkit.WebView view,
ReadableArray urlPrefixesForDefaultIntent) |
void |
setUserAgent(android.webkit.WebView view,
java.lang.String userAgent) |
createShadowNodeInstance, getShadowNodeClass, updateExtraData
onAfterUpdateTransaction, setAccessibilityComponentType, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLiveRegion, setAccessibilityRole, setBackgroundColor, setElevation, setImportantForAccessibility, setNativeId, setOpacity, setRenderToHardwareTexture, setRotation, setScaleX, setScaleY, setTestId, setTransform, setTranslateX, setTranslateY, setViewStates, setZIndex
createShadowNodeInstance, createView, getExportedCustomBubblingEventTypeConstants, getExportedCustomDirectEventTypeConstants, getExportedViewConstants, getNativeProps, measure, updateLocalData, updateProperties
canOverrideExistingModule, getConstants, hasConstants, initialize, onCatalystInstanceDestroy
public static final java.lang.String REACT_CLASS
protected static final java.lang.String HTML_ENCODING
protected static final java.lang.String HTML_MIME_TYPE
protected static final java.lang.String BRIDGE_NAME
protected static final java.lang.String HTTP_METHOD_POST
public static final int COMMAND_GO_BACK
public static final int COMMAND_GO_FORWARD
public static final int COMMAND_RELOAD
public static final int COMMAND_STOP_LOADING
public static final int COMMAND_POST_MESSAGE
public static final int COMMAND_INJECT_JAVASCRIPT
protected static final java.lang.String BLANK_URL
protected WebViewConfig mWebViewConfig
protected android.webkit.WebView.PictureListener mPictureListener
public ReactWebViewManager()
public ReactWebViewManager(WebViewConfig webViewConfig)
public java.lang.String getName()
getName
in interface NativeModule
getName
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
protected ReactWebViewManager.ReactWebView createReactWebViewInstance(ThemedReactContext reactContext)
protected android.webkit.WebView createViewInstance(ThemedReactContext reactContext)
ViewManager
createViewInstance
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
public void sethardwareAccelerationEnabledExperimental(android.webkit.WebView view, boolean enabled)
public void setJavaScriptEnabled(android.webkit.WebView view, boolean enabled)
public void setThirdPartyCookiesEnabled(android.webkit.WebView view, boolean enabled)
public void setScalesPageToFit(android.webkit.WebView view, boolean enabled)
public void setDomStorageEnabled(android.webkit.WebView view, boolean enabled)
public void setUserAgent(android.webkit.WebView view, java.lang.String userAgent)
public void setMediaPlaybackRequiresUserAction(android.webkit.WebView view, boolean requires)
public void setAllowUniversalAccessFromFileURLs(android.webkit.WebView view, boolean allow)
public void setSaveFormDataDisabled(android.webkit.WebView view, boolean disable)
public void setInjectedJavaScript(android.webkit.WebView view, java.lang.String injectedJavaScript)
public void setMessagingEnabled(android.webkit.WebView view, boolean enabled)
public void setSource(android.webkit.WebView view, ReadableMap source)
public void setOnContentSizeChange(android.webkit.WebView view, boolean sendContentSizeChangeEvents)
public void setMixedContentMode(android.webkit.WebView view, java.lang.String mixedContentMode)
public void setUrlPrefixesForDefaultIntent(android.webkit.WebView view, ReadableArray urlPrefixesForDefaultIntent)
public void setAllowFileAccess(android.webkit.WebView view, java.lang.Boolean allowFileAccess)
public void setGeolocationEnabled(android.webkit.WebView view, java.lang.Boolean isGeolocationEnabled)
public void setOriginWhitelist(android.webkit.WebView view, ReadableArray originWhitelist)
protected void addEventEmitters(ThemedReactContext reactContext, android.webkit.WebView view)
ViewManager
addEventEmitters
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
public java.util.Map<java.lang.String,java.lang.Integer> getCommandsMap()
ViewManager
ViewManager
that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray)
should override this method returning the
map between names of the commands and IDs that are then used in ViewManager.receiveCommand(T, int, com.facebook.react.bridge.ReadableArray)
method
whenever the command is dispatched for this particular ViewManager
.
As an example we may consider ReactWebViewManager
that expose the following commands:
goBack, goForward, reload. In this case the map returned from ViewManager.getCommandsMap()
from
ReactWebViewManager
will look as follows:
{
"goBack": 1,
"goForward": 2,
"reload": 3,
}
Now assuming that "reload" command is dispatched through UIManagerModule
we trigger
ReactWebViewManager#receiveCommand
passing "3" as commandId
argument.getCommandsMap
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
public void receiveCommand(android.webkit.WebView root, int commandId, ReadableArray args)
ViewManager
UIManager
. Good example of such a command would be scrollTo
request with
coordinates for a ScrollView
or goBack
request for a WebView
instance.receiveCommand
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
root
- View instance that should receive the commandcommandId
- code of the commandargs
- optional arguments for the commandpublic void onDropViewInstance(android.webkit.WebView webView)
ViewManager
ViewManager
subclass.onDropViewInstance
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
protected android.webkit.WebView.PictureListener getPictureListener()
protected static void dispatchEvent(android.webkit.WebView webView, Event event)