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

GH-1022 android: enable zoom without on-screen controls #1023

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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 @@ -94,6 +94,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 @@ -128,7 +129,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 @@ -631,7 +633,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 @@ -648,7 +651,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 @@ -946,7 +953,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