|
@@ -115,6 +115,12 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
115
|
115
|
public static final int COMMAND_INJECT_JAVASCRIPT = 6;
|
116
|
116
|
public static final int COMMAND_LOAD_URL = 7;
|
117
|
117
|
public static final int COMMAND_FOCUS = 8;
|
|
118
|
+
|
|
119
|
+ // android commands
|
|
120
|
+ public static final int COMMAND_CLEAR_FORM_DATA = 1000;
|
|
121
|
+ public static final int COMMAND_CLEAR_CACHE = 1001;
|
|
122
|
+ public static final int COMMAND_CLEAR_HISTORY = 1002;
|
|
123
|
+
|
118
|
124
|
protected static final String REACT_CLASS = "RNCWebView";
|
119
|
125
|
protected static final String HTML_ENCODING = "UTF-8";
|
120
|
126
|
protected static final String HTML_MIME_TYPE = "text/html";
|
|
@@ -266,7 +272,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
266
|
272
|
break;
|
267
|
273
|
case "LOAD_CACHE_ELSE_NETWORK":
|
268
|
274
|
cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK;
|
269
|
|
- break;
|
|
275
|
+ break;
|
270
|
276
|
case "LOAD_NO_CACHE":
|
271
|
277
|
cacheMode = WebSettings.LOAD_NO_CACHE;
|
272
|
278
|
break;
|
|
@@ -545,17 +551,19 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
545
|
551
|
@Override
|
546
|
552
|
public @Nullable
|
547
|
553
|
Map<String, Integer> getCommandsMap() {
|
548
|
|
- Map map = MapBuilder.of(
|
549
|
|
- "goBack", COMMAND_GO_BACK,
|
550
|
|
- "goForward", COMMAND_GO_FORWARD,
|
551
|
|
- "reload", COMMAND_RELOAD,
|
552
|
|
- "stopLoading", COMMAND_STOP_LOADING,
|
553
|
|
- "postMessage", COMMAND_POST_MESSAGE,
|
554
|
|
- "injectJavaScript", COMMAND_INJECT_JAVASCRIPT,
|
555
|
|
- "loadUrl", COMMAND_LOAD_URL
|
556
|
|
- );
|
557
|
|
- map.put("requestFocus", COMMAND_FOCUS);
|
558
|
|
- return map;
|
|
554
|
+ return MapBuilder.<String, Integer>builder()
|
|
555
|
+ .put("goBack", COMMAND_GO_BACK)
|
|
556
|
+ .put("goForward", COMMAND_GO_FORWARD)
|
|
557
|
+ .put("reload", COMMAND_RELOAD)
|
|
558
|
+ .put("stopLoading", COMMAND_STOP_LOADING)
|
|
559
|
+ .put("postMessage", COMMAND_POST_MESSAGE)
|
|
560
|
+ .put("injectJavaScript", COMMAND_INJECT_JAVASCRIPT)
|
|
561
|
+ .put("loadUrl", COMMAND_LOAD_URL)
|
|
562
|
+ .put("requestFocus", COMMAND_FOCUS)
|
|
563
|
+ .put("clearFormData", COMMAND_CLEAR_FORM_DATA)
|
|
564
|
+ .put("clearCache", COMMAND_CLEAR_CACHE)
|
|
565
|
+ .put("clearHistory", COMMAND_CLEAR_HISTORY)
|
|
566
|
+ .build();
|
559
|
567
|
}
|
560
|
568
|
|
561
|
569
|
@Override
|
|
@@ -606,6 +614,16 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
606
|
614
|
case COMMAND_FOCUS:
|
607
|
615
|
root.requestFocus();
|
608
|
616
|
break;
|
|
617
|
+ case COMMAND_CLEAR_FORM_DATA:
|
|
618
|
+ root.clearFormData();
|
|
619
|
+ break;
|
|
620
|
+ case COMMAND_CLEAR_CACHE:
|
|
621
|
+ boolean includeDiskFiles = args != null && args.getBoolean(0);
|
|
622
|
+ root.clearCache(includeDiskFiles);
|
|
623
|
+ break;
|
|
624
|
+ case COMMAND_CLEAR_HISTORY:
|
|
625
|
+ root.clearHistory();
|
|
626
|
+ break;
|
609
|
627
|
}
|
610
|
628
|
}
|
611
|
629
|
|