parent
9a15737577
commit
416b05c1e5
@ -437,7 +437,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
if (option.hasMoreElements()) {
|
if (option.hasMoreElements()) {
|
||||||
String key = option.nextToken();
|
String key = option.nextToken();
|
||||||
String value = option.nextToken();
|
String value = option.nextToken();
|
||||||
if (!customizableOptions.contains(key)){
|
if (!customizableOptions.contains(key)) {
|
||||||
value = value.equals("yes") || value.equals("no") ? value : "yes";
|
value = value.equals("yes") || value.equals("no") ? value : "yes";
|
||||||
}
|
}
|
||||||
map.put(key, value);
|
map.put(key, value);
|
||||||
@ -616,7 +616,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return this.showLocationBar;
|
return this.showLocationBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InAppBrowser getInAppBrowser(){
|
private InAppBrowser getInAppBrowser() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,7 +730,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createCloseButton(int id){
|
private View createCloseButton(int id) {
|
||||||
View _close;
|
View _close;
|
||||||
Resources activityRes = cordova.getActivity().getResources();
|
Resources activityRes = cordova.getActivity().getResources();
|
||||||
|
|
||||||
@ -906,9 +906,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
// Footer
|
// Footer
|
||||||
RelativeLayout footer = new RelativeLayout(cordova.getActivity());
|
RelativeLayout footer = new RelativeLayout(cordova.getActivity());
|
||||||
int _footerColor;
|
int _footerColor;
|
||||||
if(footerColor != ""){
|
if(footerColor != "") {
|
||||||
_footerColor = Color.parseColor(footerColor);
|
_footerColor = Color.parseColor(footerColor);
|
||||||
}else{
|
} else {
|
||||||
_footerColor = android.graphics.Color.LTGRAY;
|
_footerColor = android.graphics.Color.LTGRAY;
|
||||||
}
|
}
|
||||||
footer.setBackgroundColor(_footerColor);
|
footer.setBackgroundColor(_footerColor);
|
||||||
@ -1208,26 +1208,26 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
|
|
||||||
if (beforeload.equals("yes") && method == null) {
|
if (beforeload.equals("yes") && method == null) {
|
||||||
useBeforeload = true;
|
useBeforeload = true;
|
||||||
}else if(beforeload.equals("yes")
|
} else if(beforeload.equals("yes")
|
||||||
//TODO handle POST requests then this condition can be removed:
|
//TODO handle POST requests then this condition can be removed:
|
||||||
&& !method.equals("POST"))
|
&& !method.equals("POST"))
|
||||||
{
|
{
|
||||||
useBeforeload = true;
|
useBeforeload = true;
|
||||||
}else if(beforeload.equals("get") && (method == null || method.equals("GET"))){
|
} else if(beforeload.equals("get") && (method == null || method.equals("GET"))) {
|
||||||
useBeforeload = true;
|
useBeforeload = true;
|
||||||
}else if(beforeload.equals("post") && (method == null || method.equals("POST"))){
|
} else if(beforeload.equals("post") && (method == null || method.equals("POST"))) {
|
||||||
//TODO handle POST requests
|
//TODO handle POST requests
|
||||||
errorMessage = "beforeload doesn't yet support POST requests";
|
errorMessage = "beforeload doesn't yet support POST requests";
|
||||||
}
|
}
|
||||||
|
|
||||||
// On first URL change, initiate JS callback. Only after the beforeload event, continue.
|
// On first URL change, initiate JS callback. Only after the beforeload event, continue.
|
||||||
if (useBeforeload && this.waitForBeforeload) {
|
if (useBeforeload && this.waitForBeforeload) {
|
||||||
if(sendBeforeLoad(url, method)){
|
if(sendBeforeLoad(url, method)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(errorMessage != null){
|
if(errorMessage != null) {
|
||||||
try {
|
try {
|
||||||
LOG.e(LOG_TAG, errorMessage);
|
LOG.e(LOG_TAG, errorMessage);
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
@ -1236,7 +1236,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
obj.put("code", -1);
|
obj.put("code", -1);
|
||||||
obj.put("message", errorMessage);
|
obj.put("message", errorMessage);
|
||||||
sendUpdate(obj, true, PluginResult.Status.ERROR);
|
sendUpdate(obj, true, PluginResult.Status.ERROR);
|
||||||
}catch(Exception e){
|
} catch(Exception e) {
|
||||||
LOG.e(LOG_TAG, "Error sending loaderror for " + url + ": " + e.toString());
|
LOG.e(LOG_TAG, "Error sending loaderror for " + url + ": " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1322,12 +1322,12 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sendBeforeLoad(String url, String method){
|
private boolean sendBeforeLoad(String url, String method) {
|
||||||
try {
|
try {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("type", "beforeload");
|
obj.put("type", BEFORELOAD);
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
if(method != null){
|
if(method != null) {
|
||||||
obj.put("method", method);
|
obj.put("method", method);
|
||||||
}
|
}
|
||||||
sendUpdate(obj, true);
|
sendUpdate(obj, true);
|
||||||
@ -1365,7 +1365,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
|
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method){
|
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method) {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,13 +1406,11 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
|
|
||||||
// Set the namespace for postMessage()
|
// Set the namespace for postMessage()
|
||||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
|
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
|
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user