This commit is contained in:
GaidamakUA 2015-11-09 11:36:25 +02:00
commit aad04aa940
2 changed files with 11 additions and 7 deletions

View file

@ -92,8 +92,6 @@ public class EditPoiDialogFragment extends DialogFragment {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else if (!settings.isInternetConnectionAvailable(true)) {
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else { } else {
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity); mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
} }
@ -249,7 +247,8 @@ public class EditPoiDialogFragment extends DialogFragment {
poiTypeEditText.setText(editPoiData.amenity.getSubType()); poiTypeEditText.setText(editPoiData.amenity.getSubType());
Button saveButton = (Button) view.findViewById(R.id.saveButton); 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() { saveButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -515,11 +514,10 @@ public class EditPoiDialogFragment extends DialogFragment {
final OsmandSettings settings = ((OsmandApplication) activity.getApplication()) final OsmandSettings settings = ((OsmandApplication) activity.getApplication())
.getSettings(); .getSettings();
final OpenstreetmapUtil openstreetmapUtilToLoad; 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); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity); openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity);
} else if (!settings.isInternetConnectionAvailable(true)) {
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
} else { } else {
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
} }
@ -595,6 +593,7 @@ public class EditPoiDialogFragment extends DialogFragment {
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
return; return;
} }
// FIXME give back alert dialog and use openstreetmapUtil field!
DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(), DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(),
"DeletePoiDialogFragment"); "DeletePoiDialogFragment");
} }

View file

@ -45,6 +45,7 @@ public class UploadOpenstreetmapPointAsyncTask
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) { protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
Map<OsmPoint, String> loadErrorsMap = new HashMap<>(); Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
boolean uploaded = false;
for (OsmPoint point : points) { for (OsmPoint point : points) {
if (interruptUploading) if (interruptUploading)
break; break;
@ -56,8 +57,9 @@ public class UploadOpenstreetmapPointAsyncTask
entityInfo = remotepoi.loadNode(p.getEntity()); entityInfo = remotepoi.loadNode(p.getEntity());
} }
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo,
p.getComment(), closeChangeSet); p.getComment(), false);
if (n != null) { if (n != null) {
uploaded = true;
plugin.getDBPOI().deletePOI(p); plugin.getDBPOI().deletePOI(p);
publishProgress(p); publishProgress(p);
} }
@ -79,6 +81,9 @@ public class UploadOpenstreetmapPointAsyncTask
loadErrorsMap.put(point, errorMessage); loadErrorsMap.put(point, errorMessage);
} }
} }
if(uploaded) {
remotepoi.closeChangeSet();
}
return loadErrorsMap; return loadErrorsMap;
} }