diff --git a/OsmAnd/res/layout/map_marker_item.xml b/OsmAnd/res/layout/map_marker_item.xml
new file mode 100644
index 0000000000..58d93922f4
--- /dev/null
+++ b/OsmAnd/res/layout/map_marker_item.xml
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index fbff124c19..eaa0ea14bd 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -1,6 +1,12 @@
+ #2196f3
+ #73b825
+ #ff9800
+ #e53935
+ #d7eb23
+
#EE666666
#BBBBBB
#FFFFFF
diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
index 9ced0f2f35..f5e8be75ad 100644
--- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
@@ -2,14 +2,9 @@ package net.osmand.plus;
import android.content.Context;
-import net.osmand.StateChangedListener;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
-import net.osmand.plus.GeocodingLookupService;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.OsmandSettings;
-import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
@@ -21,9 +16,14 @@ public class MapMarkersHelper {
private List mapMarkers = new ArrayList<>();
private List mapMarkersHistory = new ArrayList<>();
private OsmandSettings settings;
- private List> listeners = new ArrayList>();
+ private List listeners = new ArrayList<>();
private OsmandApplication ctx;
+ public interface MapMarkerChangedListener {
+ void onMapMarkerChanged(MapMarker mapMarker);
+ void onMapMarkersChanged();
+ }
+
public static class MapMarker implements LocationPoint {
public LatLon point;
private PointDescription pointDescription;
@@ -112,7 +112,11 @@ public class MapMarkersHelper {
GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
- mapMarker.pointDescription.setName(address);
+ if (Algorithms.isEmpty(address)) {
+ mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
+ } else {
+ mapMarker.pointDescription.setName(address);
+ }
if (history) {
settings.updateMapMarkerHistory(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
mapMarker.pointDescription, mapMarker.colorIndex);
@@ -120,7 +124,7 @@ public class MapMarkersHelper {
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
mapMarker.pointDescription, mapMarker.colorIndex);
}
- refresh();
+ updateMarker(mapMarker);
}
}, null);
ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
@@ -260,18 +264,30 @@ public class MapMarkersHelper {
}
}
- public void addListener(StateChangedListener l) {
- listeners.add(l);
+ public void addListener(MapMarkerChangedListener l) {
+ if (!listeners.contains(l)) {
+ listeners.add(l);
+ }
}
- private void updateListeners() {
- for (StateChangedListener l : listeners) {
- l.stateChanged(null);
+ public void removeListener(MapMarkerChangedListener l) {
+ listeners.remove(l);
+ }
+
+ private void updateMarker(MapMarker marker) {
+ for (MapMarkerChangedListener l : listeners) {
+ l.onMapMarkerChanged(marker);
+ }
+ }
+
+ private void updateMarkers() {
+ for (MapMarkerChangedListener l : listeners) {
+ l.onMapMarkersChanged();
}
}
public void refresh() {
- updateListeners();
+ updateMarkers();
}
private void cancelAddressRequests() {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index 1707636fb4..edf051dfa4 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -110,7 +110,6 @@ public class MapActivityActions implements DialogProvider {
public void addMapMarker(double latitude, double longitude, PointDescription pd) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd);
- //openMapMarkersActivity();
}
public void editWaypoints() {
diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
index 07d7ad6e5f..df9a745159 100644
--- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
@@ -8,6 +8,8 @@ import net.osmand.StateChangedListener;
import net.osmand.ValueHolder;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.IMapLocationListener;
+import net.osmand.plus.MapMarkersHelper;
+import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
@@ -17,10 +19,8 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
-import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
-import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.AnimateDraggingMapThread;
@@ -29,7 +29,8 @@ import net.osmand.util.MapUtils;
import java.util.List;
-public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener {
+public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
+ OsmAndCompassListener, IRouteInformationListener, MapMarkerChangedListener {
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
private long lastTimeAutoZooming = 0;
@@ -70,15 +71,18 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
private void addMapMarkersListener(OsmandApplication app) {
- app.getMapMarkersHelper().addListener(new StateChangedListener() {
+ app.getMapMarkersHelper().addListener(this);
+ }
- @Override
- public void stateChanged(Void change) {
- if(mapView != null) {
- mapView.refreshMap();
- }
- }
- });
+ @Override
+ public void onMapMarkerChanged(MapMarkersHelper.MapMarker mapMarker) {
+ }
+
+ @Override
+ public void onMapMarkersChanged() {
+ if (mapView != null) {
+ mapView.refreshMap();
+ }
}
public void setMapView(OsmandMapTileView mapView) {
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 7d8dac5127..c676e25b3e 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -43,6 +43,7 @@ import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
+import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
@@ -87,7 +88,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
/**
*/
public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks,
- IRouteInformationListener, WaypointDialogHelperCallbacks {
+ IRouteInformationListener, WaypointDialogHelperCallbacks, MapMarkerChangedListener {
private static final org.apache.commons.logging.Log LOG =
PlatformUtil.getLog(DashboardOnMap.class);
private static final String TAG = "DashboardOnMap";
@@ -210,128 +211,128 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
// by default they handle touches for their list items... i.e. they're in charge of drawing
// the pressed state (the list selector), handling list item clicks, etc.
swipeDismissListener = new SwipeDismissListViewTouchListener(
- listView,
- new DismissCallbacks() {
+ listView,
+ new DismissCallbacks() {
- private List