Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.3.2 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-webview-x5"
version="0.3.1">
version="0.3.2">

<name>TBS WebView</name>
<description>use x5 for cordova to get a better webview browsing experience</description>
Expand Down