Added confirmation dialogs for osm edits in my places

This commit is contained in:
Denis 2015-03-16 17:58:34 +02:00
parent bb8d6e40ce
commit 1c30562464
3 changed files with 77 additions and 71 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="local_osm_changes_upload_all_confirm">You are going to upload %1$d changes to osm. Are you sure?</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="shared_string_go">Go</string>

View file

@ -1,35 +1,5 @@
package net.osmand.plus.osmedit;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.EntityParser;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.DialogProvider;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OpeningHoursView;
import net.osmand.util.OpeningHoursParser;
import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import net.osmand.util.OpeningHoursParser.OpeningHours;
import net.osmand.util.OpeningHoursParser.OpeningHoursRule;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -60,6 +30,37 @@ import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.EntityParser;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.DialogProvider;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OpeningHoursView;
import net.osmand.util.OpeningHoursParser;
import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import net.osmand.util.OpeningHoursParser.OpeningHours;
import net.osmand.util.OpeningHoursParser.OpeningHoursRule;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class EditingPOIActivity implements DialogProvider {
private final Activity activity;

View file

@ -93,8 +93,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
toUpload = dataPoints.toArray(new OsmPoint[0]);
showUploadItemsDialog();
uploadItems(dataPoints.toArray(new OsmPoint[0]));
return true;
}
});
@ -116,32 +115,36 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, dataPoints.size()));
b.setPositiveButton(R.string.shared_string_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.shared_string_cancel, null);
b.show();
deleteItems(dataPoints);
return true;
}
});
}
private void deleteItems(final ArrayList<OsmPoint> points) {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, points.size()));
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Iterator<OsmPoint> it = points.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.shared_string_cancel, null);
b.show();
}
@Override
public void onResume() {
super.onResume();
@ -249,21 +252,9 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, 1));
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (info.getGroup() == OsmPoint.Group.POI) {
dbpoi.deletePOI((OpenstreetmapPoint) info);
} else if (info.getGroup() == OsmPoint.Group.BUG) {
dbbug.deleteAllBugModifications((OsmNotesPoint) info);
}
listAdapter.delete(info);
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
ArrayList<OsmPoint> points = new ArrayList<OsmPoint>();
points.add(info);
deleteItems(new ArrayList<OsmPoint>(points));
return true;
}
@ -273,8 +264,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
toUpload = new OsmPoint[]{info};
showUploadItemsDialog();
uploadItems(new OsmPoint[]{info});
return true;
}
});
@ -285,7 +275,21 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
return (OsmandApplication) getActivity().getApplication();
}
private void showUploadItemsDialog() {
private void uploadItems(final OsmPoint[] items){
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, items.length));
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
toUpload = items;
showUploadItemsProgressDialog();
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
}
private void showUploadItemsProgressDialog() {
dialog = ProgressImplementation.createProgressDialog(
getActivity(),
getString(R.string.uploading),