From 63aa93ca11fa3aa0813eb1a043c74259d48a36a1 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 12 Sep 2017 10:42:39 +0300 Subject: [PATCH 1/5] Improve method --- OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index 0e6714b1b5..35e301c287 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -308,12 +308,14 @@ public class MapMarkersDbHelper { private void buildLinkedList(HashMap markers, List res) { if (!markers.isEmpty()) { + int count = 1; for (MapMarker marker : markers.values()) { - if (!markers.keySet().contains(marker.nextKey)) { + if (!markers.keySet().contains(marker.nextKey) || count == markers.size()) { res.add(0, marker); markers.remove(marker.id); break; } + count++; } buildLinkedList(markers, res); } From 9e050f207ca166f8c1c9f7846d4bbe8e3ed81a94 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 12 Sep 2017 11:59:14 +0300 Subject: [PATCH 2/5] Add method call --- OsmAnd/src/net/osmand/plus/MapMarkersHelper.java | 1 + .../osmand/plus/activities/EditFavoriteGroupDialogFragment.java | 1 + 2 files changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index b51e67e727..29fbf20a58 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -186,6 +186,7 @@ public class MapMarkersHelper { List activeMarkers = markersDbHelper.getActiveMarkers(); mapMarkers.addAll(activeMarkers); + checkAndFixActiveMarkersOrderIfNeeded(); List markersHistory = markersDbHelper.getMarkersHistory(); sortMarkers(markersHistory, true); diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index af747429e6..22d3327d4c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -181,6 +181,7 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { addToMarkersView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + // add to map markers MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); List points = new ArrayList<>(group.points.size()); List names = new ArrayList<>(group.points.size()); From d61b2a9e8245fea3d5a7b7639e9d66a86e8848c9 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 12 Sep 2017 13:36:35 +0300 Subject: [PATCH 3/5] Add some changes --- .../src/net/osmand/plus/MapMarkersHelper.java | 17 +-- .../EditFavoriteGroupDialogFragment.java | 1 - .../plus/mapmarkers/MapMarkersDbHelper.java | 100 +----------------- .../adapters/MapMarkersActiveAdapter.java | 3 +- 4 files changed, 8 insertions(+), 113 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 29fbf20a58..e0e4675989 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -50,7 +50,7 @@ public class MapMarkersHelper { public long creationDate; public long visitedDate; public String nextKey; - public long groupKey = -1; + public String groupKey; public String groupName; public MapMarker(LatLon point, PointDescription name, int colorIndex, @@ -254,19 +254,8 @@ public class MapMarkersHelper { } } - public long getGroupId(String name) { - return markersDbHelper.getGroupId(name); - } + public void addGroupToSync(String id, String name) { -// public void removeMarker(double lat, double lon, long groupId) { -// markersDbHelper.removeMarker(lat, lon, groupId); -// loadMarkers(); -// refresh(); -// } - - @Nullable - public String getGroupName(long id) { - return markersDbHelper.getGroupName(id); } public void moveMapMarkerToHistory(MapMarker marker) { @@ -420,7 +409,7 @@ public class MapMarkersHelper { MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0); if (groups != null) { - marker.groupKey = markersDbHelper.createGroupIfNeeded(groups.get(i)); +// marker.groupKey = markersDbHelper.createGroupIfNeeded(groups.get(i)); } marker.history = false; marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 22d3327d4c..af747429e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -181,7 +181,6 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { addToMarkersView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // add to map markers MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); List points = new ArrayList<>(group.points.size()); List names = new ArrayList<>(group.points.size()); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index 35e301c287..d7f5572e79 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -20,7 +20,7 @@ import java.util.Random; public class MapMarkersDbHelper { - private static final int DB_VERSION = 4; + private static final int DB_VERSION = 5; public static final String DB_NAME = "map_markers_db"; private static final String MARKERS_TABLE_NAME = "map_markers"; @@ -46,7 +46,7 @@ public class MapMarkersDbHelper { MARKERS_COL_ADDED + " long, " + MARKERS_COL_VISITED + " long, " + MARKERS_COL_GROUP_NAME + " TEXT, " + - MARKERS_COL_GROUP_KEY + " long, " + + MARKERS_COL_GROUP_KEY + " TEXT, " + MARKERS_COL_COLOR + " int, " + MARKERS_COL_NEXT_KEY + " TEXT);"; @@ -70,7 +70,7 @@ public class MapMarkersDbHelper { private static final String GROUPS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GROUPS_TABLE_NAME + " (" + - GROUPS_COL_ID + " long PRIMARY KEY, " + + GROUPS_COL_ID + " TEXT PRIMARY KEY, " + GROUPS_COL_NAME + " TEXT);"; private static final String GROUPS_TABLE_SELECT = "SELECT " + @@ -149,27 +149,6 @@ public class MapMarkersDbHelper { } } - public long createGroupIfNeeded(String name) { - long res = -1; - SQLiteConnection db = openConnection(false); - if (db != null) { - try { - SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT + " WHERE " + GROUPS_COL_NAME + " = ?", - new String[]{name}); - if (query.moveToFirst()) { - res = query.getLong(0); - } else { - res = Long.parseLong(String.valueOf(System.currentTimeMillis()) + String.valueOf(new Random().nextInt(900) + 100)); - db.execSQL("INSERT INTO " + GROUPS_TABLE_NAME + " VALUES (?, ?)", new Object[]{res, name}); - } - query.close(); - } finally { - db.close(); - } - } - return res; - } - public void addMarker(MapMarker marker) { addMarker(marker, false); } @@ -217,45 +196,6 @@ public class MapMarkersDbHelper { marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE}); } - public long getGroupId(String name) { - long res = -1; - if (name != null) { - SQLiteConnection db = openConnection(true); - if (db != null) { - try { - SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT + " WHERE " + GROUPS_COL_NAME + " = ?", - new String[]{name}); - if (query.moveToFirst()) { - res = query.getLong(0); - } - query.close(); - } finally { - db.close(); - } - } - } - return res; - } - - @Nullable - public String getGroupName(long id) { - String res = null; - SQLiteConnection db = openConnection(true); - if (db != null) { - try { - SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT + " WHERE " + GROUPS_COL_ID + " = ?", - new String[]{String.valueOf(id)}); - if (query.moveToFirst()) { - res = query.getString(1); - } - query.close(); - } finally { - db.close(); - } - } - return res; - } - public List getActiveMarkers() { List res = new LinkedList<>(); HashMap markers = new LinkedHashMap<>(); @@ -288,7 +228,7 @@ public class MapMarkersDbHelper { long added = query.getLong(5); long visited = query.getLong(6); String groupName = query.getString(7); - long groupKey = query.getLong(8); + String groupKey = query.getString(8); int colorIndex = query.getInt(9); String nextKey = query.getString(10); @@ -351,38 +291,6 @@ public class MapMarkersDbHelper { } } - public void removeMarker(double lat, double lon, long groupId) { - SQLiteConnection db = openConnection(false); - if (db != null) { - try { - MapMarker marker = null; - SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + - MARKERS_COL_LAT + " = ? AND " + - MARKERS_COL_LON + " = ? AND " + - MARKERS_COL_GROUP_KEY + " = ?", - new String[]{String.valueOf(lat), String.valueOf(lon), String.valueOf(groupId)}); - if (query.moveToFirst()) { - marker = readItem(query); - } - query.close(); - - if (marker != null) { - if (marker.history) { - removeMarkerFromHistory(marker); - } else { - db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_NEXT_KEY + " = ? " + - "WHERE " + MARKERS_COL_NEXT_KEY + " = ?", new Object[]{marker.nextKey, marker.id}); - - db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_ID + " = ?", - new Object[]{marker.id}); - } - } - } finally { - db.close(); - } - } - } - public void moveMarkerToHistory(MapMarker marker) { SQLiteConnection db = openConnection(false); if (db != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 08cab33ea2..1401f5c4c3 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -114,8 +114,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter Date: Tue, 12 Sep 2017 15:54:17 +0300 Subject: [PATCH 4/5] Change adding markers from favorites --- .../src/net/osmand/plus/MapMarkersHelper.java | 45 +++++++++++++--- .../EditFavoriteGroupDialogFragment.java | 3 +- .../activities/FavoritesTreeFragment.java | 18 ++++--- .../plus/mapmarkers/MapMarkersDbHelper.java | 51 +++++++++++++++++-- 4 files changed, 100 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index e0e4675989..e39a68c11e 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -1,6 +1,7 @@ package net.osmand.plus; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.format.DateFormat; @@ -154,6 +155,34 @@ public class MapMarkersHelper { } } + public static class MarkersSyncGroup { + + public static final int FAVORITES_TYPE = 0; + public static final int GPX_TYPE = 1; + + private String id; + private String name; + private int type; + + public MarkersSyncGroup(@NonNull String id, @NonNull String name, int type) { + this.id = id; + this.name = name; + this.type = type; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public int getType() { + return type; + } + } + public MapMarkersHelper(OsmandApplication ctx) { this.ctx = ctx; settings = ctx.getSettings(); @@ -254,7 +283,7 @@ public class MapMarkersHelper { } } - public void addGroupToSync(String id, String name) { + public void syncGroup(MarkersSyncGroup group) { } @@ -374,15 +403,15 @@ public class MapMarkersHelper { addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null); } - public void addMapMarkers(List points, List historyNames, List groups) { - addMarkers(points, historyNames, groups); + public void addMapMarkers(List points, List historyNames, @Nullable MarkersSyncGroup group) { + addMarkers(points, historyNames, group); } public void addMapMarkers(List points, List historyNames) { addMarkers(points, historyNames, null); } - private void addMarkers(List points, List historyNames, @Nullable List groups) { + private void addMarkers(List points, List historyNames, @Nullable MarkersSyncGroup group) { if (points.size() > 0) { int colorIndex = -1; for (int i = 0; i < points.size(); i++) { @@ -408,8 +437,12 @@ public class MapMarkersHelper { } MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0); - if (groups != null) { -// marker.groupKey = markersDbHelper.createGroupIfNeeded(groups.get(i)); + if (group != null) { + if (markersDbHelper.getGroup(group.getId()) == null) { + markersDbHelper.addGroup(group.getId(), group.getName(), group.getType()); + } + marker.id = group.getId() + marker.getName(ctx); + marker.groupName = group.getName(); } marker.history = false; marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index af747429e6..ce4bc97295 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -30,6 +30,7 @@ import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.base.BottomSheetDialogFragment; @@ -188,7 +189,7 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { points.add(new LatLon(fp.getLatitude(), fp.getLongitude())); names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName())); } - markersHelper.addMapMarkers(points, names); + markersHelper.addMapMarkers(points, names, new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE)); dismiss(); MapActivity.launchMapActivityMoveToTop(getActivity()); } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 7c0f7817b6..1ee398d73d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -36,6 +36,7 @@ import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -57,6 +58,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -401,18 +403,22 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { if (getSelectedFavoritesCount() > 0) { if (getSettings().USE_MAP_MARKERS.get()) { MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); - int size = getSelectedFavoritesCount(); - List points = new ArrayList<>(size); - List names = new ArrayList<>(size); - List groups = new ArrayList<>(size); + List points = new LinkedList<>(); + List names = new LinkedList<>(); for (Map.Entry> entry : favoritesSelected.entrySet()) { + MarkersSyncGroup syncGr = null; + FavoriteGroup favGr = helper.getGroup(entry.getKey()); + if (entry.getValue().size() == favGr.points.size()) { + syncGr = new MarkersSyncGroup(favGr.name, favGr.name, MarkersSyncGroup.FAVORITES_TYPE); + } for (FavouritePoint fp : entry.getValue()) { points.add(new LatLon(fp.getLatitude(), fp.getLongitude())); names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName())); - groups.add(entry.getKey()); } + markersHelper.addMapMarkers(points, names, syncGr); + points.clear(); + names.clear(); } - markersHelper.addMapMarkers(points, names, groups); MapActivity.launchMapActivityMoveToTop(getActivity()); } else { final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index d7f5572e79..f6be7c00ec 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -5,6 +5,7 @@ import android.support.annotation.Nullable; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; @@ -20,7 +21,7 @@ import java.util.Random; public class MapMarkersDbHelper { - private static final int DB_VERSION = 5; + private static final int DB_VERSION = 6; public static final String DB_NAME = "map_markers_db"; private static final String MARKERS_TABLE_NAME = "map_markers"; @@ -67,15 +68,18 @@ public class MapMarkersDbHelper { private static final String GROUPS_TABLE_NAME = "map_markers_groups"; private static final String GROUPS_COL_ID = "group_id"; private static final String GROUPS_COL_NAME = "group_name"; + private static final String GROUPS_COL_TYPE = "group_type"; private static final String GROUPS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GROUPS_TABLE_NAME + " (" + GROUPS_COL_ID + " TEXT PRIMARY KEY, " + - GROUPS_COL_NAME + " TEXT);"; + GROUPS_COL_NAME + " TEXT, " + + GROUPS_COL_TYPE + " int);"; private static final String GROUPS_TABLE_SELECT = "SELECT " + GROUPS_COL_ID + ", " + - GROUPS_COL_NAME + + GROUPS_COL_NAME + ", " + + GROUPS_COL_TYPE + " FROM " + GROUPS_TABLE_NAME; public static final String TAIL_NEXT_VALUE = "tail_next"; @@ -149,6 +153,43 @@ public class MapMarkersDbHelper { } } + public void addGroup(String id, String name, int type) { + SQLiteConnection db = openConnection(false); + if (db != null) { + try { + db.execSQL("INSERT INTO " + GROUPS_TABLE_NAME + " VALUES (?, ?, ?)", new Object[]{id, name, type}); + } finally { + db.close(); + } + } + } + + @Nullable + public MarkersSyncGroup getGroup(String id) { + MarkersSyncGroup res = null; + SQLiteConnection db = openConnection(true); + if (db != null) { + try { + SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT + " WHERE " + GROUPS_COL_ID + " = ?", new String[]{id}); + if (query.moveToFirst()) { + res = readSyncGroup(query); + } + query.close(); + } finally { + db.close(); + } + } + return res; + } + + private MarkersSyncGroup readSyncGroup(SQLiteCursor query) { + String id = query.getString(0); + String name = query.getString(1); + int type = query.getInt(2); + + return new MarkersSyncGroup(id, name, type); + } + public void addMarker(MapMarker marker) { addMarker(marker, false); } @@ -173,7 +214,9 @@ public class MapMarkersDbHelper { } else { currentTime = System.currentTimeMillis(); } - marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100); + if (marker.id == null) { + marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100); + } marker.creationDate = currentTime; String descr = PointDescription.serializeToString(marker.getOriginalPointDescription()); int active = marker.history ? 0 : 1; From 3f5420e423856ad3118e354bfec77fd49e1e08b3 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 12 Sep 2017 16:55:33 +0300 Subject: [PATCH 5/5] Change adding markers from gpx track --- .../osmand/plus/myplaces/TrackPointFragment.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 54ceae5c4c..07315990ce 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -44,6 +44,7 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -607,7 +608,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment { names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name)); } } - markersHelper.addMapMarkers(points, names); + File gpx = getGpxDataItem().getFile(); + MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(), trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE); + markersHelper.addMapMarkers(points, names, syncGroup); MapActivity.launchMapActivityMoveToTop(getActivity()); } else { final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); @@ -626,6 +629,14 @@ public class TrackPointFragment extends OsmandExpandableListFragment { } } + private String trimExtension(String src) { + int index = src.lastIndexOf('.'); + if (index != -1) { + return src.substring(0, index); + } + return src; + } + private void enterFavoritesMode() { actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {