Close changeSet option added
This commit is contained in:
parent
56b0ace080
commit
b16c8616f6
4 changed files with 15 additions and 65 deletions
|
@ -1,11 +1,9 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
@ -18,11 +16,8 @@ import android.widget.EditText;
|
|||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.edit.EntityInfo;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
|
@ -30,7 +25,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -130,20 +124,21 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: 9/7/15 Redesign osm notes.
|
||||
private void uploadItem(final OsmPoint point) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, 1));
|
||||
b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
showProgressDialog(point);
|
||||
showProgressDialog(point, false);
|
||||
}
|
||||
});
|
||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
b.show();
|
||||
}
|
||||
|
||||
private void showProgressDialog(OsmPoint point) {
|
||||
private void showProgressDialog(OsmPoint point, boolean closeChangeSet) {
|
||||
OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity());
|
||||
OsmPoint[] toUpload = new OsmPoint[]{point};
|
||||
OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
||||
|
@ -169,7 +164,7 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
|||
}
|
||||
};
|
||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
|
||||
listener, plugin, remotepoi, remotebug, toUpload.length);
|
||||
listener, plugin, remotepoi, remotebug, toUpload.length, closeChangeSet);
|
||||
uploadTask.execute(toUpload);
|
||||
dialog.show();
|
||||
}
|
||||
|
@ -229,61 +224,12 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
|||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final OpenstreetmapRemoteUtil openstreetmapRemoteUtil
|
||||
= new OpenstreetmapRemoteUtil(getActivity());
|
||||
settings.USER_NAME.set(userNameEditText.getText().toString());
|
||||
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
|
||||
final String message = messageEditText.getText().toString();
|
||||
final boolean closeChangeSet = closeChangeSetCheckBox.isChecked();
|
||||
final Activity activity = getActivity();
|
||||
int actionTypeMessageId = -1;
|
||||
switch (poi.getAction()) {
|
||||
case CREATE: actionTypeMessageId = R.string.poi_action_add;
|
||||
break;
|
||||
case MODIFY: actionTypeMessageId = R.string.poi_action_change;
|
||||
break;
|
||||
case DELETE: actionTypeMessageId = R.string.poi_action_delete;
|
||||
break;
|
||||
}
|
||||
final String resultMessage =
|
||||
getResources().getString(actionTypeMessageId);
|
||||
final String successTemplate = getResources().getString(
|
||||
R.string.poi_action_succeded_template);
|
||||
|
||||
new AsyncTask<Void, Void, EntityInfo>() {
|
||||
|
||||
@Override
|
||||
protected EntityInfo doInBackground(Void... params) {
|
||||
return openstreetmapRemoteUtil.loadNode(poi.getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(EntityInfo entityInfo) {
|
||||
EditPoiFragment.commitNode(poi.getAction(), poi.getEntity(),
|
||||
entityInfo,
|
||||
message,
|
||||
closeChangeSet,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessibleToast.makeText(
|
||||
activity,
|
||||
MessageFormat.format(
|
||||
successTemplate,
|
||||
resultMessage),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity)
|
||||
.getMapView().refreshMap(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
activity, openstreetmapRemoteUtil);
|
||||
}
|
||||
}.execute();
|
||||
// poi.setComment(messageEditText.getText().toString());
|
||||
// ((DashOsmEditsFragment) getParentFragment()).showProgressDialog(poi);
|
||||
poi.setComment(messageEditText.getText().toString());
|
||||
((DashOsmEditsFragment) getParentFragment()).showProgressDialog(poi,
|
||||
closeChangeSetCheckBox.isChecked());
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
|
|
@ -501,7 +501,7 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
|||
OsmEditsUploadListener listener = new OsmEditsUploadListenerHelper(getActivity(),
|
||||
getString(R.string.local_openstreetmap_were_uploaded));
|
||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
||||
dialog, listener, plugin, remotepoi, remotebug, toUpload.length);
|
||||
dialog, listener, plugin, remotepoi, remotebug, toUpload.length, false);
|
||||
uploadTask.execute(toUpload);
|
||||
|
||||
dialog.show();
|
||||
|
|
|
@ -94,7 +94,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
|
|||
resources.getString(R.string.local_openstreetmap_uploading),
|
||||
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
||||
dialog, helper, plugin, remotepoi, remotebug, toUpload.length);
|
||||
dialog, helper, plugin, remotepoi, remotebug, toUpload.length, false);
|
||||
uploadTask.execute(toUpload);
|
||||
|
||||
dialog.show();
|
||||
|
|
|
@ -23,19 +23,22 @@ public class UploadOpenstreetmapPointAsyncTask
|
|||
private boolean interruptUploading = false;
|
||||
private OsmEditsUploadListener listener;
|
||||
private OsmEditingPlugin plugin;
|
||||
private final boolean closeChangeSet;
|
||||
|
||||
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,
|
||||
OsmEditsUploadListener listener,
|
||||
OsmEditingPlugin plugin,
|
||||
OpenstreetmapRemoteUtil remotepoi,
|
||||
OsmBugsRemoteUtil remotebug,
|
||||
int listSize) {
|
||||
int listSize,
|
||||
boolean closeChangeSet) {
|
||||
this.progress = progress;
|
||||
this.plugin = plugin;
|
||||
this.remotepoi = remotepoi;
|
||||
this.remotebug = remotebug;
|
||||
this.listSize = listSize;
|
||||
this.listener = listener;
|
||||
this.closeChangeSet = closeChangeSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +55,8 @@ public class UploadOpenstreetmapPointAsyncTask
|
|||
if (OsmPoint.Action.CREATE != p.getAction()) {
|
||||
entityInfo = remotepoi.loadNode(p.getEntity());
|
||||
}
|
||||
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
|
||||
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo,
|
||||
p.getComment(), closeChangeSet);
|
||||
if (n != null) {
|
||||
plugin.getDBPOI().deletePOI(p);
|
||||
publishProgress(p);
|
||||
|
|
Loading…
Reference in a new issue