From c15ee0216b03bcd1c2fbf82da825252b49966d5a Mon Sep 17 00:00:00 2001 From: crazecoder <21527312@qq.com> Date: Fri, 8 Nov 2019 14:39:15 +0800 Subject: [PATCH] add initialScale in android --- .../flutter_inappbrowser/InAppWebView/InAppWebView.java | 6 ++++++ .../InAppWebView/InAppWebViewOptions.java | 1 + lib/src/webview_options.dart | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) 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 4b68fe1c9..8a471d838 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 @@ -216,6 +216,9 @@ else if (options.clearSessionCache) settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically); settings.setMinimumFontSize(options.minimumFontSize); settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize); + if(options.initialScale != null) + setInitialScale(options.initialScale); + settings.setNeedInitialFocus(options.needInitialFocus); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) settings.setOffscreenPreRaster(options.offscreenPreRaster); @@ -529,6 +532,9 @@ else if (newOptionsMap.get("clearSessionCache") != null && newOptions.clearSessi if (newOptionsMap.get("minimumLogicalFontSize") != null && !options.minimumLogicalFontSize.equals(newOptions.minimumLogicalFontSize)) settings.setMinimumLogicalFontSize(newOptions.minimumLogicalFontSize); + if (newOptionsMap.get("initialScale") != null && !options.initialScale.equals(newOptions.initialScale)) + setInitialScale(newOptions.initialScale); + if (newOptionsMap.get("needInitialFocus") != null && options.needInitialFocus != newOptions.needInitialFocus) settings.setNeedInitialFocus(newOptions.needInitialFocus); 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 ae2e20423..6b8254f3d 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 @@ -62,6 +62,7 @@ public class InAppWebViewOptions extends Options { public boolean loadWithOverviewMode = true; public boolean loadsImagesAutomatically = true; public Integer minimumLogicalFontSize = 8; + public Integer initialScale; public boolean needInitialFocus = true; public boolean offscreenPreRaster = false; public String sansSerifFontFamily = "sans-serif"; diff --git a/lib/src/webview_options.dart b/lib/src/webview_options.dart index 30c7f51a8..102b17c8f 100644 --- a/lib/src/webview_options.dart +++ b/lib/src/webview_options.dart @@ -156,6 +156,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr bool loadWithOverviewMode; bool loadsImagesAutomatically; int minimumLogicalFontSize; + int initialScale; bool needInitialFocus; bool offscreenPreRaster; String sansSerifFontFamily; @@ -169,7 +170,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr this.cursiveFontFamily = "cursive", this.defaultFixedFontSize = 16, this.defaultFontSize = 16, this.defaultTextEncodingName = "UTF-8", this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", this.forceDark = AndroidInAppWebViewForceDark.FORCE_DARK_OFF, this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, this.loadsImagesAutomatically = true, - this.minimumLogicalFontSize = 8, this.needInitialFocus = true, this.offscreenPreRaster = false, this.sansSerifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif", + this.minimumLogicalFontSize = 8, this.initialScale, this.needInitialFocus = true, this.offscreenPreRaster = false, this.sansSerifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif", this.standardFontFamily = "sans-serif" }); @@ -208,6 +209,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr "loadWithOverviewMode": loadWithOverviewMode, "loadsImagesAutomatically": loadsImagesAutomatically, "minimumLogicalFontSize": minimumLogicalFontSize, + "initialScale": initialScale, "needInitialFocus": needInitialFocus, "offscreenPreRaster": offscreenPreRaster, "sansSerifFontFamily": sansSerifFontFamily, @@ -251,6 +253,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr options.loadWithOverviewMode = map["loadWithOverviewMode"]; options.loadsImagesAutomatically = map["loadsImagesAutomatically"]; options.minimumLogicalFontSize = map["minimumLogicalFontSize"]; + options.initialScale = map["initialScale"]; options.needInitialFocus = map["needInitialFocus"]; options.offscreenPreRaster = map["offscreenPreRaster"]; options.sansSerifFontFamily = map["sansSerifFontFamily"];