Add delete all button
This commit is contained in:
parent
a98c49e559
commit
3a3e68bb8c
2 changed files with 31 additions and 0 deletions
|
@ -9,6 +9,8 @@
|
||||||
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="local_osm_changes_delete_all_confirm">You are going to delete %1$d osm changes. Are you sure?</string>
|
||||||
|
<string name="local_osm_changes_delete_all">Delete All</string>
|
||||||
<string name="animate_routing_route_not_calculated">Please, calculate the route first</string>
|
<string name="animate_routing_route_not_calculated">Please, calculate the route first</string>
|
||||||
<string name="animate_routing_route">Simulate using calculated route </string>
|
<string name="animate_routing_route">Simulate using calculated route </string>
|
||||||
<string name="animate_routing_gpx">Simulate using GPX track</string>
|
<string name="animate_routing_gpx">Simulate using GPX track</string>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
|
@ -20,6 +21,8 @@ import net.osmand.plus.osmedit.OsmPoint.Action;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -47,6 +50,7 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
|
||||||
protected static final int MENU_GROUP = 0;
|
protected static final int MENU_GROUP = 0;
|
||||||
private static final int UPLOAD_ID = 1;
|
private static final int UPLOAD_ID = 1;
|
||||||
private static final int BACKUP_ID = 2;
|
private static final int BACKUP_ID = 2;
|
||||||
|
private static final int DELETE_ID = 3;
|
||||||
|
|
||||||
private LocalOpenstreetmapAdapter listAdapter;
|
private LocalOpenstreetmapAdapter listAdapter;
|
||||||
|
|
||||||
|
@ -94,6 +98,8 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
createMenuItem(menu, BACKUP_ID, R.string.local_osm_changes_backup, R.drawable.ic_action_gsave_light, R.drawable.ic_action_gsave_dark,
|
createMenuItem(menu, BACKUP_ID, R.string.local_osm_changes_backup, R.drawable.ic_action_gsave_light, R.drawable.ic_action_gsave_dark,
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
|
createMenuItem(menu, DELETE_ID, R.string.local_osm_changes_delete_all, R.drawable.ic_action_gdiscard_light, R.drawable.ic_action_gdiscard_dark,
|
||||||
|
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +112,29 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
|
||||||
} else if (item.getItemId() == BACKUP_ID) {
|
} else if (item.getItemId() == BACKUP_ID) {
|
||||||
new BackupOpenstreetmapPointAsyncTask().execute(dataPoints.toArray(new OsmPoint[0]));
|
new BackupOpenstreetmapPointAsyncTask().execute(dataPoints.toArray(new OsmPoint[0]));
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == DELETE_ID) {
|
||||||
|
Builder b = new AlertDialog.Builder(this);
|
||||||
|
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, dataPoints.size()));
|
||||||
|
b.setPositiveButton(R.string.default_buttons_delete, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Iterator<OsmPoint> it = dataPoints.iterator();
|
||||||
|
while(it.hasNext()) {
|
||||||
|
OsmPoint info = it.next();
|
||||||
|
if (info.getGroup() == OsmPoint.Group.POI) {
|
||||||
|
dbpoi.deletePOI((OpenstreetmapPoint) info);
|
||||||
|
} else if (info.getGroup() == OsmPoint.Group.BUG) {
|
||||||
|
dbbug.deleteAllBugModifications((OsmNotesPoint) info);
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
listAdapter.delete(info);
|
||||||
|
}
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
|
b.show();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue