Map markers UI fixes

This commit is contained in:
Alexey Kulish 2016-02-14 15:38:19 +03:00
parent 7eacd0da63
commit 5cabbc46b5
3 changed files with 25 additions and 9 deletions

View file

@ -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();

View file

@ -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() {

View file

@ -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<MapMarker> 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) {