From 042c22d408f8d8c00b27736014073bcdde971e9e Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 3 Oct 2017 12:11:18 +0300 Subject: [PATCH 1/7] Add possibility to modify osm note --- OsmAnd/res/values/strings.xml | 3 + .../osmand/plus/osmedit/OsmBugsDbHelper.java | 13 +++++ .../net/osmand/plus/osmedit/OsmBugsLayer.java | 56 ++++++++++++++++++- .../osmand/plus/osmedit/OsmBugsLocalUtil.java | 14 ++++- .../plus/osmedit/OsmBugsRemoteUtil.java | 5 ++ .../net/osmand/plus/osmedit/OsmBugsUtil.java | 2 + .../osmand/plus/osmedit/OsmEditingPlugin.java | 22 +++++++- 7 files changed, 110 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a90cd5f178..131ce3ebb3 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,9 @@ 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 --> + Exception occurred: note was not modified + Modify note + Modify OSM note Markers Coordinates format Use system keyboard diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java index c2a84f8256..d689349af4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java @@ -47,6 +47,19 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper { return cache; } + public boolean updateOsmBug(long id, String text) { + SQLiteDatabase db = getWritableDatabase(); + if (db != null) { + db.execSQL("UPDATE " + OSMBUGS_TABLE_NAME + + " SET " + OSMBUGS_COL_TEXT + " = ? " + + "WHERE " + OSMBUGS_COL_ID + " = ?", new Object[]{text, id}); + checkOsmbugsPoints(db); + db.close(); + return true; + } + return false; + } + public boolean addOsmbugs(OsmNotesPoint p) { SQLiteDatabase db = getWritableDatabase(); if (db != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index cf1567c6ac..d45beba47e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -304,6 +304,30 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider return bugs; } + private void asyncActionTask(final OsmNotesPoint point, final String text) { + AsyncTask task = new AsyncTask() { + + @Override + protected OsmBugResult doInBackground(Void... params) { + return local.modify(point, text); + } + + protected void onPostExecute(OsmBugResult obj) { + if (obj != null && obj.warning == null) { + Toast.makeText(activity, R.string.osm_changes_added_to_local_edits, Toast.LENGTH_LONG).show(); + if (obj.local != null) { + PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_OSM_BUG, obj.local.getText()); + activity.getContextMenu().show(new LatLon(obj.local.getLatitude(), obj.local.getLongitude()), pd, obj.local); + } + clearCache(); + } else { + modifyBug(point); + Toast.makeText(activity, activity.getResources().getString(R.string.osn_modify_dialog_error) + "\n" + obj, Toast.LENGTH_LONG).show(); + } + } + }; + executeTaskInBackground(task); + } private void asyncActionTask(final OpenStreetNote bug, final String text, final Action action) { AsyncTask task = new AsyncTask() { @@ -378,7 +402,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider else showBugDialog(bug, Action.CREATE, message); } - public void closeBug(final OpenStreetNote bug, String txt) { showBugDialog(bug, Action.DELETE, txt); } @@ -391,6 +414,37 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider showBugDialog(bug, Action.MODIFY, txt); } + public void modifyBug(final OsmNotesPoint point) { + showBugDialog(point); + } + + private void showBugDialog(final OsmNotesPoint point) { + final View view = LayoutInflater.from(activity).inflate(R.layout.open_bug, null); + view.findViewById(R.id.user_name_field).setVisibility(View.GONE); + view.findViewById(R.id.userNameEditTextLabel).setVisibility(View.GONE); + view.findViewById(R.id.password_field).setVisibility(View.GONE); + view.findViewById(R.id.passwordEditTextLabel).setVisibility(View.GONE); + String text = point.getText(); + if (!Algorithms.isEmpty(text)) { + ((EditText) view.findViewById(R.id.message_field)).setText(text); + } + AndroidUtils.softKeyboardDelayed(view.findViewById(R.id.message_field)); + + final AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.shared_string_commit); + builder.setView(view); + builder.setPositiveButton(R.string.osn_modify_dialog_title, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String text = getMessageText(view); + activity.getContextMenu().close(); + asyncActionTask(point, text); + } + }); + builder.setNegativeButton(R.string.shared_string_cancel, null); + builder.create().show(); + } + private void showBugDialog(final OpenStreetNote bug, final Action action, String text) { int title; if (action == Action.DELETE) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java index 9caee4e678..54f6314f39 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java @@ -32,7 +32,19 @@ public class OsmBugsLocalUtil implements OsmBugsUtil { } return wrap(point, db.addOsmbugs(point)); } - + + @Override + public OsmBugResult modify(OsmNotesPoint point, String text) { + OsmNotesPoint pnt = new OsmNotesPoint(); + pnt.setId(point.getId()); + pnt.setLatitude(point.getLatitude()); + pnt.setLongitude(point.getLongitude()); + pnt.setAction(Action.MODIFY); + pnt.setText(text); + point = pnt; + return wrap(point, db.updateOsmBug(point.getId(), text)); + } + private OsmBugResult wrap(OsmNotesPoint p, boolean success) { OsmBugResult s = new OsmBugResult(); s.local = p; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java index 955a05ebcf..dc31f35b0b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java @@ -61,6 +61,11 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil { return commit(point, text, action, false); } + @Override + public OsmBugResult modify(OsmNotesPoint bug, String text) { + return null; + } + public OsmBugResult commit(OsmNotesPoint point, String text, Action action, boolean anonymous) { StringBuilder b = new StringBuilder(); String msg = ""; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java index bcc040722c..715eec2057 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java @@ -10,5 +10,7 @@ public interface OsmBugsUtil { } public OsmBugResult commit(OsmNotesPoint bug, String text, Action action); + + OsmBugResult modify(OsmNotesPoint bug, String text); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index b0795033b2..39190c82d2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -40,6 +40,7 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.util.List; +import java.util.Map; public class OsmEditingPlugin extends OsmandPlugin { @@ -181,6 +182,8 @@ public class OsmEditingPlugin extends OsmandPlugin { EditPoiDialogFragment.TAG); } else if (resId == R.string.context_menu_item_open_note) { openOsmNote(mapActivity, latitude, longitude); + } else if (resId == R.string.context_menu_item_modify_note) { + modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj); } else if (resId == R.string.poi_context_menu_delete) { new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity) .execute((Amenity) selectedObj); @@ -220,9 +223,15 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(listener) .createItem()); } - adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity) - .setIcon(R.drawable.ic_action_bug_dark) - .setListener(listener).createItem()); + if (selectedObj instanceof OsmNotesPoint) { + adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_modify_note, mapActivity) + .setIcon(R.drawable.ic_action_bug_dark) + .setListener(listener).createItem()); + } else { + adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity) + .setIcon(R.drawable.ic_action_bug_dark) + .setListener(listener).createItem()); + } } public void openOsmNote(MapActivity mapActivity, double latitude, double longitude) { @@ -239,6 +248,13 @@ public class OsmEditingPlugin extends OsmandPlugin { osmBugsLayer.openBug(latitude, longitude, message, autofill); } + public void modifyOsmNote(MapActivity mapActivity, OsmNotesPoint point) { + if (osmBugsLayer == null) { + registerLayers(mapActivity); + } + osmBugsLayer.modifyBug(point); + } + @Override public void addMyPlacesTab(FavoritesActivity favoritesActivity, List mTabs, Intent intent) { if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0) { From b92ce02f36d5820ba4c34a01054d41277f3c3114 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 3 Oct 2017 13:19:03 +0300 Subject: [PATCH 2/7] Add possibility to modify osm bugs from my places --- .../osmand/plus/osmedit/OsmBugsLocalUtil.java | 1 - .../osmand/plus/osmedit/OsmEditsFragment.java | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java index 54f6314f39..074109673d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java @@ -39,7 +39,6 @@ public class OsmBugsLocalUtil implements OsmBugsUtil { pnt.setId(point.getId()); pnt.setLatitude(point.getLatitude()); pnt.setLongitude(point.getLongitude()); - pnt.setAction(Action.MODIFY); pnt.setText(text); point = pnt; return wrap(point, db.updateOsmBug(point.getId(), text)); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 356d6765b6..cd221f2e5f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -24,11 +24,13 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; +import android.widget.EditText; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.data.PointDescription; import net.osmand.osm.edit.Node; import net.osmand.plus.OsmandApplication; @@ -46,6 +48,7 @@ import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.PoiUploaderType; +import net.osmand.util.Algorithms; import org.xmlpull.v1.XmlSerializer; @@ -351,6 +354,33 @@ public class OsmEditsFragment extends OsmAndListFragment } + private void showBugDialog(final OsmNotesPoint point) { + final View view = LayoutInflater.from(getActivity()).inflate(R.layout.open_bug, null); + view.findViewById(R.id.user_name_field).setVisibility(View.GONE); + view.findViewById(R.id.userNameEditTextLabel).setVisibility(View.GONE); + view.findViewById(R.id.password_field).setVisibility(View.GONE); + view.findViewById(R.id.passwordEditTextLabel).setVisibility(View.GONE); + String text = point.getText(); + if (!Algorithms.isEmpty(text)) { + ((EditText) view.findViewById(R.id.message_field)).setText(text); + } + + final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(R.string.shared_string_commit); + builder.setView(view); + builder.setPositiveButton(R.string.osn_modify_dialog_title, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String text = ((EditText) view.findViewById(R.id.message_field)).getText().toString(); + plugin.getDBBug().updateOsmBug(point.getId(), text); + point.setText(text); + notifyDataSetChanged(); + } + }); + builder.setNegativeButton(R.string.shared_string_cancel, null); + builder.create().show(); + } + public static void getOsmEditView(View v, OsmPoint child, OsmandApplication app) { TextView viewName = ((TextView) v.findViewById(R.id.name)); ImageView icon = (ImageView) v.findViewById(R.id.icon); @@ -503,6 +533,18 @@ public class OsmEditsFragment extends OsmAndListFragment } }); } + if (info instanceof OsmNotesPoint) { + item = optionsMenu.getMenu().add(R.string.context_menu_item_modify_note) + .setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_edit_dark)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + + @Override + public boolean onMenuItemClick(MenuItem item) { + showBugDialog((OsmNotesPoint) info); + return true; + } + }); + } item = optionsMenu.getMenu().add(R.string.shared_string_delete). setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark)); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { From 91e0ef005756a54f7b1d36e537019f76631d2555 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 3 Oct 2017 13:34:08 +0300 Subject: [PATCH 3/7] Fix dialog layout --- OsmAnd/res/layout/open_bug.xml | 43 ++++++++++++++-------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/OsmAnd/res/layout/open_bug.xml b/OsmAnd/res/layout/open_bug.xml index 9d6f11336e..18daf5159a 100644 --- a/OsmAnd/res/layout/open_bug.xml +++ b/OsmAnd/res/layout/open_bug.xml @@ -2,53 +2,46 @@ + android:orientation="vertical" + android:paddingLeft="?dialogPreferredPadding" + android:paddingRight="?dialogPreferredPadding"> + android:layout_height="wrap_content" + android:text="@string/osb_comment_dialog_message"/> + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:minLines="1"/> + android:layout_height="wrap_content" + android:text="@string/osb_comment_dialog_author"/> + android:layout_height="wrap_content" + android:text="NoName"/> + android:layout_height="wrap_content" + android:text="@string/osb_author_dialog_password"/> + android:layout_height="wrap_content" + android:inputType="textPassword"/> From 663f1b62ffbf58bf48fc1e1d711f99e71d2d720e Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 3 Oct 2017 14:04:19 +0300 Subject: [PATCH 4/7] Refactor --- .../net/osmand/plus/osmedit/OsmBugsLayer.java | 87 ++++++------------- 1 file changed, 27 insertions(+), 60 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index d45beba47e..4d3c085ba8 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -304,43 +304,23 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider return bugs; } - private void asyncActionTask(final OsmNotesPoint point, final String text) { - AsyncTask task = new AsyncTask() { - - @Override - protected OsmBugResult doInBackground(Void... params) { - return local.modify(point, text); - } - - protected void onPostExecute(OsmBugResult obj) { - if (obj != null && obj.warning == null) { - Toast.makeText(activity, R.string.osm_changes_added_to_local_edits, Toast.LENGTH_LONG).show(); - if (obj.local != null) { - PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_OSM_BUG, obj.local.getText()); - activity.getContextMenu().show(new LatLon(obj.local.getLatitude(), obj.local.getLongitude()), pd, obj.local); - } - clearCache(); - } else { - modifyBug(point); - Toast.makeText(activity, activity.getResources().getString(R.string.osn_modify_dialog_error) + "\n" + obj, Toast.LENGTH_LONG).show(); - } - } - }; - executeTaskInBackground(task); - } - - private void asyncActionTask(final OpenStreetNote bug, final String text, final Action action) { + private void asyncActionTask(final OpenStreetNote bug, final OsmNotesPoint point, final String text, final Action action) { AsyncTask task = new AsyncTask() { private OsmBugsUtil osmbugsUtil; @Override protected OsmBugResult doInBackground(Void... params) { - osmbugsUtil = getOsmbugsUtil(bug); - OsmNotesPoint pnt = new OsmNotesPoint(); - pnt.setId(bug.getId()); - pnt.setLatitude(bug.getLatitude()); - pnt.setLongitude(bug.getLongitude()); - return osmbugsUtil.commit(pnt, text, action); + if (bug != null) { + osmbugsUtil = getOsmbugsUtil(bug); + OsmNotesPoint pnt = new OsmNotesPoint(); + pnt.setId(bug.getId()); + pnt.setLatitude(bug.getLatitude()); + pnt.setLongitude(bug.getLongitude()); + return osmbugsUtil.commit(pnt, text, action); + } else { + osmbugsUtil = local; + return osmbugsUtil.modify(point, text); + } } protected void onPostExecute(OsmBugResult obj) { @@ -375,6 +355,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } else if (action == Action.CREATE) { r = R.string.osn_add_dialog_error; openBug(bug.getLatitude(), bug.getLongitude(), text); + } else if (action == null) { + r = R.string.osn_modify_dialog_error; + modifyBug(point); } else { commentBug(bug, text); } @@ -398,7 +381,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider bug.setLatitude(latitude); bug.setLongitude(longitude); - if (autofill) asyncActionTask(bug, message, Action.CREATE); + if (autofill) asyncActionTask(bug, null, message, Action.CREATE); else showBugDialog(bug, Action.CREATE, message); } @@ -419,30 +402,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } private void showBugDialog(final OsmNotesPoint point) { - final View view = LayoutInflater.from(activity).inflate(R.layout.open_bug, null); - view.findViewById(R.id.user_name_field).setVisibility(View.GONE); - view.findViewById(R.id.userNameEditTextLabel).setVisibility(View.GONE); - view.findViewById(R.id.password_field).setVisibility(View.GONE); - view.findViewById(R.id.passwordEditTextLabel).setVisibility(View.GONE); String text = point.getText(); - if (!Algorithms.isEmpty(text)) { - ((EditText) view.findViewById(R.id.message_field)).setText(text); - } - AndroidUtils.softKeyboardDelayed(view.findViewById(R.id.message_field)); - - final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(R.string.shared_string_commit); - builder.setView(view); - builder.setPositiveButton(R.string.osn_modify_dialog_title, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - String text = getMessageText(view); - activity.getContextMenu().close(); - asyncActionTask(point, text); - } - }); - builder.setNegativeButton(R.string.shared_string_cancel, null); - builder.create().show(); + createBugDialog(true, text, R.string.osn_modify_dialog_title, null, null, point); } private void showBugDialog(final OpenStreetNote bug, final Action action, String text) { @@ -460,6 +421,10 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider OsmBugsUtil util = getOsmbugsUtil(bug); final boolean offline = util instanceof OsmBugsLocalUtil; + createBugDialog(offline, text, title, action, bug, null); + } + + private void createBugDialog(final boolean offline, String text, int posButtonTitleRes, final Action action, final OpenStreetNote bug, final OsmNotesPoint point) { @SuppressLint("InflateParams") final View view = LayoutInflater.from(activity).inflate(R.layout.open_bug, null); if (offline) { @@ -479,13 +444,15 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.shared_string_commit); builder.setView(view); - builder.setPositiveButton(title, new DialogInterface.OnClickListener() { + builder.setPositiveButton(posButtonTitleRes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view); + activity.getContextMenu().close(); if (bug != null) { - String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view); - activity.getContextMenu().close(); - asyncActionTask(bug, text, action); + asyncActionTask(bug, null, text, action); + } else if (point != null) { + asyncActionTask(null, point, text, null); } } }); From 1f3ca9388afe2bf6ac59798d0da6ec125226cdff Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 3 Oct 2017 14:46:28 +0300 Subject: [PATCH 5/7] Fix creating items on context menu --- .../net/osmand/plus/osmedit/OsmEditingPlugin.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 39190c82d2..b73f443771 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -223,15 +223,10 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(listener) .createItem()); } - if (selectedObj instanceof OsmNotesPoint) { - adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_modify_note, mapActivity) - .setIcon(R.drawable.ic_action_bug_dark) - .setListener(listener).createItem()); - } else { - adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity) - .setIcon(R.drawable.ic_action_bug_dark) - .setListener(listener).createItem()); - } + adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(selectedObj instanceof OsmNotesPoint ? R.string.context_menu_item_modify_note : + R.string.context_menu_item_open_note, mapActivity) + .setIcon(R.drawable.ic_action_bug_dark) + .setListener(listener).createItem()); } public void openOsmNote(MapActivity mapActivity, double latitude, double longitude) { From c50a60261a8750c55cd13748a99f3597cfc3f376 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Tue, 3 Oct 2017 17:26:39 +0300 Subject: [PATCH 6/7] Change edit icon --- .../net/osmand/plus/osmedit/OsmEditingPlugin.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index b73f443771..705182b4eb 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -223,10 +223,15 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(listener) .createItem()); } - adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(selectedObj instanceof OsmNotesPoint ? R.string.context_menu_item_modify_note : - R.string.context_menu_item_open_note, mapActivity) - .setIcon(R.drawable.ic_action_bug_dark) - .setListener(listener).createItem()); + if (selectedObj instanceof OsmNotesPoint) { + adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_modify_note, mapActivity) + .setIcon(R.drawable.ic_action_edit_dark) + .setListener(listener).createItem()); + } else { + adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity) + .setIcon(R.drawable.ic_action_bug_dark) + .setListener(listener).createItem()); + } } public void openOsmNote(MapActivity mapActivity, double latitude, double longitude) { From bcac4eae2738bec0d579e29104b2afc1b6fb00f3 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Tue, 3 Oct 2017 17:47:28 +0300 Subject: [PATCH 7/7] Add checking for null --- OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 4d3c085ba8..7452609509 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -317,10 +317,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider pnt.setLatitude(bug.getLatitude()); pnt.setLongitude(bug.getLongitude()); return osmbugsUtil.commit(pnt, text, action); - } else { + } else if (point != null) { osmbugsUtil = local; return osmbugsUtil.modify(point, text); } + return null; } protected void onPostExecute(OsmBugResult obj) {