diff --git a/package.json b/package.json index 213bf97..59a366e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-webview-x5", - "version": "0.3.1", + "version": "0.3.2-alpha.1", "description": "Changes the default WebView to x5", "cordova": { "id": "cordova-plugin-webview-x5", diff --git a/platforms/android/src/org/apache/cordova/x5engine/X5WebViewEngine.java b/platforms/android/src/org/apache/cordova/x5engine/X5WebViewEngine.java index 514649c..da5c69f 100644 --- a/platforms/android/src/org/apache/cordova/x5engine/X5WebViewEngine.java +++ b/platforms/android/src/org/apache/cordova/x5engine/X5WebViewEngine.java @@ -217,6 +217,12 @@ private void initWebViewSettings() { //如果webview内容宽度大于显示区域的宽度,那么将内容缩小,以适应显示区域的宽度, 默认是false settings.setLoadWithOverviewMode(true); + // 系统字体大小变更 + boolean applySystemFontScale = preferences.getBoolean("applySystemFontScale", false); + if (applySystemFontScale) { + settings.setTextZoom((int)(this.getSystemFontScale() * 100)); + } + // Fix for CB-1405 // Google issue 4641 String defaultUserAgent = settings.getUserAgentString(); @@ -247,6 +253,22 @@ public void onReceive(Context context, Intent intent) { // end CB-1405 } + private float getSystemFontScale() { + float systemFontScale = webView.getContext().getResources().getConfiguration().fontScale; + LOG.d(TAG, "current system font scale is " + systemFontScale); + boolean limitSystemFontScale = preferences.getBoolean("limitSystemFontScale", false); + if (!limitSystemFontScale) { + return systemFontScale; + } + if (1.5f < systemFontScale) { + systemFontScale = 1.5f; + } + if (0.8f > systemFontScale) { + systemFontScale = 0.8f; + } + return systemFontScale; + } + @TargetApi(Build.VERSION_CODES.KITKAT) private void enableRemoteDebugging() { try { diff --git a/plugin.xml b/plugin.xml index e55c9d0..677809b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="0.3.2"> TBS WebView use x5 for cordova to get a better webview browsing experience