From f733ad4f8a7cfce246d16dc71cc2a2af8532b653 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 18 Mar 2015 00:38:38 +0100 Subject: [PATCH] Fix history --- OsmAnd/res/values/strings.xml | 1 + .../search/SearchHistoryFragment.java | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0dbb029d8d..c29f71bded 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 --> + Do you want to clear the whole history? Automatically start navigation after specified interval Skip route planning Go diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java index c34b5bd25c..036459ea71 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java @@ -18,7 +18,10 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.util.MapUtils; import android.R.anim; import android.app.Activity; +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -64,9 +67,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit clearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - helper.removeAll(); - historyAdapter.clear(); - clearButton.setVisibility(View.GONE); + clearWithConfirmation(); } }); ((ListView)view.findViewById(android.R.id.list)).setOnItemClickListener(new OnItemClickListener() { @@ -79,6 +80,26 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit return view; } + + private void clearWithConfirmation() { + Builder bld = new AlertDialog.Builder(getActivity()); + bld.setMessage(R.string.confirmation_to_clear_history); + bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + clearWithoutConfirmation(); + } + }); + bld.setNegativeButton(R.string.shared_string_no, null); + bld.show(); + } + + private void clearWithoutConfirmation() { + helper.removeAll(); + historyAdapter.clear(); + clearButton.setVisibility(View.GONE); + } @Override public void onCreate(Bundle savedInstanceState) {