From d9a25dabf8d8bfa8785622c6426ab10ef84559b1 Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 6 Jan 2017 19:58:03 +0100 Subject: [PATCH] use system font scaling --- .../net/osmand/plus/views/POIMapLayer.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 062e86ab8a..25d29091f0 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -4,7 +4,7 @@ import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -//import android.content.res.Configuration; +import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -373,19 +373,16 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon settings.setDisplayZoomControls(false); //Scale web view font size with system font size - float systemFontScaling = ctx.getResources().getDisplayMetrics().density; - //float systemFontScaling = ctx.getResources().getDisplayMetrics().density * android.content.res.Configuration.fontScale; - //float systemFontScaling = android.content.res.Configuration.fontScale; if (android.os.Build.VERSION.SDK_INT >= 14) { - settings.setTextZoom((int) (systemFontScaling * 100f)); + settings.setTextZoom((int) (getSystemFontScaling() * 100f)); } else { - if (systemFontScaling <= 0.5f) { + if (getSystemFontScaling() <= 0.5f) { settings.setTextSize(WebSettings.TextSize.SMALLEST); - } else if (systemFontScaling <= 0.75f) { + } else if (getSystemFontScaling() <= 0.75f) { settings.setTextSize(WebSettings.TextSize.SMALLER); - } else if (systemFontScaling <= 1.0f) { + } else if (getSystemFontScaling() <= 1.0f) { settings.setTextSize(WebSettings.TextSize.NORMAL); - } else if (systemFontScaling <= 1.5f) { + } else if (getSystemFontScaling() <= 1.5f) { settings.setTextSize(WebSettings.TextSize.LARGER); } else { settings.setTextSize(WebSettings.TextSize.LARGEST); @@ -424,6 +421,10 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon dialog.show(); } + private float getSystemFontScaling () { + return android.content.res.Configuration.fontScale; + } + private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) { final Dialog dialog = new Dialog(ctx, app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);