diff --git a/OsmAnd/res/layout/map_marker_item_new.xml b/OsmAnd/res/layout/map_marker_item_new.xml
index db101331d0..7ae162e70d 100644
--- a/OsmAnd/res/layout/map_marker_item_new.xml
+++ b/OsmAnd/res/layout/map_marker_item_new.xml
@@ -78,7 +78,8 @@
android:text="•"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
- android:visibility="gone"/>
+ android:visibility="gone"
+ tools:visibility="visible"/>
diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java
index a53c7d3ca4..cf1a3a30fd 100644
--- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java
+++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java
@@ -818,7 +818,7 @@ public class OsmandAidlApi {
if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
PointDescription pd = new PointDescription(
PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
- MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
+ MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.creationDate, m.index);
markersHelper.moveMapMarker(marker, latLonNew);
refreshMap();
return true;
diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
index b727621a62..5b58d6e20e 100644
--- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
@@ -35,13 +35,15 @@ public class MapMarkersHelper {
public boolean history;
public boolean selected;
public int dist;
+ public long creationDate;
public MapMarker(LatLon point, PointDescription name, int colorIndex,
- boolean selected, int index) {
+ boolean selected, long creationDate, int index) {
this.point = point;
this.pointDescription = name;
this.colorIndex = colorIndex;
this.selected = selected;
+ this.creationDate = creationDate;
this.index = index;
}
@@ -169,6 +171,7 @@ public class MapMarkersHelper {
List desc = settings.getMapMarkersPointDescriptions(ips.size());
List colors = settings.getMapMarkersColors(ips.size());
List selections = settings.getMapMarkersSelections(ips.size());
+ List creationDates = settings.getMapMarkersCreationDates(ips.size());
int colorIndex = 0;
for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
@@ -176,15 +179,21 @@ public class MapMarkersHelper {
}
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
- selections.get(i), i);
+ selections.get(i), creationDates.get(i), i);
mapMarkers.add(mapMarker);
}
ips = settings.getMapMarkersHistoryPoints();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size());
+ colors = settings.getMapMarkersHistoryColors(ips.size());
+ creationDates = settings.getMapMarkersHistoryCreationDates(ips.size());
for (int i = 0; i < ips.size(); i++) {
+ if (colors.size() > i) {
+ colorIndex = colors.get(i);
+ }
MapMarker mapMarker = new MapMarker(ips.get(i),
- PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, false, i);
+ PointDescription.deserializeFromString(desc.get(i), ips.get(i)),
+ colorIndex, false, creationDates.get(i), i);
mapMarker.history = true;
mapMarkersHistory.add(mapMarker);
}
@@ -207,10 +216,10 @@ public class MapMarkersHelper {
}
if (history) {
settings.updateMapMarkerHistory(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
- mapMarker.pointDescription, mapMarker.colorIndex);
+ mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.creationDate);
} else {
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
- mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.selected);
+ mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.selected, mapMarker.creationDate);
}
updateMarker(mapMarker);
}
@@ -312,6 +321,12 @@ public class MapMarkersHelper {
refresh();
}
+ public void addMapMarker(MapMarker marker, int index) {
+ settings.insertMapMarker(marker.getLatitude(), marker.getLongitude(), marker.pointDescription,
+ marker.colorIndex, marker.selected, marker.creationDate, index);
+ readFromSettings();
+ }
+
public void addMapMarker(LatLon point, PointDescription historyName) {
List points = new ArrayList<>(1);
List historyNames = new ArrayList<>(1);
@@ -376,7 +391,7 @@ public class MapMarkersHelper {
public void updateMapMarker(MapMarker marker, boolean refresh) {
if (marker != null) {
settings.updateMapMarker(marker.getLatitude(), marker.getLongitude(),
- marker.pointDescription, marker.colorIndex, marker.selected);
+ marker.pointDescription, marker.colorIndex, marker.selected, marker.creationDate);
if (refresh) {
readFromSettings();
refresh();
@@ -387,7 +402,7 @@ public class MapMarkersHelper {
public void moveMapMarker(@Nullable MapMarker marker, LatLon latLon) {
if (marker != null) {
settings.moveMapMarker(new LatLon(marker.getLatitude(), marker.getLongitude()), latLon,
- marker.pointDescription, marker.colorIndex, marker.selected);
+ marker.pointDescription, marker.colorIndex, marker.selected, marker.creationDate);
marker.point = new LatLon(latLon.getLatitude(), latLon.getLongitude());
readFromSettings();
refresh();
@@ -404,7 +419,8 @@ public class MapMarkersHelper {
public void addMapMarkerHistory(MapMarker marker) {
if (marker != null) {
- settings.insertMapMarkerHistory(marker.getLatitude(), marker.getLongitude(), marker.pointDescription, marker.colorIndex, 0);
+ settings.insertMapMarkerHistory(marker.getLatitude(), marker.getLongitude(),
+ marker.pointDescription, marker.colorIndex, marker.creationDate, 0);
readFromSettings();
refresh();
}
@@ -424,25 +440,29 @@ public class MapMarkersHelper {
List names = new ArrayList<>(markers.size());
List colors = new ArrayList<>(markers.size());
List selections = new ArrayList<>(markers.size());
+ List creationDates = new ArrayList<>(markers.size());
for (MapMarker marker : markers) {
ls.add(marker.point);
names.add(PointDescription.serializeToString(marker.pointDescription));
colors.add(marker.colorIndex);
selections.add(marker.selected);
+ creationDates.add(marker.creationDate);
}
- settings.saveMapMarkers(ls, names, colors, selections);
+ settings.saveMapMarkers(ls, names, colors, selections, creationDates);
}
if (markersHistory != null) {
List ls = new ArrayList<>(markersHistory.size());
List names = new ArrayList<>(markersHistory.size());
List colors = new ArrayList<>(markersHistory.size());
+ List creationDates = new ArrayList<>(markersHistory.size());
for (MapMarker marker : markersHistory) {
ls.add(marker.point);
names.add(PointDescription.serializeToString(marker.pointDescription));
colors.add(marker.colorIndex);
+ creationDates.add(marker.creationDate);
}
- settings.saveMapMarkersHistory(ls, names, colors);
+ settings.saveMapMarkersHistory(ls, names, colors, creationDates);
}
if (markers != null || markersHistory != null) {
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 8dcec70c60..f2f6b625a2 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -1783,8 +1783,11 @@ public class OsmandSettings {
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$
public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$
public final static String MAP_MARKERS_SELECTION = "map_markers_selection"; //$NON-NLS-1$
+ public final static String MAP_MARKERS_CREATION_DATE = "map_markers_creation_date"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_POINT = "map_markers_history_point"; //$NON-NLS-1$
+ public final static String MAP_MARKERS_HISTORY_COLOR = "map_markers_history_color"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_DESCRIPTION = "map_markers_history_description"; //$NON-NLS-1$
+ public final static String MAP_MARKERS_HISTORY_CREATION_DATE = "map_markers_history_creation_date"; //$NON-NLS-1$
public final static int MAP_MARKERS_HISTORY_LIMIT = 30;
private MapMarkersStorage mapMarkersStorage = new MapMarkersStorage();
private MapMarkersHistoryStorage mapMarkersHistoryStorage = new MapMarkersHistoryStorage();
@@ -1896,6 +1899,7 @@ public class OsmandSettings {
.remove(MAP_MARKERS_DESCRIPTION)
.remove(MAP_MARKERS_COLOR)
.remove(MAP_MARKERS_SELECTION)
+ .remove(MAP_MARKERS_CREATION_DATE)
.commit();
}
@@ -1903,6 +1907,8 @@ public class OsmandSettings {
return settingsAPI.edit(globalPreferences)
.remove(MAP_MARKERS_HISTORY_POINT)
.remove(MAP_MARKERS_HISTORY_DESCRIPTION)
+ .remove(MAP_MARKERS_HISTORY_COLOR)
+ .remove(MAP_MARKERS_HISTORY_CREATION_DATE)
.commit();
}
@@ -1927,18 +1933,175 @@ public class OsmandSettings {
private class MapMarkersHistoryStorage extends MapPointsStorage {
+ protected String colorsKey;
+ protected String creationDatesKey;
+
public MapMarkersHistoryStorage() {
pointsKey = MAP_MARKERS_HISTORY_POINT;
descriptionsKey = MAP_MARKERS_HISTORY_DESCRIPTION;
+ colorsKey = MAP_MARKERS_HISTORY_COLOR;
+ creationDatesKey = MAP_MARKERS_HISTORY_CREATION_DATE;
+ }
+
+ public List getColors(int sz) {
+ List list = new ArrayList<>();
+ String ip = settingsAPI.getString(globalPreferences, colorsKey, "");
+ if (ip.trim().length() > 0) {
+ StringTokenizer tok = new StringTokenizer(ip, ",");
+ while (tok.hasMoreTokens()) {
+ String colorStr = tok.nextToken();
+ list.add(Integer.parseInt(colorStr));
+ }
+ }
+ while (list.size() > sz) {
+ list.remove(list.size() - 1);
+ }
+ int i = 0;
+ while (list.size() < sz) {
+ list.add(i % MapMarkersHelper.MAP_MARKERS_COLORS_COUNT);
+ i++;
+ }
+ return list;
+ }
+
+ public List getCreationDates(int sz) {
+ List list = new ArrayList<>();
+ String ip = settingsAPI.getString(globalPreferences, creationDatesKey, "");
+ if (ip.trim().length() > 0) {
+ StringTokenizer tok = new StringTokenizer(ip, ",");
+ while (tok.hasMoreTokens()) {
+ String creationDateStr = tok.nextToken();
+ list.add(Long.parseLong(creationDateStr));
+ }
+ }
+ while (list.size() > sz) {
+ list.remove(list.size() - 1);
+ }
+ while (list.size() < sz) {
+ list.add(0L);
+ }
+ return list;
+ }
+
+ public boolean savePoints(List ps, List ds, List cs, List cds) {
+ while (ps.size() > MAP_MARKERS_HISTORY_LIMIT) {
+ ps.remove(ps.size() - 1);
+ ds.remove(ds.size() - 1);
+ cs.remove(cs.size() - 1);
+ cds.remove(cds.size() - 1);
+ }
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < ps.size(); i++) {
+ if (i > 0) {
+ sb.append(",");
+ }
+ sb.append(((float) ps.get(i).getLatitude() + "")).append(",").append(((float) ps.get(i).getLongitude() + ""));
+ }
+ StringBuilder tb = new StringBuilder();
+ for (int i = 0; i < ds.size(); i++) {
+ if (i > 0) {
+ tb.append("--");
+ }
+ if (ds.get(i) == null) {
+ tb.append("");
+ } else {
+ tb.append(ds.get(i));
+ }
+ }
+ StringBuilder cb = new StringBuilder();
+ for (int i = 0; i < cs.size(); i++) {
+ if (i > 0) {
+ cb.append(",");
+ }
+ cb.append(Integer.toString(cs.get(i)));
+ }
+ StringBuilder cdb = new StringBuilder();
+ if (cds != null) {
+ for (int i = 0; i < cds.size(); i++) {
+ if (i > 0) {
+ cdb.append(",");
+ }
+ cdb.append(Long.toString(cds.get(i)));
+ }
+ }
+ return settingsAPI.edit(globalPreferences)
+ .putString(pointsKey, sb.toString())
+ .putString(descriptionsKey, tb.toString())
+ .putString(colorsKey, cb.toString())
+ .putString(creationDatesKey, cdb.toString())
+ .commit();
+ }
+
+ public boolean insertPoint(double latitude, double longitude,
+ PointDescription historyDescription, int colorIndex,
+ long creationDate, int index) {
+ List ps = getPoints();
+ List ds = getPointDescriptions(ps.size());
+ List cs = getColors(ps.size());
+ List cds = getCreationDates(ps.size());
+ ps.add(index, new LatLon(latitude, longitude));
+ ds.add(index, PointDescription.serializeToString(historyDescription));
+ cs.add(index, colorIndex);
+ cds.add(index, creationDate);
+ if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
+ SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
+ }
+ return savePoints(ps, ds, cs, cds);
+ }
+
+ public boolean updatePoint(double latitude, double longitude,
+ PointDescription historyDescription, int colorIndex,
+ long creationDate) {
+ List ps = getPoints();
+ List ds = getPointDescriptions(ps.size());
+ List cs = getColors(ps.size());
+ List cds = getCreationDates(ps.size());
+ int index = ps.indexOf(new LatLon(latitude, longitude));
+ if (index != -1) {
+ ds.set(index, PointDescription.serializeToString(historyDescription));
+ if (cs.size() > index) {
+ cs.set(index, colorIndex);
+ }
+ if (cds.size() > index) {
+ cds.set(index, creationDate);
+ }
+ if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
+ SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
+ }
+ return savePoints(ps, ds, cs, cds);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean deletePoint(int index) {
+ List ps = getPoints();
+ List ds = getPointDescriptions(ps.size());
+ List cs = getColors(ps.size());
+ List cds = getCreationDates(ps.size());
+ ps.remove(index);
+ ds.remove(index);
+ cds.remove(index);
+ if (cs.size() > index) {
+ cs.remove(index);
+ }
+ return savePoints(ps, ds, cs, cds);
}
@Override
public boolean savePoints(List ps, List ds) {
- while (ps.size() > MAP_MARKERS_HISTORY_LIMIT) {
- ps.remove(ps.size() - 1);
- ds.remove(ds.size() - 1);
- }
- return super.savePoints(ps, ds);
+ return false;
+ }
+
+ @Override
+ public boolean insertPoint(double latitude, double longitude, PointDescription historyDescription, int index) {
+ return false;
+ }
+
+ @Override
+ public boolean updatePoint(double latitude, double longitude, PointDescription historyDescription) {
+ return false;
}
}
@@ -1946,12 +2109,14 @@ public class OsmandSettings {
protected String colorsKey;
protected String selectionKey;
+ protected String creationDatesKey;
public MapMarkersStorage() {
pointsKey = MAP_MARKERS_POINT;
descriptionsKey = MAP_MARKERS_DESCRIPTION;
colorsKey = MAP_MARKERS_COLOR;
selectionKey = MAP_MARKERS_SELECTION;
+ creationDatesKey = MAP_MARKERS_CREATION_DATE;
}
public List getColors(int sz) {
@@ -1994,21 +2159,42 @@ public class OsmandSettings {
return list;
}
+ public List getCreationDates(int sz) {
+ List list = new ArrayList<>();
+ String ip = settingsAPI.getString(globalPreferences, creationDatesKey, "");
+ if (ip.trim().length() > 0) {
+ StringTokenizer tok = new StringTokenizer(ip, ",");
+ while (tok.hasMoreTokens()) {
+ String creationDateStr = tok.nextToken();
+ list.add(Long.parseLong(creationDateStr));
+ }
+ }
+ while (list.size() > sz) {
+ list.remove(list.size() - 1);
+ }
+ while (list.size() < sz) {
+ list.add(0L);
+ }
+ return list;
+ }
+
public boolean insertPoint(double latitude, double longitude,
- PointDescription historyDescription, int colorIndex, int pos,
- boolean selected, int index) {
+ PointDescription historyDescription, int colorIndex,
+ boolean selected, long creationDate, int index) {
List ps = getPoints();
List ds = getPointDescriptions(ps.size());
List cs = getColors(ps.size());
List bs = getSelections(ps.size());
+ List cds = getCreationDates(ps.size());
ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
bs.add(index, selected);
+ cds.add(index, creationDate == 0 ? System.currentTimeMillis() : creationDate);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
- return savePoints(ps, ds, cs, bs);
+ return savePoints(ps, ds, cs, bs, cds);
}
public boolean insertPoints(double[] latitudes, double[] longitudes,
@@ -2018,6 +2204,7 @@ public class OsmandSettings {
List ds = getPointDescriptions(ps.size());
List cs = getColors(ps.size());
List bs = getSelections(ps.size());
+ List cds = getCreationDates(ps.size());
for (int i = 0; i < latitudes.length; i++) {
double latitude = latitudes[i];
double longitude = longitudes[i];
@@ -2029,20 +2216,22 @@ public class OsmandSettings {
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
bs.add(index, selected);
+ cds.add(index, System.currentTimeMillis());
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
}
- return savePoints(ps, ds, cs, bs);
+ return savePoints(ps, ds, cs, bs, cds);
}
public boolean updatePoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex,
- boolean selected) {
+ boolean selected, long creationDate) {
List ps = getPoints();
List ds = getPointDescriptions(ps.size());
List cs = getColors(ps.size());
List bs = getSelections(ps.size());
+ List cds = getCreationDates(ps.size());
int index = ps.indexOf(new LatLon(latitude, longitude));
if (index != -1) {
ds.set(index, PointDescription.serializeToString(historyDescription));
@@ -2052,10 +2241,13 @@ public class OsmandSettings {
if (bs.size() > index) {
bs.set(index, selected);
}
+ if (cds.size() > index) {
+ cds.set(index, creationDate);
+ }
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
- return savePoints(ps, ds, cs, bs);
+ return savePoints(ps, ds, cs, bs, cds);
} else {
return false;
}
@@ -2065,11 +2257,13 @@ public class OsmandSettings {
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
- boolean selected) {
+ boolean selected,
+ long creationDate) {
List ps = getPoints();
List ds = getPointDescriptions(ps.size());
List cs = getColors(ps.size());
List bs = getSelections(ps.size());
+ List cds = getCreationDates(ps.size());
int index = ps.indexOf(latLonEx);
if (index != -1) {
if (ps.size() > index) {
@@ -2082,12 +2276,15 @@ public class OsmandSettings {
if (bs.size() > index) {
bs.set(index, selected);
}
+ if (cds.size() > index) {
+ cds.set(index, creationDate);
+ }
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
double lat = latLonNew.getLatitude();
double lon = latLonNew.getLongitude();
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(lat, lon, historyDescription);
}
- return savePoints(ps, ds, cs, bs);
+ return savePoints(ps, ds, cs, bs, cds);
} else {
return false;
}
@@ -2099,19 +2296,21 @@ public class OsmandSettings {
List ds = getPointDescriptions(ps.size());
List cs = getColors(ps.size());
List bs = getSelections(ps.size());
+ List cds = getCreationDates(ps.size());
ps.remove(index);
ds.remove(index);
+ cds.remove(index);
if (cs.size() > index) {
cs.remove(index);
}
if (bs.size() > index) {
bs.remove(index);
}
- return savePoints(ps, ds, cs, bs);
+ return savePoints(ps, ds, cs, bs, cds);
}
public boolean savePoints(List ps, List ds, List cs,
- List bs) {
+ List bs, List cds) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ps.size(); i++) {
if (i > 0) {
@@ -2146,11 +2345,21 @@ public class OsmandSettings {
bb.append(Boolean.toString(bs.get(i)));
}
}
+ StringBuilder cdb = new StringBuilder();
+ if (cds != null) {
+ for (int i = 0; i < cds.size(); i++) {
+ if (i > 0) {
+ cdb.append(",");
+ }
+ cdb.append(Long.toString(cds.get(i)));
+ }
+ }
return settingsAPI.edit(globalPreferences)
.putString(pointsKey, sb.toString())
.putString(descriptionsKey, tb.toString())
.putString(colorsKey, cb.toString())
.putString(selectionKey, bb.toString())
+ .putString(creationDatesKey, cdb.toString())
.commit();
}
@@ -2344,15 +2553,19 @@ public class OsmandSettings {
return mapMarkersStorage.getSelections(sz);
}
+ public List getMapMarkersCreationDates(int sz) {
+ return mapMarkersStorage.getCreationDates(sz);
+ }
+
public List getMapMarkersPoints() {
return mapMarkersStorage.getPoints();
}
public boolean insertMapMarker(double latitude, double longitude,
- PointDescription historyDescription, int colorIndex, int pos,
- boolean selected, int index) {
+ PointDescription historyDescription, int colorIndex,
+ boolean selected, long creationDate, int index) {
return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex,
- index, selected, pos);
+ selected, creationDate, index);
}
public boolean insertMapMarkers(double[] latitudes, double[] longitudes,
@@ -2363,24 +2576,27 @@ public class OsmandSettings {
}
public boolean updateMapMarker(double latitude, double longitude,
- PointDescription historyDescription, int colorIndex, boolean selected) {
- return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, selected);
+ PointDescription historyDescription, int colorIndex, boolean selected,
+ long creationDate) {
+ return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, selected, creationDate);
}
public boolean moveMapMarker(LatLon latLonEx,
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
- boolean selected) {
- return mapMarkersStorage.movePoint(latLonEx, latLonNew, historyDescription, colorIndex, selected);
+ boolean selected,
+ long creationDate) {
+ return mapMarkersStorage.movePoint(latLonEx, latLonNew, historyDescription, colorIndex, selected, creationDate);
}
public boolean deleteMapMarker(int index) {
return mapMarkersStorage.deletePoint(index);
}
- public boolean saveMapMarkers(List ps, List ds, List cs, List bs) {
- return mapMarkersStorage.savePoints(ps, ds, cs, bs);
+ public boolean saveMapMarkers(List ps, List ds, List cs, List bs,
+ List cds) {
+ return mapMarkersStorage.savePoints(ps, ds, cs, bs, cds);
}
@@ -2392,22 +2608,31 @@ public class OsmandSettings {
return mapMarkersHistoryStorage.getPoints();
}
+ public List getMapMarkersHistoryCreationDates(int sz) {
+ return mapMarkersHistoryStorage.getCreationDates(sz);
+ }
+
+ public List getMapMarkersHistoryColors(int sz) {
+ return mapMarkersHistoryStorage.getColors(sz);
+ }
+
public boolean insertMapMarkerHistory(double latitude, double longitude,
- PointDescription historyDescription, int colorIndex, int index) {
- return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, index);
+ PointDescription historyDescription, int colorIndex,
+ long creationDate, int index) {
+ return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, creationDate, index);
}
public boolean updateMapMarkerHistory(double latitude, double longitude,
- PointDescription historyDescription, int colorIndex) {
- return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription);
+ PointDescription historyDescription, int colorIndex, long creationDate) {
+ return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, creationDate);
}
public boolean deleteMapMarkerHistory(int index) {
return mapMarkersHistoryStorage.deletePoint(index);
}
- public boolean saveMapMarkersHistory(List ps, List ds, List cs) {
- return mapMarkersHistoryStorage.savePoints(ps, ds);
+ public boolean saveMapMarkersHistory(List ps, List ds, List cs, List cds) {
+ return mapMarkersHistoryStorage.savePoints(ps, ds, cs, cds);
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
index e6cb7502e1..3b2fb3d96d 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
@@ -121,6 +121,12 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
return null;
}
+ void updateAdapter() {
+ if (adapter != null) {
+ adapter.notifyDataSetChanged();
+ }
+ }
+
private void updateLocationUi() {
final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
index 0bdc11b5fb..99c05a9550 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
@@ -78,11 +78,17 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
switch (menuItem.getItemId()) {
case R.id.action_active:
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
+ if (viewPager.getCurrentItem() != 0) {
+ ((MapMarkersActiveFragment) adapter.getItem(0)).updateAdapter();
+ }
viewPager.setCurrentItem(0);
optionsButton.setVisibility(View.VISIBLE);
return true;
case R.id.action_history:
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
+ if (viewPager.getCurrentItem() != 1) {
+ ((MapMarkersHistoryFragment) adapter.getItem(1)).updateAdapter();
+ }
viewPager.setCurrentItem(1);
optionsButton.setVisibility(View.GONE);
return true;
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
index b84d42ba86..f5ef8026e3 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
@@ -2,6 +2,7 @@ package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -9,11 +10,15 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import net.osmand.data.PointDescription;
+import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
public class MapMarkersHistoryFragment extends Fragment {
+ MapMarkersHistoryAdapter adapter;
+
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -21,8 +26,27 @@ public class MapMarkersHistoryFragment extends Fragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
final MapActivity mapActivity = (MapActivity) getActivity();
- recyclerView.setAdapter(new MapMarkersHistoryAdapter(mapActivity.getMyApplication()));
+ adapter = new MapMarkersHistoryAdapter(mapActivity.getMyApplication());
+ adapter.setAdapterListener(new MapMarkersHistoryAdapter.MapMarkersHistoryAdapterListener() {
+ @Override
+ public void onItemClick(View view) {
+ int pos = recyclerView.indexOfChild(view);
+ MapMarker marker = adapter.getItem(pos);
+ mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
+ 15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(mapActivity).getName()),
+ false, null);
+ MapActivity.launchMapActivityMoveToTop(mapActivity);
+ ((DialogFragment) getParentFragment()).dismiss();
+ }
+ });
+ recyclerView.setAdapter(adapter);
return recyclerView;
}
+
+ void updateAdapter() {
+ if (adapter != null) {
+ adapter.notifyDataSetChanged();
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
index 8775a599f9..d3042e2090 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
@@ -17,7 +17,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
final TextView distance;
final TextView point;
final TextView description;
- final ImageButton options;
+ final ImageButton optionsBtn;
public MapMarkerItemViewHolder(View view) {
super(view);
@@ -28,6 +28,6 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
distance = (TextView) view.findViewById(R.id.map_marker_distance);
point = (TextView) view.findViewById(R.id.map_marker_point_text_view);
description = (TextView) view.findViewById(R.id.map_marker_description);
- options = (ImageButton) view.findViewById(R.id.map_marker_options_button);
+ optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java
index 83014d6132..20cfc06e1a 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java
@@ -1,5 +1,6 @@
package net.osmand.plus.mapmarkers.adapters;
+import android.support.design.widget.Snackbar;
import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -87,6 +88,42 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter markers;
+ private MapMarkersHistoryAdapterListener listener;
public MapMarkersHistoryAdapter(OsmandApplication app) {
this.app = app;
markers = app.getMapMarkersHelper().getMapMarkersHistory();
}
+ public void setAdapterListener(MapMarkersHistoryAdapterListener listener) {
+ this.listener = listener;
+ }
+
@Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ listener.onItemClick(view);
+ }
+ });
return new MapMarkerItemViewHolder(view);
}
@Override
- public void onBindViewHolder(MapMarkerItemViewHolder holder, int pos) {
+ public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) {
IconsCache iconsCache = app.getIconsCache();
MapMarker marker = markers.get(pos);
@@ -39,10 +50,34 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter