Refactor error handling and poi bug creation

This commit is contained in:
Victor Shcherb 2015-11-16 00:58:29 +01:00
parent 9bdb0e5355
commit 0314ef16e6
10 changed files with 116 additions and 148 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). 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="osm_save_offline">Save offline</string>
<string name="osm_edit_modified_poi">Modified OSM POI</string> <string name="osm_edit_modified_poi">Modified OSM POI</string>
<string name="osm_edit_deleted_poi">Deleted OSM POI</string> <string name="osm_edit_deleted_poi">Deleted OSM POI</string>
<string name="context_menu_item_open_note">Open OSM Note</string> <string name="context_menu_item_open_note">Open OSM Note</string>

View file

@ -29,9 +29,9 @@ public class OsmBugMenuController extends MenuController {
if (plugin != null) { if (plugin != null) {
OpenStreetNote bg = getBug(); OpenStreetNote bg = getBug();
if(bg.isOpened()) { if(bg.isOpened()) {
plugin.getBugsLayer(getMapActivity()).commentBug(bg); plugin.getBugsLayer(getMapActivity()).commentBug(bg, "");
} else { } else {
plugin.getBugsLayer(getMapActivity()).reopenBug(bg); plugin.getBugsLayer(getMapActivity()).reopenBug(bg, "");
} }
} }
} }
@ -47,7 +47,7 @@ public class OsmBugMenuController extends MenuController {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
if (plugin != null) { if (plugin != null) {
plugin.getBugsLayer(getMapActivity()).closeBug(getBug()); plugin.getBugsLayer(getMapActivity()).closeBug(getBug(), "");
} }
} }
}; };

View file

@ -23,11 +23,12 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.DialogProvider; import net.osmand.plus.activities.DialogProvider;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.osmedit.OsmBugsUtil.Action;
import net.osmand.plus.osmedit.OsmBugsUtil.OsmBugResult; import net.osmand.plus.osmedit.OsmBugsUtil.OsmBugResult;
import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -65,6 +66,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
private final MapActivity activity; private final MapActivity activity;
protected static final String KEY_BUG = "bug"; protected static final String KEY_BUG = "bug";
protected static final String KEY_TEXT = "text";
protected static final String KEY_ACTION = "action"; protected static final String KEY_ACTION = "action";
private static final int DIALOG_BUG = 305; private static final int DIALOG_BUG = 305;
private static Bundle dialogBundle = new Bundle(); private static Bundle dialogBundle = new Bundle();
@ -74,7 +76,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin){ public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin){
this.activity = activity; this.activity = activity;
this.plugin = plugin; this.plugin = plugin;
local = new OsmBugsLocalUtil(activity, plugin.getDBBug()); local = plugin.getOsmNotesLocalUtil();
} }
public OsmBugsUtil getOsmbugsUtil(OpenStreetNote bug) { public OsmBugsUtil getOsmbugsUtil(OpenStreetNote bug) {
@ -320,16 +322,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
@Override @Override
protected OsmBugResult doInBackground(Void... params) { protected OsmBugResult doInBackground(Void... params) {
osmbugsUtil = getOsmbugsUtil(bug); osmbugsUtil = getOsmbugsUtil(bug);
if(action == Action.REOPEN) { OsmNotesPoint pnt = new OsmNotesPoint();
return osmbugsUtil.reopenBug(bug.getLatitude(), bug.getLongitude(), bug.getId(), text); pnt.setId(bug.getId());
} else if(action == Action.MODIFY) { pnt.setLatitude(bug.getLatitude());
return osmbugsUtil.addingComment(bug.getLatitude(), bug.getLongitude(), bug.getId(), text); pnt.setLongitude(bug.getLongitude());
} else if(action == Action.CLOSE) { return osmbugsUtil.commit(pnt, text, action);
return osmbugsUtil.closingBug(bug.getLatitude(), bug.getLongitude(), bug.getId(), text);
} else if(action == Action.CREATE) {
return osmbugsUtil.createNewBug(bug.getLatitude(), bug.getLongitude(), text);
}
return null;
} }
protected void onPostExecute(OsmBugResult obj) { protected void onPostExecute(OsmBugResult obj) {
if (obj != null && obj.warning == null) { if (obj != null && obj.warning == null) {
@ -344,7 +341,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
AccessibleToast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show();
} else if(action == Action.MODIFY) { } else if(action == Action.MODIFY) {
AccessibleToast.makeText(activity, R.string.osb_comment_dialog_success, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, R.string.osb_comment_dialog_success, Toast.LENGTH_LONG).show();
} else if(action == Action.CLOSE) { } else if(action == Action.DELETE) {
AccessibleToast.makeText(activity, R.string.osn_close_dialog_success, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, R.string.osn_close_dialog_success, Toast.LENGTH_LONG).show();
} else if(action == Action.CREATE) { } else if(action == Action.CREATE) {
AccessibleToast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show();
@ -356,10 +353,15 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
int r = R.string.osb_comment_dialog_error; int r = R.string.osb_comment_dialog_error;
if(action == Action.REOPEN) { if(action == Action.REOPEN) {
r = R.string.osn_add_dialog_error; r = R.string.osn_add_dialog_error;
} else if(action == Action.CLOSE) { reopenBug(bug, text);
} else if(action == Action.DELETE) {
r = R.string.osn_close_dialog_error; r = R.string.osn_close_dialog_error;
closeBug(bug, text);
} else if(action == Action.CREATE) { } else if(action == Action.CREATE) {
r = R.string.osn_add_dialog_error; r = R.string.osn_add_dialog_error;
openBug(bug.getLatitude(), bug.getLongitude(), text);
} else {
commentBug(bug, text);
} }
AccessibleToast.makeText(activity, activity.getResources().getString(r) + "\n" + obj, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity, activity.getResources().getString(r) + "\n" + obj, Toast.LENGTH_LONG).show();
} }
@ -373,39 +375,43 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
OpenStreetNote bug = new OpenStreetNote(); OpenStreetNote bug = new OpenStreetNote();
bug.setLatitude(latitude); bug.setLatitude(latitude);
bug.setLongitude(longitude); bug.setLongitude(longitude);
bug.comments.add(message);
dialogBundle = new Bundle(); dialogBundle = new Bundle();
dialogBundle.putSerializable(KEY_BUG, bug); dialogBundle.putSerializable(KEY_BUG, bug);
dialogBundle.putSerializable(KEY_ACTION, OsmBugsUtil.Action.CREATE.name()); dialogBundle.putSerializable(KEY_TEXT, message);
dialogBundle.putSerializable(KEY_ACTION, Action.CREATE.name());
activity.showDialog(DIALOG_BUG); activity.showDialog(DIALOG_BUG);
} }
public void closeBug(final OpenStreetNote bug){ public void closeBug(final OpenStreetNote bug, String txt){
dialogBundle = new Bundle(); dialogBundle = new Bundle();
dialogBundle.putSerializable(KEY_BUG, bug); dialogBundle.putSerializable(KEY_BUG, bug);
dialogBundle.putSerializable(KEY_ACTION, OsmBugsUtil.Action.CLOSE.name()); dialogBundle.putSerializable(KEY_TEXT, txt);
dialogBundle.putSerializable(KEY_ACTION, Action.DELETE.name());
activity.showDialog(DIALOG_BUG); activity.showDialog(DIALOG_BUG);
} }
public void reopenBug(final OpenStreetNote bug){ public void reopenBug(final OpenStreetNote bug, String txt){
dialogBundle = new Bundle(); dialogBundle = new Bundle();
dialogBundle.putSerializable(KEY_BUG, bug); dialogBundle.putSerializable(KEY_BUG, bug);
dialogBundle.putSerializable(KEY_ACTION, OsmBugsUtil.Action.REOPEN.name()); dialogBundle.putSerializable(KEY_TEXT, txt);
dialogBundle.putSerializable(KEY_ACTION, Action.REOPEN.name());
activity.showDialog(DIALOG_BUG); activity.showDialog(DIALOG_BUG);
} }
public void commentBug(final OpenStreetNote bug){ public void commentBug(final OpenStreetNote bug, String txt){
dialogBundle = new Bundle(); dialogBundle = new Bundle();
dialogBundle.putSerializable(KEY_BUG, bug); dialogBundle.putSerializable(KEY_BUG, bug);
dialogBundle.putSerializable(KEY_ACTION, OsmBugsUtil.Action.MODIFY.name()); dialogBundle.putSerializable(KEY_TEXT, txt);
dialogBundle.putSerializable(KEY_ACTION, Action.MODIFY.name());
activity.showDialog(DIALOG_BUG); activity.showDialog(DIALOG_BUG);
} }
private void prepareBugDialog(Bundle args, Dialog dialog) { private void prepareBugDialog(Bundle args, Dialog dialog) {
final OpenStreetNote bug = (OpenStreetNote) args.getSerializable(KEY_BUG); final OpenStreetNote bug = (OpenStreetNote) args.getSerializable(KEY_BUG);
final Action action = OsmBugsUtil.Action.valueOf((String) args.getSerializable(KEY_ACTION)); final Action action = Action.valueOf((String) args.getSerializable(KEY_ACTION));
String text =(String) args.getSerializable(KEY_TEXT);
int title ; int title ;
if(action == Action.CLOSE) { if(action == Action.DELETE) {
title = R.string.osn_close_dialog_title; title = R.string.osn_close_dialog_title;
} else if(action == Action.MODIFY) { } else if(action == Action.MODIFY) {
title = R.string.osn_comment_dialog_title; title = R.string.osn_comment_dialog_title;
@ -431,8 +437,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
((EditText)view.findViewById(R.id.userNameEditText)).setText(getUserName()); ((EditText)view.findViewById(R.id.userNameEditText)).setText(getUserName());
((EditText)view.findViewById(R.id.passwordEditText)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_PASSWORD.get()); ((EditText)view.findViewById(R.id.passwordEditText)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_PASSWORD.get());
} }
if(action == Action.CREATE && bug.comments.size() > 0) { if(!Algorithms.isEmpty(text)) {
((EditText)view.findViewById(R.id.messageEditText)).setText(bug.comments.get(0)); ((EditText)view.findViewById(R.id.messageEditText)).setText(text);
} }
AndroidUtils.softKeyboardDelayed((EditText) view.findViewById(R.id.messageEditText)); AndroidUtils.softKeyboardDelayed((EditText) view.findViewById(R.id.messageEditText));
btn.setOnClickListener(new View.OnClickListener() { btn.setOnClickListener(new View.OnClickListener() {

View file

@ -4,28 +4,33 @@ package net.osmand.plus.osmedit;
import java.util.List; import java.util.List;
import android.content.Context; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.osmedit.OsmPoint.Action;
public class OsmBugsLocalUtil implements OsmBugsUtil { public class OsmBugsLocalUtil implements OsmBugsUtil {
private final Context ctx;
private final OsmBugsDbHelper db; private final OsmBugsDbHelper db;
public OsmBugsLocalUtil(Context uiContext, OsmBugsDbHelper db) { public OsmBugsLocalUtil(OsmandApplication app, OsmBugsDbHelper db) {
this.ctx = uiContext;
this.db = db; this.db = db;
} }
@Override @Override
public OsmBugResult createNewBug(double latitude, double longitude, String text){ public OsmBugResult commit(OsmNotesPoint point, String text, Action action) {
OsmNotesPoint p = new OsmNotesPoint(); if(action == OsmPoint.Action.CREATE) {
p.setId(Math.min(-2, db.getMinID() -1)); point.setId(Math.min(-2, db.getMinID() -1));
p.setText(text); point.setText(text);
p.setLatitude(latitude); point.setAction(action);
p.setLongitude(longitude); } else {
p.setAction(OsmPoint.Action.CREATE); OsmNotesPoint pnt = new OsmNotesPoint();
return wrap(p, db.addOsmbugs(p)); pnt.setId(point.getId());
pnt.setLatitude(point.getLatitude());
pnt.setLongitude(point.getLongitude());
pnt.setAction(action);
pnt.setText(text);
point = pnt;
}
return wrap(point, db.addOsmbugs(point));
} }
private OsmBugResult wrap(OsmNotesPoint p, boolean success) { private OsmBugResult wrap(OsmNotesPoint p, boolean success) {
@ -35,41 +40,8 @@ public class OsmBugsLocalUtil implements OsmBugsUtil {
return s; return s;
} }
@Override
public OsmBugResult reopenBug(double latitude, double longitude, long id, String text){
OsmNotesPoint p = new OsmNotesPoint();
p.setId(id);
p.setText(text);
p.setLatitude(latitude);
p.setLongitude(longitude);
p.setAction(OsmPoint.Action.REOPEN);
return wrap(p, db.addOsmbugs(p));
}
public List<OsmNotesPoint> getOsmbugsPoints() { public List<OsmNotesPoint> getOsmbugsPoints() {
return db.getOsmbugsPoints(); return db.getOsmbugsPoints();
} }
@Override
public OsmBugResult addingComment(double latitude, double longitude, long id, String text){
OsmNotesPoint p = new OsmNotesPoint();
p.setId(id);
p.setText(text);
p.setLatitude(latitude);
p.setLongitude(longitude);
p.setAction(OsmPoint.Action.MODIFY);
return wrap(p, db.addOsmbugs(p));
}
@Override
public OsmBugResult closingBug(double latitude, double longitude, long id, String text){
OsmNotesPoint p = new OsmNotesPoint();
p.setId(id);
p.setText(text);
p.setLatitude(latitude);
p.setLongitude(longitude);
p.setAction(OsmPoint.Action.DELETE);
return wrap(p, db.addOsmbugs(p));
}
} }

View file

@ -1,5 +1,6 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.osm.io.Base64; import net.osmand.osm.io.Base64;
import net.osmand.osm.io.NetworkUtils; import net.osmand.osm.io.NetworkUtils;
@ -7,6 +8,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -40,41 +42,31 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
} }
@Override @Override
public OsmBugResult createNewBug(double latitude, double longitude, String text) { public OsmBugResult commit(OsmNotesPoint point, String text, Action action) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(getNotesApi()).append("?"); //$NON-NLS-1$ String msg = "";
b.append("lat=").append(latitude); //$NON-NLS-1$ if(action == OsmPoint.Action.CREATE) {
b.append("&lon=").append(longitude); //$NON-NLS-1$ b.append(getNotesApi()).append("?"); //$NON-NLS-1$
b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ b.append("lat=").append(point.getLatitude()); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "creating bug"); //$NON-NLS-1$ b.append("&lon=").append(point.getLongitude()); //$NON-NLS-1$
} b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
msg = "creating bug";
@Override } else {
public OsmBugResult addingComment(double latitude, double longitude, long id, String text) { b.append(getNotesApi()).append("/");
StringBuilder b = new StringBuilder(); b.append(point.getId()); //$NON-NLS-1$
b.append(getNotesApi()).append("/"); if(action == OsmPoint.Action.REOPEN) {
b.append(id); //$NON-NLS-1$ b.append("/reopen");
b.append("/comment?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ msg = "reopen note";
return editingPOI(b.toString(), "POST", "adding comment"); //$NON-NLS-1$ } else if(action == OsmPoint.Action.MODIFY) {
} b.append("/comment");
msg = "adding comment";
@Override } else if(action == OsmPoint.Action.DELETE) {
public OsmBugResult reopenBug(double latitude, double longitude, long id, String text){ b.append("/close");
StringBuilder b = new StringBuilder(); msg = "close note";
b.append(getNotesApi()).append("/"); //$NON-NLS-1$ }
b.append(id); //$NON-NLS-1$ b.append("?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
b.append("/reopen?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ }
return editingPOI(b.toString(), "POST", "reopen bug"); //$NON-NLS-1$ return editingPOI(b.toString(), "POST", msg);
}
@Override
public OsmBugResult closingBug(double latitude, double longitude, long id, String text) {
StringBuilder b = new StringBuilder();
b.append(getNotesApi()).append("/");
b.append(id); //$NON-NLS-1$
b.append("/close?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "close bug"); //$NON-NLS-1$
} }
private OsmBugResult editingPOI(String url, String requestMethod, String userOperation) { private OsmBugResult editingPOI(String url, String requestMethod, String userOperation) {

View file

@ -1,19 +1,14 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
public interface OsmBugsUtil { import net.osmand.plus.osmedit.OsmPoint.Action;
public static enum Action {CREATE, MODIFY, CLOSE, REOPEN}; public interface OsmBugsUtil {
public static class OsmBugResult { public static class OsmBugResult {
OsmNotesPoint local; OsmNotesPoint local;
String warning; String warning;
} }
public OsmBugResult createNewBug(double latitude, double longitude, String text); public OsmBugResult commit(OsmNotesPoint bug, String text, Action action);
public OsmBugResult addingComment(double latitude, double longitude, long id, String text);
public OsmBugResult reopenBug(double latitude, double longitude, long id, String text);
public OsmBugResult closingBug(double latitude, double longitude, long id, String text);
} }

View file

@ -1,18 +1,7 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.app.Activity; import java.util.List;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
@ -38,7 +27,19 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.util.List; import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class OsmEditingPlugin extends OsmandPlugin { public class OsmEditingPlugin extends OsmandPlugin {
@ -50,7 +51,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
OsmBugsDbHelper dbbug; OsmBugsDbHelper dbbug;
OpenstreetmapLocalUtil localUtil; OpenstreetmapLocalUtil localUtil;
OpenstreetmapRemoteUtil remoteUtil; OpenstreetmapRemoteUtil remoteUtil;
private OsmBugsRemoteUtil remoteNotesUtil; OsmBugsRemoteUtil remoteNotesUtil;
OsmBugsLocalUtil localNotesUtil;
public OsmEditingPlugin(OsmandApplication app) { public OsmEditingPlugin(OsmandApplication app) {
this.app = app; this.app = app;
@ -90,6 +92,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
return remoteNotesUtil; return remoteNotesUtil;
} }
public OsmBugsLocalUtil getOsmNotesLocalUtil() {
if(localNotesUtil == null) {
localNotesUtil = new OsmBugsLocalUtil(app, dbbug);
}
return localNotesUtil;
}

View file

@ -22,13 +22,13 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.ProgressImplementation; import net.osmand.plus.ProgressImplementation;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.osmedit.OsmPoint.Action;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -111,8 +111,8 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
builder.setTitle(getResources().getString(R.string.failed_to_upload)) builder.setTitle(getResources().getString(R.string.failed_to_upload))
.setMessage(MessageFormat.format( .setMessage(MessageFormat.format(
getResources().getString(R.string.error_message_pattern), errorMessage)) getResources().getString(R.string.error_message_pattern), errorMessage))
.setPositiveButton(R.string.shared_string_ok, null) .setPositiveButton(R.string.shared_string_ok, null);
.setNeutralButton(getResources().getString(R.string.delete_change), builder.setNeutralButton(getResources().getString(R.string.delete_change),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(@Nullable DialogInterface dialog, int id) { public void onClick(@Nullable DialogInterface dialog, int id) {
OsmEditingPlugin plugin = OsmEditingPlugin plugin =

View file

@ -62,16 +62,7 @@ public class UploadOpenstreetmapPointAsyncTask
loadErrorsMap.put(point, n != null ? null : "Unknown problem"); loadErrorsMap.put(point, n != null ? null : "Unknown problem");
} else if (point.getGroup() == OsmPoint.Group.BUG) { } else if (point.getGroup() == OsmPoint.Group.BUG) {
OsmNotesPoint p = (OsmNotesPoint) point; OsmNotesPoint p = (OsmNotesPoint) point;
String errorMessage = null; String errorMessage = remotebug.commit(p, p.getText(), p.getAction()).warning;
if (p.getAction() == OsmPoint.Action.CREATE) {
errorMessage = remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText()).warning;
} else if (p.getAction() == OsmPoint.Action.MODIFY) {
errorMessage = remotebug.addingComment(p.getLatitude(), p.getLongitude(), p.getId(), p.getText()).warning;
} else if (p.getAction() == OsmPoint.Action.REOPEN) {
errorMessage = remotebug.reopenBug(p.getLatitude(), p.getLongitude(), p.getId(), p.getText()).warning;
} else if (p.getAction() == OsmPoint.Action.DELETE) {
errorMessage = remotebug.closingBug(p.getLatitude(), p.getLongitude(), p.getId(), p.getText()).warning;
}
if (errorMessage == null) { if (errorMessage == null) {
plugin.getDBBug().deleteAllBugModifications(p); plugin.getDBBug().deleteAllBugModifications(p);
publishProgress(p); publishProgress(p);

View file

@ -94,6 +94,8 @@ public class SendPoiDialogFragment extends DialogFragment {
} }
public interface ProgressDialogPoiUploader { public interface ProgressDialogPoiUploader {
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet); void showProgressDialog(OsmPoint[] points, boolean closeChangeSet);
} }
} }