From 18dd2356e03a1a4df2bcd6be90eeb566918f7c7e Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 21 May 2020 14:00:05 +0300 Subject: [PATCH 1/4] Fix tablet poi icon size --- OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index f1f2e1153a..32f867b2ce 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -176,8 +176,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon @Override public void initLayer(OsmandMapTileView view) { this.view = view; - - poiSize = dpToPx(view.getContext(), 16f); + poiSize = (int) app.getResources().getDimension(R.dimen.poi_icon_size); poiColorFilter = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); paintIconBackground = new Paint(); poiBackground = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_orange_poi_shield); From aa9b656d45c8929a6f859fea34c20149c8407117 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 21 May 2020 14:04:14 +0300 Subject: [PATCH 2/4] Fix scale pressed area size --- OsmAnd/res/values-large/sizes.xml | 13 +++++++------ OsmAnd/res/values/sizes.xml | 1 + .../net/osmand/plus/audionotes/AudioNotesLayer.java | 3 ++- .../src/net/osmand/plus/views/ContextMenuLayer.java | 11 ++++++++--- OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 3 ++- .../net/osmand/plus/views/TransportStopsLayer.java | 3 ++- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index a2af789a5e..00e5606654 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -1,6 +1,6 @@ - 120dp + 120dp 35sp 33sp 23sp @@ -29,7 +29,7 @@ 140dp 81dp - + 36dp 48dp 120dp @@ -120,13 +120,14 @@ 20dp 23dp - 180dp - 24dp - 60dp + 180dp + 24dp + 60dp 450dp 54dp - 64dp + 64dp + 24dp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index e3181e5c0b..6383e285c7 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -90,6 +90,7 @@ 16dp 34dp 24dp + 16dp 3dp 14dp 6dp diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 49a03a8cf2..828b08d20d 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -203,7 +203,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements public void getRecordingsFromPoint(PointF point, RotatedTileBox tileBox, List am) { int ex = (int) point.x; int ey = (int) point.y; - int compare = getRadiusPoi(tileBox); + float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); + int compare = getRadiusPoi(tileBox) * (int) textScale; int radius = compare * 3 / 2; for (Recording n : plugin.getAllRecordings()) { int x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 366da4afd5..18ccf6117b 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -21,7 +21,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresPermission; import androidx.appcompat.content.res.AppCompatResources; -import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; @@ -223,15 +222,21 @@ public class ContextMenuLayer extends OsmandMapLayer { } } } + float scale = 1f; + if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) { + scale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); + } for (LatLon latLon : pressedLatLonSmall) { int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); - canvas.drawBitmap(pressedBitmapSmall, x - pressedBitmapSmall.getWidth() / 2, y - pressedBitmapSmall.getHeight() / 2, paint); + Rect destRect = getIconDestinationRect(x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), scale); + canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint); } for (LatLon latLon : pressedLatLonFull) { int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); - canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint); + Rect destRect = getIconDestinationRect(x, y, pressedBitmap.getWidth(), pressedBitmap.getHeight(), scale); + canvas.drawBitmap(pressedBitmap, null, destRect, paint); } if (mapQuickActionLayer != null && mapQuickActionLayer.isInMovingMarkerMode()) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 32f867b2ce..d946d8d55b 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -154,7 +154,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon int ex = (int) point.x; int ey = (int) point.y; final int rp = getRadiusPoi(tb); - int compare = rp; + float textScale = app.getSettings().TEXT_SCALE.get(); + int compare = rp * (int) textScale; int radius = rp * 3 / 2; try { for (int i = 0; i < objects.size(); i++) { diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 9067054f85..12a8ae8139 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -144,7 +144,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa List objects) { int ex = (int) point.x; int ey = (int) point.y; - final int rp = getRadiusPoi(tb); + float textScale = mapActivity.getMyApplication().getSettings().TEXT_SCALE.get(); + final int rp = getRadiusPoi(tb) * (int) textScale; int radius = rp * 3 / 2; try { TreeSet ms = new TreeSet<>(); From aa05635f6ee25ca10bad46f70704fdd737ca8a55 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 21 May 2020 15:53:59 +0300 Subject: [PATCH 3/4] Fix scale pressed area size --- .../src/net/osmand/plus/audionotes/AudioNotesLayer.java | 3 +-- OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/GPXLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java | 8 ++++++++ OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 6 ++---- OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java | 3 +-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 828b08d20d..627450665e 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -203,8 +203,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements public void getRecordingsFromPoint(PointF point, RotatedTileBox tileBox, List am) { int ex = (int) point.x; int ey = (int) point.y; - float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); - int compare = getRadiusPoi(tileBox) * (int) textScale; + int compare = getScaledTouchRadius(activity.getMyApplication(), getRadiusPoi(tileBox)); int radius = compare * 3 / 2; for (Recording n : plugin.getAllRecordings()) { int x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java index a29b8bff72..1a59ddebf0 100644 --- a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java @@ -216,7 +216,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer. } private void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List res) { - int r = getDefaultRadiusPoi(tb); + int r = getScaledTouchRadius(view.getApplication(), getDefaultRadiusPoi(tb)); int ex = (int) point.x; int ey = (int) point.y; for (FavouritePoint n : favorites.getFavouritePoints()) { diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index bc169bde73..6e1f63c3c0 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -580,7 +580,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } public void getWptFromPoint(RotatedTileBox tb, PointF point, List res) { - int r = getDefaultRadiusPoi(tb); + int r = getScaledTouchRadius(view.getApplication(), getDefaultRadiusPoi(tb)); int ex = (int) point.x; int ey = (int) point.y; List selectedGpxFiles = new ArrayList<>(selectedGpxHelper.getSelectedGPXFiles()); diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java index 2afe6868d2..0e154d098f 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java @@ -637,6 +637,14 @@ public abstract class OsmandMapLayer { return rect; } + public int getScaledTouchRadius(OsmandApplication app, int radiusPoi) { + float textScale = app.getSettings().TEXT_SCALE.get(); + if (textScale < 1.0f) { + textScale = 1.0f; + } + return (int) textScale * radiusPoi; + } + public abstract class MapLayerData { public int ZOOM_THRESHOLD = 1; public RotatedTileBox queriedBox; diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index d946d8d55b..8e35108ada 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -153,10 +153,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon if (objects != null) { int ex = (int) point.x; int ey = (int) point.y; - final int rp = getRadiusPoi(tb); - float textScale = app.getSettings().TEXT_SCALE.get(); - int compare = rp * (int) textScale; - int radius = rp * 3 / 2; + int compare = getScaledTouchRadius(view.getApplication(), getRadiusPoi(tb)); + int radius = compare * 3 / 2; try { for (int i = 0; i < objects.size(); i++) { Amenity n = objects.get(i); diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 12a8ae8139..db1eae9605 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -144,8 +144,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa List objects) { int ex = (int) point.x; int ey = (int) point.y; - float textScale = mapActivity.getMyApplication().getSettings().TEXT_SCALE.get(); - final int rp = getRadiusPoi(tb) * (int) textScale; + final int rp = getScaledTouchRadius(mapActivity.getMyApplication(), getRadiusPoi(tb)); int radius = rp * 3 / 2; try { TreeSet ms = new TreeSet<>(); From 59d5d307e0a48d11f371560baf34d94f4dd21bab Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 21 May 2020 16:39:16 +0300 Subject: [PATCH 4/4] Fix dimension pixel size --- OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 8e35108ada..411eaf3d6c 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -175,7 +175,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon @Override public void initLayer(OsmandMapTileView view) { this.view = view; - poiSize = (int) app.getResources().getDimension(R.dimen.poi_icon_size); + poiSize = app.getResources().getDimensionPixelSize(R.dimen.poi_icon_size); poiColorFilter = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); paintIconBackground = new Paint(); poiBackground = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_orange_poi_shield);