Skip to content

Commit 02b89ca

Browse files
author
Arik
committed
feat: enable zoom without on-screen controls ref - apache#1023
1 parent 64b2952 commit 02b89ca

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ instance, or the system browser.
119119
- __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`.
120120
- __toolbarcolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color the toolbar from default. Only has effect if user has location set to `yes`.
121121
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the right and close button to the left. Default value is `no`.
122-
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
122+
- __zoom__: set to `yes` to enable Android browser's zoom controls, set to `no` to disable them. Default value is `yes`.
123+
- __zoomcontrols__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `no`.
123124
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
124125
- __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)).
125126
- __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`).

src/android/InAppBrowser.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public class InAppBrowser extends CordovaPlugin {
9595
private static final String EXIT_EVENT = "exit";
9696
private static final String LOCATION = "location";
9797
private static final String ZOOM = "zoom";
98+
private static final String ZOOMCONTROLS = "zoomcontrols";
9899
private static final String HIDDEN = "hidden";
99100
private static final String LOAD_START_EVENT = "loadstart";
100101
private static final String LOAD_STOP_EVENT = "loadstop";
@@ -129,7 +130,8 @@ public class InAppBrowser extends CordovaPlugin {
129130
private EditText edittext;
130131
private CallbackContext callbackContext;
131132
private boolean showLocationBar = true;
132-
private boolean showZoomControls = true;
133+
private boolean enableZoom = true;
134+
private boolean showZoomControls = false;
133135
private boolean openWindowHidden = false;
134136
private boolean clearAllCache = false;
135137
private boolean clearSessionCache = false;
@@ -632,7 +634,8 @@ private InAppBrowser getInAppBrowser() {
632634
public String showWebPage(final String url, HashMap<String, String> features) {
633635
// Determine if we should hide the location bar.
634636
showLocationBar = true;
635-
showZoomControls = true;
637+
enableZoom = true;
638+
showZoomControls = false;
636639
openWindowHidden = false;
637640
mediaPlaybackRequiresUserGesture = false;
638641

@@ -649,7 +652,11 @@ public String showWebPage(final String url, HashMap<String, String> features) {
649652
}
650653
String zoom = features.get(ZOOM);
651654
if (zoom != null) {
652-
showZoomControls = zoom.equals("yes") ? true : false;
655+
enableZoom = zoom.equals("yes") ? true : false;
656+
}
657+
String zoomcontrols = features.get(ZOOMCONTROLS);
658+
if (zoomcontrols != null) {
659+
showZoomControls = zoomcontrols.equals("yes") ? true : false;
653660
}
654661
String hidden = features.get(HIDDEN);
655662
if (hidden != null) {
@@ -959,7 +966,8 @@ public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePath
959966
WebSettings settings = inAppWebView.getSettings();
960967
settings.setJavaScriptEnabled(true);
961968
settings.setJavaScriptCanOpenWindowsAutomatically(true);
962-
settings.setBuiltInZoomControls(showZoomControls);
969+
settings.setBuiltInZoomControls(enableZoom);
970+
settings.setDisplayZoomControls(showZoomControls);
963971
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
964972

965973
// download event

0 commit comments

Comments
 (0)