add initialScale in android

This commit is contained in:
crazecoder 2019-11-08 14:39:15 +08:00
parent e18e6910bb
commit c15ee0216b
3 changed files with 11 additions and 1 deletions

View File

@ -216,6 +216,9 @@ final public class InAppWebView extends InputAwareWebView {
settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically); settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically);
settings.setMinimumFontSize(options.minimumFontSize); settings.setMinimumFontSize(options.minimumFontSize);
settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize); settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize);
if(options.initialScale != null)
setInitialScale(options.initialScale);
settings.setNeedInitialFocus(options.needInitialFocus); settings.setNeedInitialFocus(options.needInitialFocus);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
settings.setOffscreenPreRaster(options.offscreenPreRaster); settings.setOffscreenPreRaster(options.offscreenPreRaster);
@ -529,6 +532,9 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("minimumLogicalFontSize") != null && !options.minimumLogicalFontSize.equals(newOptions.minimumLogicalFontSize)) if (newOptionsMap.get("minimumLogicalFontSize") != null && !options.minimumLogicalFontSize.equals(newOptions.minimumLogicalFontSize))
settings.setMinimumLogicalFontSize(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) if (newOptionsMap.get("needInitialFocus") != null && options.needInitialFocus != newOptions.needInitialFocus)
settings.setNeedInitialFocus(newOptions.needInitialFocus); settings.setNeedInitialFocus(newOptions.needInitialFocus);

View File

@ -62,6 +62,7 @@ public class InAppWebViewOptions extends Options {
public boolean loadWithOverviewMode = true; public boolean loadWithOverviewMode = true;
public boolean loadsImagesAutomatically = true; public boolean loadsImagesAutomatically = true;
public Integer minimumLogicalFontSize = 8; public Integer minimumLogicalFontSize = 8;
public Integer initialScale;
public boolean needInitialFocus = true; public boolean needInitialFocus = true;
public boolean offscreenPreRaster = false; public boolean offscreenPreRaster = false;
public String sansSerifFontFamily = "sans-serif"; public String sansSerifFontFamily = "sans-serif";

View File

@ -156,6 +156,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
bool loadWithOverviewMode; bool loadWithOverviewMode;
bool loadsImagesAutomatically; bool loadsImagesAutomatically;
int minimumLogicalFontSize; int minimumLogicalFontSize;
int initialScale;
bool needInitialFocus; bool needInitialFocus;
bool offscreenPreRaster; bool offscreenPreRaster;
String sansSerifFontFamily; 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.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.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.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" this.standardFontFamily = "sans-serif"
}); });
@ -208,6 +209,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
"loadWithOverviewMode": loadWithOverviewMode, "loadWithOverviewMode": loadWithOverviewMode,
"loadsImagesAutomatically": loadsImagesAutomatically, "loadsImagesAutomatically": loadsImagesAutomatically,
"minimumLogicalFontSize": minimumLogicalFontSize, "minimumLogicalFontSize": minimumLogicalFontSize,
"initialScale": initialScale,
"needInitialFocus": needInitialFocus, "needInitialFocus": needInitialFocus,
"offscreenPreRaster": offscreenPreRaster, "offscreenPreRaster": offscreenPreRaster,
"sansSerifFontFamily": sansSerifFontFamily, "sansSerifFontFamily": sansSerifFontFamily,
@ -251,6 +253,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
options.loadWithOverviewMode = map["loadWithOverviewMode"]; options.loadWithOverviewMode = map["loadWithOverviewMode"];
options.loadsImagesAutomatically = map["loadsImagesAutomatically"]; options.loadsImagesAutomatically = map["loadsImagesAutomatically"];
options.minimumLogicalFontSize = map["minimumLogicalFontSize"]; options.minimumLogicalFontSize = map["minimumLogicalFontSize"];
options.initialScale = map["initialScale"];
options.needInitialFocus = map["needInitialFocus"]; options.needInitialFocus = map["needInitialFocus"];
options.offscreenPreRaster = map["offscreenPreRaster"]; options.offscreenPreRaster = map["offscreenPreRaster"];
options.sansSerifFontFamily = map["sansSerifFontFamily"]; options.sansSerifFontFamily = map["sansSerifFontFamily"];