From 147f562d0aa500c487b20197d2fa2d13a05239d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Sun, 24 Jul 2016 09:53:51 +0200 Subject: [PATCH] Remove android auto print margin (Closes #81) --- src/android/Printer.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/android/Printer.java b/src/android/Printer.java index 8a5aaa4..65c8fc4 100644 --- a/src/android/Printer.java +++ b/src/android/Printer.java @@ -28,6 +28,8 @@ import android.print.PrintAttributes; import android.print.PrintDocumentAdapter; import android.print.PrintJob; import android.print.PrintManager; +import android.view.View; +import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -156,10 +158,22 @@ public class Printer extends CordovaPlugin { * The JSON object with the containing page properties */ private void initWebView (JSONObject props) { - Activity ctx = cordova.getActivity(); - view = new WebView(ctx); + Activity ctx = cordova.getActivity(); + view = new WebView(ctx); + WebSettings settings = view.getSettings(); - view.getSettings().setDatabaseEnabled(true); + settings.setDatabaseEnabled(true); + settings.setGeolocationEnabled(true); + settings.setSaveFormData(true); + settings.setUseWideViewPort(true); + view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); + + if (Build.VERSION.SDK_INT >= 21) { + Method setMixedContentModeMethod = getMethod(settings.getClass(), + "setMixedContentMode", int.class); + + invokeMethod(settings, setMixedContentModeMethod, 2); + } setWebViewClient(props); }