Skip to content

Commit

Permalink
feat: enable zoom without on-screen controls ref - apache#1023
Browse files Browse the repository at this point in the history
  • Loading branch information
Arik committed Jan 12, 2025
1 parent 64b2952 commit 02b89ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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__: set to `yes` to enable Android browser's zoom controls, set to `no` to disable them. Default value is `yes`.
- __zoomcontrols__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `no`.
- __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`).
Expand Down
16 changes: 12 additions & 4 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -129,7 +130,8 @@ public class InAppBrowser extends CordovaPlugin {
private EditText edittext;
private CallbackContext callbackContext;
private boolean showLocationBar = true;
private boolean showZoomControls = true;
private boolean enableZoom = true;
private boolean showZoomControls = false;
private boolean openWindowHidden = false;
private boolean clearAllCache = false;
private boolean clearSessionCache = false;
Expand Down Expand Up @@ -632,7 +634,8 @@ private InAppBrowser getInAppBrowser() {
public String showWebPage(final String url, HashMap<String, String> features) {
// Determine if we should hide the location bar.
showLocationBar = true;
showZoomControls = true;
enableZoom = true;
showZoomControls = false;
openWindowHidden = false;
mediaPlaybackRequiresUserGesture = false;

Expand All @@ -649,7 +652,11 @@ public String showWebPage(final String url, HashMap<String, String> features) {
}
String zoom = features.get(ZOOM);
if (zoom != null) {
showZoomControls = zoom.equals("yes") ? true : false;
enableZoom = zoom.equals("yes") ? true : false;
}
String zoomcontrols = features.get(ZOOMCONTROLS);
if (zoomcontrols != null) {
showZoomControls = zoomcontrols.equals("yes") ? true : false;
}
String hidden = features.get(HIDDEN);
if (hidden != null) {
Expand Down Expand Up @@ -959,7 +966,8 @@ public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePath
WebSettings settings = inAppWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setBuiltInZoomControls(showZoomControls);
settings.setBuiltInZoomControls(enableZoom);
settings.setDisplayZoomControls(showZoomControls);
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

// download event
Expand Down

0 comments on commit 02b89ca

Please sign in to comment.