You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/05/07 17:25:24 UTC

(cordova-plugin-inappbrowser) branch master updated: feat(android): make zoom on-screen controls configurable (#1023)

This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


The following commit(s) were added to refs/heads/master by this push:
     new 24c6738  feat(android): make zoom on-screen controls configurable (#1023)
24c6738 is described below

commit 24c6738c68441fd62b46b62d23480917d266c714
Author: Mark Hartmann <62...@users.noreply.github.com>
AuthorDate: Thu May 7 19:25:17 2026 +0200

    feat(android): make zoom on-screen controls configurable (#1023)
    
    - This change adds a settable option `zoomcontrols` in addition to `zoom` at initialisation of the Inappbrowser instance. This enables a separation between zoom-controls (pinch-to-zoom) and additionally showing zoom-buttons to manually adjust zooming.
    - Fixes https://github.com/apache/cordova-plugin-inappbrowser/issues/1022
    ---------
    
    Co-authored-by: Mark Jenzer <ma...@itwm.fraunhofer.de>
    Co-authored-by: Mark Hartmann <ma...@wendeware.com>
---
 README.md                     |  3 ++-
 src/android/InAppBrowser.java | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index e2fe4d3..9f0bd3f 100644
--- a/README.md
+++ b/README.md
@@ -129,7 +129,8 @@ instance, or the system browser.
     - __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`.
     - __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`.
     - __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`.
-    - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them.  Default value is `yes`.
+    - __zoom__: Enables pinch-to-zoom gesture. Set to `no` to disable it. Default value is `yes`.
+    - __zoomcontrols__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. The zoom controls are deprecated since Android API Level 26 (Android 8). Google recommends to disable them.
     - __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 wil [...]
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index bb3495f..f220b9f 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -95,6 +95,7 @@ public class InAppBrowser extends CordovaPlugin {
     private static final String EXIT_EVENT = "exit";
     private static final String LOCATION = "location";
     private static final String ZOOM = "zoom";
+    private static final String ZOOMCONTROLS = "zoomcontrols";
     private static final String HIDDEN = "hidden";
     private static final String LOAD_START_EVENT = "loadstart";
     private static final String LOAD_STOP_EVENT = "loadstop";
@@ -129,6 +130,7 @@ public class InAppBrowser extends CordovaPlugin {
     private EditText edittext;
     private CallbackContext callbackContext;
     private boolean showLocationBar = true;
+    private boolean enableZoom = true;
     private boolean showZoomControls = true;
     private boolean openWindowHidden = false;
     private boolean clearAllCache = false;
@@ -632,6 +634,7 @@ public class InAppBrowser extends CordovaPlugin {
     public String showWebPage(final String url, HashMap<String, String> features) {
         // Determine if we should hide the location bar.
         showLocationBar = true;
+        enableZoom = true;
         showZoomControls = true;
         openWindowHidden = false;
         mediaPlaybackRequiresUserGesture = false;
@@ -649,7 +652,11 @@ public class InAppBrowser extends CordovaPlugin {
             }
             String zoom = features.get(ZOOM);
             if (zoom != null) {
-                showZoomControls = zoom.equals("yes") ? true : false;
+                enableZoom = zoom.equals("yes");
+            }
+            String zoomcontrols = features.get(ZOOMCONTROLS);
+            if (zoomcontrols != null) {
+                showZoomControls = zoomcontrols.equals("yes");
             }
             String hidden = features.get(HIDDEN);
             if (hidden != null) {
@@ -947,7 +954,14 @@ public class InAppBrowser extends CordovaPlugin {
                 WebSettings settings = inAppWebView.getSettings();
                 settings.setJavaScriptEnabled(true);
                 settings.setJavaScriptCanOpenWindowsAutomatically(true);
-                settings.setBuiltInZoomControls(showZoomControls);
+                // setBuiltInZoomControls enables pinch-to-zoom and also the on-screen zoom controls
+                // The zoom controls have to be disabled separately by setDisplayZoomControls
+                // This is the recommended way by Google
+                settings.setBuiltInZoomControls(enableZoom);
+                // Enable/Disable on-screen zoom controls.
+                // These are deprecated since Android API Level 26 (Android 8).
+                // Google recommends to disable them
+                settings.setDisplayZoomControls(showZoomControls);
                 settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
                 
                 // download event


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org