Commit bb0e7f70 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

fixed InAppWebViewOptions error, fixed javascript error for ajax requests

parent 0c17e032
This diff is collapsed.
...@@ -161,7 +161,7 @@ final public class InAppWebView extends InputAwareWebView { ...@@ -161,7 +161,7 @@ final public class InAppWebView extends InputAwareWebView {
" event: {" + " event: {" +
" type: e.type," + " type: e.type," +
" loaded: e.loaded," + " loaded: e.loaded," +
" lengthComputable: e.lengthComputable" + " lengthComputable: e.lengthComputable," +
" total: e.total" + " total: e.total" +
" }" + " }" +
" };" + " };" +
......
...@@ -84,17 +84,20 @@ public class InAppWebViewOptions extends Options { ...@@ -84,17 +84,20 @@ public class InAppWebViewOptions extends Options {
@Override @Override
public Object onParse(Map.Entry<String, Object> pair) { public Object onParse(Map.Entry<String, Object> pair) {
if (pair.getKey().equals("layoutAlgorithm")) { if (pair.getKey().equals("layoutAlgorithm")) {
switch ((String) pair.getValue()) { String value = (String) pair.getValue();
case "NORMAL": if (value != null) {
pair.setValue(NORMAL); switch (value) {
return pair; case "NORMAL":
case "TEXT_AUTOSIZING":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return pair.setValue(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} else {
pair.setValue(NORMAL); pair.setValue(NORMAL);
} return pair;
return pair; case "TEXT_AUTOSIZING":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return pair.setValue(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} else {
pair.setValue(NORMAL);
}
return pair;
}
} }
} }
return super.onParse(pair); return super.onParse(pair);
...@@ -105,14 +108,16 @@ public class InAppWebViewOptions extends Options { ...@@ -105,14 +108,16 @@ public class InAppWebViewOptions extends Options {
if (field.getName().equals("layoutAlgorithm")) { if (field.getName().equals("layoutAlgorithm")) {
try { try {
WebSettings.LayoutAlgorithm value = (WebSettings.LayoutAlgorithm) field.get(this); WebSettings.LayoutAlgorithm value = (WebSettings.LayoutAlgorithm) field.get(this);
switch (value) { if (value != null) {
case NORMAL: switch (value) {
return "NORMAL"; case NORMAL:
default: return "NORMAL";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) { default:
return "TEXT_AUTOSIZING"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
} return "TEXT_AUTOSIZING";
return "NORMAL"; }
return "NORMAL";
}
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage()); Log.d(LOG_TAG, e.getMessage());
......
...@@ -288,7 +288,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> { ...@@ -288,7 +288,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
print("Current highlighted: $activeMatchOrdinal, Number of matches found: $numberOfMatches, find operation completed: $isDoneCounting"); print("Current highlighted: $activeMatchOrdinal, Number of matches found: $numberOfMatches, find operation completed: $isDoneCounting");
}, },
shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}"); print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}");
// ajaxRequest.method = "GET"; // ajaxRequest.method = "GET";
// ajaxRequest.url = "http://192.168.1.20:8082/test-download-file"; // ajaxRequest.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.headers = { // ajaxRequest.headers = {
...@@ -298,11 +298,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> { ...@@ -298,11 +298,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return null; return null;
}, },
onAjaxReadyStateChange: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { onAjaxReadyStateChange: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}"); print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED; return AjaxRequestAction.PROCEED;
}, },
onAjaxProgress: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { onAjaxProgress: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}"); print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED; return AjaxRequestAction.PROCEED;
}, },
shouldInterceptFetchRequest: (InAppWebViewController controller, FetchRequest fetchRequest) async { shouldInterceptFetchRequest: (InAppWebViewController controller, FetchRequest fetchRequest) async {
......
...@@ -311,7 +311,7 @@ let interceptAjaxRequestsJS = """ ...@@ -311,7 +311,7 @@ let interceptAjaxRequestsJS = """
event: { event: {
type: e.type, type: e.type,
loaded: e.loaded, loaded: e.loaded,
lengthComputable: e.lengthComputable lengthComputable: e.lengthComputable,
total: e.total total: e.total
} }
}; };
......
///
class ContentBlocker { class ContentBlocker {
ContentBlockerTrigger trigger; ContentBlockerTrigger trigger;
ContentBlockerAction action; ContentBlockerAction action;
...@@ -23,6 +24,7 @@ class ContentBlocker { ...@@ -23,6 +24,7 @@ class ContentBlocker {
} }
} }
///
class ContentBlockerTriggerResourceType { class ContentBlockerTriggerResourceType {
final String _value; final String _value;
const ContentBlockerTriggerResourceType._internal(this._value); const ContentBlockerTriggerResourceType._internal(this._value);
...@@ -42,6 +44,7 @@ class ContentBlockerTriggerResourceType { ...@@ -42,6 +44,7 @@ class ContentBlockerTriggerResourceType {
static const RAW = const ContentBlockerTriggerResourceType._internal('raw'); static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
} }
///
class ContentBlockerTriggerLoadType { class ContentBlockerTriggerLoadType {
final String _value; final String _value;
const ContentBlockerTriggerLoadType._internal(this._value); const ContentBlockerTriggerLoadType._internal(this._value);
...@@ -54,6 +57,7 @@ class ContentBlockerTriggerLoadType { ...@@ -54,6 +57,7 @@ class ContentBlockerTriggerLoadType {
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party'); static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
} }
///
class ContentBlockerTrigger { class ContentBlockerTrigger {
String urlFilter; String urlFilter;
bool urlFilterIsCaseSensitive; bool urlFilterIsCaseSensitive;
...@@ -136,6 +140,7 @@ class ContentBlockerTrigger { ...@@ -136,6 +140,7 @@ class ContentBlockerTrigger {
} }
} }
///
class ContentBlockerActionType { class ContentBlockerActionType {
final String _value; final String _value;
const ContentBlockerActionType._internal(this._value); const ContentBlockerActionType._internal(this._value);
...@@ -149,6 +154,7 @@ class ContentBlockerActionType { ...@@ -149,6 +154,7 @@ class ContentBlockerActionType {
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https'); static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
} }
///
class ContentBlockerAction { class ContentBlockerAction {
ContentBlockerActionType type; ContentBlockerActionType type;
String selector; String selector;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment