From 8d054286cfe65d23b9b7c2e26de21ad6b52c133b Mon Sep 17 00:00:00 2001 From: liuxy <938651469@qq.com> Date: Tue, 2 Feb 2021 11:21:10 +0800 Subject: [PATCH 1/2] feat: apply system font scale --- .../cordova/x5engine/X5WebViewEngine.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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 { From 014cdce73976150faa52c608a310c2fd999f8b6a Mon Sep 17 00:00:00 2001 From: liuxy <938651469@qq.com> Date: Tue, 2 Feb 2021 11:28:54 +0800 Subject: [PATCH 2/2] chore: update package version --- package.json | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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