Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(android) Added option to turn on/off fullscreen mode in Android #634

Merged
merged 3 commits into from
Mar 24, 2020
Merged
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 @@ -128,6 +128,7 @@ instance, or the system browser.
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
- __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`.

iOS supports these additional options:

Expand Down
10 changes: 9 additions & 1 deletion src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public class InAppBrowser extends CordovaPlugin {
private static final String FOOTER = "footer";
private static final String FOOTER_COLOR = "footercolor";
private static final String BEFORELOAD = "beforeload";
private static final String FULLSCREEN = "fullscreen";

private static final List customizableOptions = Arrays.asList(CLOSE_BUTTON_CAPTION, TOOLBAR_COLOR, NAVIGATION_COLOR, CLOSE_BUTTON_COLOR, FOOTER_COLOR);

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

Expand Down Expand Up @@ -714,6 +716,10 @@ public String showWebPage(final String url, HashMap<String, String> features) {
if (features.get(BEFORELOAD) != null) {
beforeload = features.get(BEFORELOAD);
}
String fullscreenSet = features.get(FULLSCREEN);
if (fullscreenSet != null) {
fullscreen = fullscreenSet.equals("yes") ? true : false;
}
}

final CordovaWebView thatWebView = this.webView;
Expand Down Expand Up @@ -794,7 +800,9 @@ public void run() {
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (fullscreen) {
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
dialog.setCancelable(true);
dialog.setInAppBroswer(getInAppBrowser());

Expand Down