From edb2400e9dd148433d00389c15834f15a3948208 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 27 Mar 2018 12:08:13 +0300 Subject: [PATCH] added removeMarkersGroup if group was added --- OsmAnd/res/values/strings.xml | 1 + .../plus/myplaces/TrackPointFragment.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 7e989e2ded..d623adbf92 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Waypoints removed from map markers Nothing found within the radius: You can add all of the track\'s waypoints, or select separate categories. Total diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 35a993b91c..76b034522a 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -436,9 +436,13 @@ public class TrackPointFragment extends OsmandExpandableListFragment { }); if (!MenuItemCompat.isActionViewExpanded(mi)) { + final MapMarkersHelper markersHelper = app.getMapMarkersHelper(); + final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(getGpxDataItem().getFile()); + final boolean synced = markersHelper.isGroupSynced(markersGr.getId()); + createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER); - createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.shared_string_add_to_map_markers, R.drawable.ic_action_flag_dark, + createMenuItem(menu, SELECT_MAP_MARKERS_ID, synced ? R.string.remove_from_map_markers : R.string.shared_string_add_to_map_markers, R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER); createMenuItem(menu, SELECT_FAVORITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER); @@ -582,7 +586,13 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private void addMapMarkersSyncGroup() { MapMarkersHelper markersHelper = app.getMapMarkersHelper(); final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(getGpxDataItem().getFile()); - markersHelper.addOrEnableGroup(markersGr); + final boolean synced = markersHelper.isGroupSynced(markersGr.getId()); + if (synced) { + markersHelper.removeMarkersGroup(markersGr); + } else { + markersHelper.addOrEnableGroup(markersGr); + } + getActionBarActivity().invalidateOptionsMenu(); GPXFile gpxFile = getTrackActivity().getGpx(); if (gpxFile != null) { app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, false); @@ -590,7 +600,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment { hideTransparentOverlay(); closeMenu(); updateMenuFabVisibility(false); - Snackbar snackbar = Snackbar.make(mainView, getResources().getString(R.string.waypoints_added_to_map_markers), Snackbar.LENGTH_LONG) + Snackbar snackbar = Snackbar.make(mainView, getResources().getString(synced?R.string.waypoints_removed_from_map_markers:R.string.waypoints_added_to_map_markers), + Snackbar.LENGTH_LONG) .setAction(getResources().getString(R.string.view), new View.OnClickListener() { @Override public void onClick(View v) {