Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ instance, or the system browser.
- __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)).
- __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to `yes`).
- __fullscreen__: Sets whether the InappBrowser WebView is displayed fullscreen or not. In fullscreen mode, the status bar is hidden. Default value is `yes`.
- __launchInNewTask__: When using target `_system`, sets to `yes` to launch system's browser in a new task. Default value is `no`.

iOS supports these additional options:

Expand Down
17 changes: 15 additions & 2 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public class InAppBrowser extends CordovaPlugin {
private static final String FOOTER_COLOR = "footercolor";
private static final String BEFORELOAD = "beforeload";
private static final String FULLSCREEN = "fullscreen";
private static final String LAUNCH_NEW_TASK = "launchInNewTask";

private static final int TOOLBAR_HEIGHT = 48;

Expand Down Expand Up @@ -149,6 +150,7 @@ public class InAppBrowser extends CordovaPlugin {
private String footerColor = "";
private String beforeload = "";
private boolean fullscreen = true;
private boolean launchInNewTask = false;
private String[] allowedSchemes;
private InAppBrowserClient currentClient;

Expand Down Expand Up @@ -241,7 +243,7 @@ else if (url.startsWith(WebView.SCHEME_TEL))
// SYSTEM
else if (SYSTEM.equals(target)) {
LOG.d(LOG_TAG, "in system");
result = openExternal(url);
result = openExternal(url, features);
}
// BLANK - or anything else
else {
Expand Down Expand Up @@ -455,7 +457,7 @@ private HashMap<String, String> parseFeature(String optString) {
* @param url the url to load.
* @return "" if ok, or error message.
*/
public String openExternal(String url) {
public String openExternal(String url, HashMap<String, String> features) {
try {
Intent intent = null;
intent = new Intent(Intent.ACTION_VIEW);
Expand All @@ -468,6 +470,17 @@ public String openExternal(String url) {
intent.setData(uri);
}
intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());

if (features != null) {
String launchNewTask = features.get(LAUNCH_NEW_TASK);
if (launchNewTask != null) {
launchInNewTask = launchNewTask.equals("yes") ? true : false;
}
}

if (launchInNewTask) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
// CB-10795: Avoid circular loops by preventing it from opening in the current app
this.openExternalExcludeCurrentApp(intent);
return "";
Expand Down