From 03ee996b051f712a5f6c24816012fcb9f7e5e789 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 19 Oct 2017 15:53:46 +0300 Subject: [PATCH] Add the ability to undo an action --- .../mapmarkers/MarkerMenuOnMapFragment.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java index 64932c8170..f4bd81aba3 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.content.ContextCompat; @@ -113,6 +114,17 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi @Override public void onClick(View view) { app.getMapMarkersHelper().moveMapMarkerToHistory(marker); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.marker_moved_to_history, Snackbar.LENGTH_LONG) + .setAction(R.string.shared_string_undo, new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0); + } + }) + .show(); + } dismiss(); } }); @@ -128,6 +140,17 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi @Override public void onClick(View view) { app.getMapMarkersHelper().removeMarker(marker); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.item_removed, Snackbar.LENGTH_LONG) + .setAction(R.string.shared_string_undo, new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().addMarker(marker); + } + }) + .show(); + } dismiss(); } });