From edb2400e9dd148433d00389c15834f15a3948208 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 27 Mar 2018 12:08:13 +0300 Subject: [PATCH 1/3] 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) { From 255faad66dd5a4aca400990c88041b5acdf7f254 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 27 Mar 2018 14:14:31 +0300 Subject: [PATCH 2/3] added undo option --- .../osmand/plus/myplaces/TrackPointFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 76b034522a..1b6ca3137e 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -584,7 +584,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { } private void addMapMarkersSyncGroup() { - MapMarkersHelper markersHelper = app.getMapMarkersHelper(); + final MapMarkersHelper markersHelper = app.getMapMarkersHelper(); final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(getGpxDataItem().getFile()); final boolean synced = markersHelper.isGroupSynced(markersGr.getId()); if (synced) { @@ -602,12 +602,17 @@ public class TrackPointFragment extends OsmandExpandableListFragment { updateMenuFabVisibility(false); 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() { + .setAction(synced?getResources().getString(R.string.shared_string_undo):getResources().getString(R.string.view), new View.OnClickListener() { @Override public void onClick(View v) { - Bundle args = new Bundle(); - args.putString(MapMarkersGroup.MARKERS_SYNC_GROUP_ID, markersGr.getId()); - MapActivity.launchMapActivityMoveToTop(getTrackActivity(), MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS, args); + if (synced) { + markersHelper.addOrEnableGroup(markersGr); + getActionBarActivity().invalidateOptionsMenu(); + } else { + Bundle args = new Bundle(); + args.putString(MapMarkersGroup.MARKERS_SYNC_GROUP_ID, markersGr.getId()); + MapActivity.launchMapActivityMoveToTop(getTrackActivity(), MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS, args); + } } }); snackbar.addCallback(new Snackbar.Callback() { From 71b5e6a1b3b5ef2268c52c9723b4aae67d216672 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 28 Mar 2018 10:47:59 +0300 Subject: [PATCH 3/3] Rename method addOrRemoveMapMarkersSyncGroup and delete getResources --- .../src/net/osmand/plus/myplaces/TrackPointFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 1b6ca3137e..0a41d65646 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -376,7 +376,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private void selectMapMarkers() { if (getGpxDataItem() != null) { - addMapMarkersSyncGroup(); + addOrRemoveMapMarkersSyncGroup(); } } @@ -583,7 +583,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { } } - private void addMapMarkersSyncGroup() { + private void addOrRemoveMapMarkersSyncGroup() { final MapMarkersHelper markersHelper = app.getMapMarkersHelper(); final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(getGpxDataItem().getFile()); final boolean synced = markersHelper.isGroupSynced(markersGr.getId()); @@ -600,9 +600,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment { hideTransparentOverlay(); closeMenu(); updateMenuFabVisibility(false); - Snackbar snackbar = Snackbar.make(mainView, getResources().getString(synced?R.string.waypoints_removed_from_map_markers:R.string.waypoints_added_to_map_markers), + Snackbar snackbar = Snackbar.make(mainView, synced ? R.string.waypoints_removed_from_map_markers : R.string.waypoints_added_to_map_markers, Snackbar.LENGTH_LONG) - .setAction(synced?getResources().getString(R.string.shared_string_undo):getResources().getString(R.string.view), new View.OnClickListener() { + .setAction(synced ? R.string.shared_string_undo : R.string.view, new View.OnClickListener() { @Override public void onClick(View v) { if (synced) {