correct font size in Help web view
This commit is contained in:
parent
fa0f627b14
commit
fe28eee816
1 changed files with 21 additions and 0 deletions
|
@ -1,14 +1,17 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -75,6 +78,24 @@ public class HelpArticleDialogFragment extends DialogFragment {
|
|||
webView.getSettings().setDisplayZoomControls(false);
|
||||
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) {
|
||||
String fileContents = getAssetAsString(assetName, getActivity());
|
||||
|
||||
|
|
Loading…
Reference in a new issue