From 1d963e9f17befe53592fd4546ec53450fd428517 Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 6 Jan 2017 15:41:45 +0100 Subject: [PATCH] respect system settings --- OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 12 +++++++----- .../sample1/mapcontextmenu/ContextMenuHelper.java | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index a002a7178b..0fe5ed629b 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -4,6 +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.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -372,16 +373,17 @@ 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 * android.content.res.Configuration.fontScale; if (android.os.Build.VERSION.SDK_INT >= 14) { - settings.setTextZoom((int) (ctx.getResources().getDisplayMetrics().density * 100f)); + settings.setTextZoom((int) (systemFontScaling * 100f)); } else { - if (ctx.getResources().getDisplayMetrics().density <= 0.5f) { + if (systemFontScaling <= 0.5f) { settings.setTextSize(WebSettings.TextSize.SMALLEST); - } else if (ctx.getResources().getDisplayMetrics().density <= 0.75f) { + } else if (systemFontScaling <= 0.75f) { settings.setTextSize(WebSettings.TextSize.SMALLER); - } else if (ctx.getResources().getDisplayMetrics().density <= 1.0f) { + } else if (systemFontScaling <= 1.0f) { settings.setTextSize(WebSettings.TextSize.NORMAL); - } else if (ctx.getResources().getDisplayMetrics().density <= 1.5f) { + } else if (systemFontScaling <= 1.5f) { settings.setTextSize(WebSettings.TextSize.LARGER); } else { settings.setTextSize(WebSettings.TextSize.LARGEST); diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java index 30b4b23d98..5c42b6886d 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java @@ -3,6 +3,7 @@ package net.osmand.core.samples.android.sample1.mapcontextmenu; import android.app.Dialog; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.net.Uri; import android.support.v4.content.ContextCompat; @@ -108,16 +109,17 @@ public class ContextMenuHelper { settings.setDisplayZoomControls(false); //Scale web view font size with system font size + float systemFontScaling = ctx.getResources().getDisplayMetrics().density * android.content.res.Configuration.fontScale; if (android.os.Build.VERSION.SDK_INT >= 14) { - settings.setTextZoom((int) (ctx.getResources().getDisplayMetrics().density * 100f)); + settings.setTextZoom((int) (systemFontScaling * 100f)); } else { - if (ctx.getResources().getDisplayMetrics().density <= 0.5f) { + if (systemFontScaling <= 0.5f) { settings.setTextSize(WebSettings.TextSize.SMALLEST); - } else if (ctx.getResources().getDisplayMetrics().density <= 0.75f) { + } else if (systemFontScaling <= 0.75f) { settings.setTextSize(WebSettings.TextSize.SMALLER); - } else if (ctx.getResources().getDisplayMetrics().density <= 1.0f) { + } else if (systemFontScaling <= 1.0f) { settings.setTextSize(WebSettings.TextSize.NORMAL); - } else if (ctx.getResources().getDisplayMetrics().density <= 1.5f) { + } else if (systemFontScaling <= 1.5f) { settings.setTextSize(WebSettings.TextSize.LARGER); } else { settings.setTextSize(WebSettings.TextSize.LARGEST);