From 944caa9d4fb88d56fa60c68132e5c2d66eb1113e Mon Sep 17 00:00:00 2001 From: YouCii Date: Fri, 19 Apr 2019 15:36:12 +0800 Subject: [PATCH 1/2] 1. Enable setTextZoom function of Android-WebViewSetting --- .../InAppWebView/InAppWebView.java | 10 ++++------ .../InAppWebView/InAppWebViewOptions.java | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java index 6fd2c575..d9dfd640 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java @@ -181,12 +181,7 @@ public class InAppWebView extends WebView { settings.setUseWideViewPort(options.useWideViewPort); settings.setSupportZoom(options.supportZoom); - // fix webview scaling - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); - else - settings.setTextZoom(100); - + settings.setTextZoom(options.textZoom); } public void loadUrl(String url, MethodChannel.Result result) { @@ -337,6 +332,9 @@ public class InAppWebView extends WebView { if (newOptionsMap.get("supportZoom") != null && options.supportZoom != newOptions.supportZoom) settings.setSupportZoom(newOptions.supportZoom); + if (newOptionsMap.get("textZoom") != null && options.textZoom != newOptions.textZoom) + settings.setTextZoom(newOptions.textZoom); + options = newOptions; } diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java index 06ea38b0..08b2f03d 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java @@ -21,4 +21,6 @@ public class InAppWebViewOptions extends Options { public boolean domStorageEnabled = false; public boolean useWideViewPort = true; public boolean safeBrowsingEnabled = true; + + public int textZoom = 100; } From 2040abf5cdb09c9f5f0af3bc98df6c642f07f570 Mon Sep 17 00:00:00 2001 From: YouCii <550341130@qq.com> Date: Fri, 19 Apr 2019 15:42:47 +0800 Subject: [PATCH 2/2] Update README.md Enable setTextZoom function of Android-WebViewSetting --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16e9a5c3..0216b02c 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,8 @@ All platforms support: - __databaseEnabled__: Set to `true` if you want the database storage API is enabled. The default value is `false`. - __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`. - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true 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. The default value is `true`. - - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`. + - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`. + - __textZoom__: Set text scaling of android-webview. The default value is `100`. **iOS** supports these additional options: @@ -1330,4 +1331,4 @@ CookieManager.deleteCookies(String url, {String domain = "", String path = "/"}) Removes all cookies. ```dart CookieManager.deleteAllCookies(); -``` \ No newline at end of file +```