infil00p closed pull request #250: Browser Close Controll URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/250
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 48f68461..88cb6c66 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -87,6 +87,7 @@ Licensed to the Apache Software Foundation (ASF) under one private static final String CLEAR_ALL_CACHE = "clearcache"; private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; private static final String HARDWARE_BACK_BUTTON = "hardwareback"; + private static final String CAN_CLOSE ="canclose"; private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction"; private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private static final Boolean DEFAULT_HARDWARE_BACK = true; @@ -105,6 +106,7 @@ Licensed to the Apache Software Foundation (ASF) under one private boolean mediaPlaybackRequiresUserGesture = false; private boolean shouldPauseInAppBrowser = false; private boolean useWideViewPort = true; + private boolean canCloseBrowser = true; private ValueCallback<Uri> mUploadCallback; private ValueCallback<Uri[]> mUploadCallbackLollipop; private final static int FILECHOOSER_REQUESTCODE = 1; @@ -476,6 +478,9 @@ public boolean canGoBack() { public boolean hardwareBack() { return hadwareBackButton; } + public boolean canCloseBrowser() { + return canCloseBrowser; + } /** * Checks to see if it is possible to go forward one page in history, then does so. @@ -570,6 +575,10 @@ public String showWebPage(final String url, HashMap<String, Boolean> features) { if (wideViewPort != null ) { useWideViewPort = wideViewPort.booleanValue(); } + Boolean canClose = features.get(CAN_CLOSE); + if(canClose != null){ + canCloseBrowser = canClose; + } } final CordovaWebView thatWebView = this.webView; diff --git a/src/android/InAppBrowserDialog.java b/src/android/InAppBrowserDialog.java index e7b212f2..fb873f77 100644 --- a/src/android/InAppBrowserDialog.java +++ b/src/android/InAppBrowserDialog.java @@ -50,7 +50,8 @@ public void onBackPressed () { if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) { this.inAppBrowser.goBack(); } else { - this.inAppBrowser.closeDialog(); + if(this.inAppBrowser.canCloseBrowser()) + this.inAppBrowser.closeDialog(); } } } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org