mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 08:53:24 +08:00
CB-3420: add hidden option to InAppBrowser
This commit is contained in:
parent
0dd4951be7
commit
c3b8b279b0
@ -69,8 +69,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private static final String SELF = "_self";
|
private static final String SELF = "_self";
|
||||||
private static final String SYSTEM = "_system";
|
private static final String SYSTEM = "_system";
|
||||||
// private static final String BLANK = "_blank";
|
// private static final String BLANK = "_blank";
|
||||||
private static final String LOCATION = "location";
|
|
||||||
private static final String EXIT_EVENT = "exit";
|
private static final String EXIT_EVENT = "exit";
|
||||||
|
private static final String LOCATION = "location";
|
||||||
|
private static final String HIDDEN = "hidden";
|
||||||
private static final String LOAD_START_EVENT = "loadstart";
|
private static final String LOAD_START_EVENT = "loadstart";
|
||||||
private static final String LOAD_STOP_EVENT = "loadstop";
|
private static final String LOAD_STOP_EVENT = "loadstop";
|
||||||
private static final String LOAD_ERROR_EVENT = "loaderror";
|
private static final String LOAD_ERROR_EVENT = "loaderror";
|
||||||
@ -80,8 +81,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private Dialog dialog;
|
private Dialog dialog;
|
||||||
private WebView inAppWebView;
|
private WebView inAppWebView;
|
||||||
private EditText edittext;
|
private EditText edittext;
|
||||||
private boolean showLocationBar = true;
|
|
||||||
private CallbackContext callbackContext;
|
private CallbackContext callbackContext;
|
||||||
|
private boolean showLocationBar = true;
|
||||||
|
private boolean openWindowHidden = false;
|
||||||
private String buttonLabel = "Done";
|
private String buttonLabel = "Done";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,6 +187,16 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
injectDeferredObject(args.getString(0), jsWrapper);
|
injectDeferredObject(args.getString(0), jsWrapper);
|
||||||
}
|
}
|
||||||
|
else if (action.equals("show")) {
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.cordova.getActivity().runOnUiThread(runnable);
|
||||||
|
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -361,11 +373,16 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
public String showWebPage(final String url, HashMap<String, Boolean> features) {
|
public String showWebPage(final String url, HashMap<String, Boolean> features) {
|
||||||
// Determine if we should hide the location bar.
|
// Determine if we should hide the location bar.
|
||||||
showLocationBar = true;
|
showLocationBar = true;
|
||||||
|
openWindowHidden = false;
|
||||||
if (features != null) {
|
if (features != null) {
|
||||||
Boolean show = features.get(LOCATION);
|
Boolean show = features.get(LOCATION);
|
||||||
if (show != null) {
|
if (show != null) {
|
||||||
showLocationBar = show.booleanValue();
|
showLocationBar = show.booleanValue();
|
||||||
}
|
}
|
||||||
|
Boolean hidden = features.get(HIDDEN);
|
||||||
|
if(hidden != null) {
|
||||||
|
openWindowHidden = hidden.booleanValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CordovaWebView thatWebView = this.webView;
|
final CordovaWebView thatWebView = this.webView;
|
||||||
@ -549,6 +566,11 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
dialog.setContentView(main);
|
dialog.setContentView(main);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.getWindow().setAttributes(lp);
|
dialog.getWindow().setAttributes(lp);
|
||||||
|
// the goal of openhidden is to load the url and not display it
|
||||||
|
// Show() needs to be called to cause the URL to be loaded
|
||||||
|
if(openWindowHidden) {
|
||||||
|
dialog.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.cordova.getActivity().runOnUiThread(runnable);
|
this.cordova.getActivity().runOnUiThread(runnable);
|
||||||
|
Loading…
Reference in New Issue
Block a user