added removeMarkersGroup if group was added

This commit is contained in:
Chumva 2018-03-27 12:08:13 +03:00
parent 2ebca53e25
commit edb2400e9d
2 changed files with 15 additions and 3 deletions

View file

@ -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
-->
<string name="waypoints_removed_from_map_markers">Waypoints removed from map markers</string>
<string name="nothing_found_in_radius">Nothing found within the radius:</string>
<string name="select_waypoints_category_description">You can add all of the track\'s waypoints, or select separate categories.</string>
<string name="shared_string_total">Total</string>

View file

@ -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());
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) {