correct font size in Help web view

This commit is contained in:
sonora 2017-01-07 10:30:32 +01:00
parent fa0f627b14
commit fe28eee816

View file

@ -1,14 +1,17 @@
package net.osmand.plus.dialogs; package net.osmand.plus.dialogs;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -75,6 +78,24 @@ public class HelpArticleDialogFragment extends DialogFragment {
webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setSupportZoom(true); webView.getSettings().setSupportZoom(true);
//Scale web view font size with system font size
float scale = getActivity().getResources().getConfiguration().fontScale;
if (android.os.Build.VERSION.SDK_INT >= 14) {
webView.getSettings().setTextZoom((int) (scale * 100f));
} else {
if (scale <= 0.7f) {
webView.getSettings().setTextSize(WebSettings.TextSize.SMALLEST);
} else if (scale <= 0.85f) {
webView.getSettings().setTextSize(WebSettings.TextSize.SMALLER);
} else if (scale <= 1.0f) {
webView.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
} else if (scale <= 1.15f) {
webView.getSettings().setTextSize(WebSettings.TextSize.LARGER);
} else {
webView.getSettings().setTextSize(WebSettings.TextSize.LARGEST);
}
}
if (assetName != null) { if (assetName != null) {
String fileContents = getAssetAsString(assetName, getActivity()); String fileContents = getAssetAsString(assetName, getActivity());