From 5cabbc46b56d15e2e6b1646e66ae5406e5ab2b4d Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sun, 14 Feb 2016 15:38:19 +0300 Subject: [PATCH] Map markers UI fixes --- OsmAnd/src/net/osmand/plus/MapMarkersHelper.java | 4 ++-- .../net/osmand/plus/views/MapMarkersLayer.java | 15 ++++++++++++--- .../plus/views/mapwidgets/MapMarkersWidget.java | 15 +++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 2622babaa2..5cc86a703a 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -197,12 +197,12 @@ public class MapMarkersHelper { } int colorIndex; if (mapMarkers.size() > 0) { - colorIndex = (mapMarkers.get(mapMarkers.size() - 1).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT; + colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT; } else { colorIndex = 0; } settings.insertMapMarker(point.getLatitude(), point.getLongitude(), - pointDescription, colorIndex, mapMarkers.size()); + pointDescription, colorIndex, 0); readFromSettings(); refresh(); diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 8b562b45ed..52cd69b7b8 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -62,8 +62,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements ContextMenuLayer. markerBitmapOrange = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_orange); markerBitmapRed = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_red); markerBitmapYellow = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_yellow); - markerBitmapTeal = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_red); - markerBitmapPurple = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_green); + markerBitmapTeal = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_teal); + markerBitmapPurple = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_purple); arrowToDestination = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_arrow_to_destination); bitmapPaintDestBlue = createPaintDest(R.color.marker_blue); @@ -182,9 +182,18 @@ public class MapMarkersLayer extends OsmandMapLayer implements ContextMenuLayer. if (marker == null || tb == null) { return false; } - return tb.containsLatLon(marker.getLatitude(), marker.getLongitude()); + return containsLatLon(tb, marker.getLatitude(), marker.getLongitude()); } + public boolean containsLatLon(RotatedTileBox tb, double lat, double lon) { + double widgetHeight = 0; + if (widget.isTopBarVisible()) { + widgetHeight = widget.getTopBarHeight(); + } + double tx = tb.getPixXFromLatLon(lat, lon); + double ty = tb.getPixYFromLatLon(lat, lon); + return tx >= 0 && tx <= tb.getPixWidth() && ty >= widgetHeight && ty <= tb.getPixHeight(); + } @Override public void destroyLayer() { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java index 8d912cced0..af1476f859 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java @@ -24,7 +24,7 @@ import java.util.List; public class MapMarkersWidget { - public static final int MIN_DIST_OK_VISIBLE = 50; + public static final int MIN_DIST_OK_VISIBLE = 40; private final MapActivity map; private MapMarkersHelper helper; @@ -153,9 +153,18 @@ public class MapMarkersWidget { return false; } + public int getTopBarHeight() { + return topBar.getHeight(); + } + + public boolean isTopBarVisible() { + return topBar.getVisibility() == View.VISIBLE; + } + public void updateInfo(int zoom) { List markers = helper.getActiveMapMarkers(); if (zoom < 3 || markers.size() == 0 || map.getMyApplication().getRoutingHelper().isFollowingMode() + || map.getMyApplication().getRoutingHelper().isRoutePlanningMode() || map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()) { updateVisibility(false); return; @@ -194,9 +203,7 @@ public class MapMarkersWidget { dd = (DirectionDrawable) arrowImg.getDrawable(); } dd.setImage(R.drawable.map_arrow_to_destination, MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex)); - if (loc == null || heading == null || marker.point == null) { - dd.setAngle(0); - } else { + if (heading != null && loc != null) { dd.setAngle(mes[1] - heading + 90 + screenOrientation); } if (newImage) {