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 {
" event: {" +
" type: e.type," +
" loaded: e.loaded," +
" lengthComputable: e.lengthComputable" +
" lengthComputable: e.lengthComputable," +
" total: e.total" +
" }" +
" };" +
......
......@@ -84,17 +84,20 @@ public class InAppWebViewOptions extends Options {
@Override
public Object onParse(Map.Entry<String, Object> pair) {
if (pair.getKey().equals("layoutAlgorithm")) {
switch ((String) pair.getValue()) {
case "NORMAL":
pair.setValue(NORMAL);
return pair;
case "TEXT_AUTOSIZING":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return pair.setValue(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} else {
String value = (String) pair.getValue();
if (value != null) {
switch (value) {
case "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);
......@@ -105,14 +108,16 @@ public class InAppWebViewOptions extends Options {
if (field.getName().equals("layoutAlgorithm")) {
try {
WebSettings.LayoutAlgorithm value = (WebSettings.LayoutAlgorithm) field.get(this);
switch (value) {
case NORMAL:
return "NORMAL";
default:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
return "TEXT_AUTOSIZING";
}
return "NORMAL";
if (value != null) {
switch (value) {
case NORMAL:
return "NORMAL";
default:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
return "TEXT_AUTOSIZING";
}
return "NORMAL";
}
}
} catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage());
......
......@@ -288,7 +288,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
print("Current highlighted: $activeMatchOrdinal, Number of matches found: $numberOfMatches, find operation completed: $isDoneCounting");
},
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.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.headers = {
......@@ -298,11 +298,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return null;
},
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;
},
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;
},
shouldInterceptFetchRequest: (InAppWebViewController controller, FetchRequest fetchRequest) async {
......
......@@ -311,7 +311,7 @@ let interceptAjaxRequestsJS = """
event: {
type: e.type,
loaded: e.loaded,
lengthComputable: e.lengthComputable
lengthComputable: e.lengthComputable,
total: e.total
}
};
......
///
class ContentBlocker {
ContentBlockerTrigger trigger;
ContentBlockerAction action;
......@@ -23,6 +24,7 @@ class ContentBlocker {
}
}
///
class ContentBlockerTriggerResourceType {
final String _value;
const ContentBlockerTriggerResourceType._internal(this._value);
......@@ -42,6 +44,7 @@ class ContentBlockerTriggerResourceType {
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
}
///
class ContentBlockerTriggerLoadType {
final String _value;
const ContentBlockerTriggerLoadType._internal(this._value);
......@@ -54,6 +57,7 @@ class ContentBlockerTriggerLoadType {
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
}
///
class ContentBlockerTrigger {
String urlFilter;
bool urlFilterIsCaseSensitive;
......@@ -136,6 +140,7 @@ class ContentBlockerTrigger {
}
}
///
class ContentBlockerActionType {
final String _value;
const ContentBlockerActionType._internal(this._value);
......@@ -149,6 +154,7 @@ class ContentBlockerActionType {
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
}
///
class ContentBlockerAction {
ContentBlockerActionType type;
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