From 674f55235640ad27bb49c9bd97b54b72195878b7 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 9 Nov 2015 10:27:55 +0100 Subject: [PATCH 1/2] fix close changeset --- .../src/net/osmand/plus/osmedit/EditPoiDialogFragment.java | 1 - .../plus/osmedit/UploadOpenstreetmapPointAsyncTask.java | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 5ec24ac042..a418d8289f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -570,7 +570,6 @@ public class EditPoiDialogFragment extends DialogFragment { } } - // TODO: 8/28/15 Move to helper public static class ShowDeleteDialogAsyncTask extends AsyncTask { private final OpenstreetmapUtil openstreetmapUtil; private final AppCompatActivity activity; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java index 354caeba39..5ec20b55d5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java @@ -45,6 +45,7 @@ public class UploadOpenstreetmapPointAsyncTask protected Map doInBackground(OsmPoint... points) { Map loadErrorsMap = new HashMap<>(); + boolean uploaded = false; for (OsmPoint point : points) { if (interruptUploading) break; @@ -56,8 +57,9 @@ public class UploadOpenstreetmapPointAsyncTask entityInfo = remotepoi.loadNode(p.getEntity()); } Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, - p.getComment(), closeChangeSet); + p.getComment(), false); if (n != null) { + uploaded = true; plugin.getDBPOI().deletePOI(p); publishProgress(p); } @@ -79,6 +81,9 @@ public class UploadOpenstreetmapPointAsyncTask loadErrorsMap.put(point, errorMessage); } } + if(uploaded) { + remotepoi.closeChangeSet(); + } return loadErrorsMap; } From 9dbdbaac1dde5865d51b01dc97eaffe11f2a082f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 9 Nov 2015 10:33:26 +0100 Subject: [PATCH 2/2] Fix poi --- .../osmand/plus/osmedit/EditPoiDialogFragment.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index a418d8289f..05f50a2b4f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -92,8 +92,6 @@ public class EditPoiDialogFragment extends DialogFragment { OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); - } else if (!settings.isInternetConnectionAvailable(true)) { - mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); } else { mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity); } @@ -249,7 +247,8 @@ public class EditPoiDialogFragment extends DialogFragment { poiTypeEditText.setText(editPoiData.amenity.getSubType()); Button saveButton = (Button) view.findViewById(R.id.saveButton); - saveButton.setText(R.string.shared_string_save); + saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil? R.string.shared_string_upload : + R.string.shared_string_save); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -516,11 +515,10 @@ public class EditPoiDialogFragment extends DialogFragment { final OsmandSettings settings = ((OsmandApplication) activity.getApplication()) .getSettings(); final OpenstreetmapUtil openstreetmapUtilToLoad; - if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { + if (//settings.OFFLINE_EDITION.get() || + !settings.isInternetConnectionAvailable(true)) { OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity); - } else if (!settings.isInternetConnectionAvailable(true)) { - openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); } else { openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); } @@ -596,6 +594,7 @@ public class EditPoiDialogFragment extends DialogFragment { AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show(); return; } + // FIXME give back alert dialog and use openstreetmapUtil field! DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(), "DeletePoiDialogFragment"); }