Skip to content

Commit e78ffe7

Browse files
PDLMobileAppsAlessandro Basso
andauthored
(android) Added option to turn on/off fullscreen mode in Android (apache#634)
* (android) Added option to turn on/off fullscreen mode in Android * (android) Reverted version changes as requested * (android) Changing default option value to enabled as per request Co-authored-by: Alessandro Basso <[email protected]>
1 parent e658c8c commit e78ffe7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ instance, or the system browser.
128128
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
129129
- __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)).
130130
- __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`).
131+
- __fullscreen__: Sets whether the InappBrowser WebView is displayed fullscreen or not. In fullscreen mode, the status bar is hidden. Default value is `yes`.
131132

132133
iOS supports these additional options:
133134

src/android/InAppBrowser.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public class InAppBrowser extends CordovaPlugin {
117117
private static final String FOOTER = "footer";
118118
private static final String FOOTER_COLOR = "footercolor";
119119
private static final String BEFORELOAD = "beforeload";
120+
private static final String FULLSCREEN = "fullscreen";
120121

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

@@ -147,6 +148,7 @@ public class InAppBrowser extends CordovaPlugin {
147148
private boolean showFooter = false;
148149
private String footerColor = "";
149150
private String beforeload = "";
151+
private boolean fullscreen = true;
150152
private String[] allowedSchemes;
151153
private InAppBrowserClient currentClient;
152154

@@ -714,6 +716,10 @@ public String showWebPage(final String url, HashMap<String, String> features) {
714716
if (features.get(BEFORELOAD) != null) {
715717
beforeload = features.get(BEFORELOAD);
716718
}
719+
String fullscreenSet = features.get(FULLSCREEN);
720+
if (fullscreenSet != null) {
721+
fullscreen = fullscreenSet.equals("yes") ? true : false;
722+
}
717723
}
718724

719725
final CordovaWebView thatWebView = this.webView;
@@ -794,7 +800,9 @@ public void run() {
794800
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
795801
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
796802
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
797-
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
803+
if (fullscreen) {
804+
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
805+
}
798806
dialog.setCancelable(true);
799807
dialog.setInAppBroswer(getInAppBrowser());
800808

0 commit comments

Comments
 (0)