Fix history

This commit is contained in:
Victor Shcherb 2015-03-18 00:38:38 +01:00
parent 61cd6c6ec6
commit f733ad4f8a
2 changed files with 25 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). 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 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="confirmation_to_clear_history">Do you want to clear the whole history?</string>
<string name="delay_to_start_navigation_descr">Automatically start navigation after specified interval</string> <string name="delay_to_start_navigation_descr">Automatically start navigation after specified interval</string>
<string name="delay_to_start_navigation">Skip route planning</string> <string name="delay_to_start_navigation">Skip route planning</string>
<string name="shared_string_go">Go</string> <string name="shared_string_go">Go</string>

View file

@ -18,7 +18,10 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.R.anim; import android.R.anim;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -64,9 +67,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
clearButton.setOnClickListener(new View.OnClickListener() { clearButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
helper.removeAll(); clearWithConfirmation();
historyAdapter.clear();
clearButton.setVisibility(View.GONE);
} }
}); });
((ListView)view.findViewById(android.R.id.list)).setOnItemClickListener(new OnItemClickListener() { ((ListView)view.findViewById(android.R.id.list)).setOnItemClickListener(new OnItemClickListener() {
@ -80,6 +81,26 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
return view; 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 @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);