From c1596733d0b551c76ef0ca1cf8313163bacb87a0 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 15 Oct 2015 18:58:17 +0300 Subject: [PATCH] Small add waypoint fixes --- .../osmand/plus/activities/MapActivityActions.java | 9 ++++++++- .../osmand/plus/mapcontextmenu/MapContextMenu.java | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 5f8609a1ab..28b2f96489 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -186,7 +186,13 @@ public class MapActivityActions implements DialogProvider { public void addWaypoint(final double latitude, final double longitude) { - String name = mapActivity.getContextMenu().getPointDescription().getFullPlainName(mapActivity); + String name; + PointDescription pointDescription = mapActivity.getContextMenu().getPointDescription(); + if (!pointDescription.isWpt() && !mapActivity.getContextMenu().isAddressUnknown()) { + name = mapActivity.getContextMenu().getTitleStr(); + } else { + name = ""; + } enhance(dialogBundle,latitude,longitude, name); mapActivity.showDialog(DIALOG_ADD_WAYPOINT); } @@ -587,6 +593,7 @@ public class MapActivityActions implements DialogProvider { v.setPadding(5, 0, 5, 0); if(args.getString(KEY_NAME) != null) { v.setText(args.getString(KEY_NAME)); + v.selectAll(); } else { v.setText(""); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 412953f357..aadd8b4d0c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.View; import net.osmand.Location; @@ -44,6 +43,7 @@ public class MapContextMenu { private String typeStr; private Drawable secondLineIcon; private String streetStr; + private boolean addressUnknown; private int favActionIconId; @@ -54,6 +54,7 @@ public class MapContextMenu { private static final String KEY_CTX_MENU_NAME_STR = "key_ctx_menu_name_str"; private static final String KEY_CTX_MENU_TYPE_STR = "key_ctx_menu_type_str"; private static final String KEY_CTX_MENU_STREET_STR = "key_ctx_menu_street_str"; + private static final String KEY_CTX_MENU_ADDR_UNKNOWN = "key_ctx_menu_addr_unknown"; public boolean isActive() { return active; @@ -114,6 +115,7 @@ public class MapContextMenu { nameStr = ""; typeStr = ""; streetStr = ""; + addressUnknown = false; active = true; @@ -240,6 +242,10 @@ public class MapContextMenu { return nameStr; } + public boolean isAddressUnknown() { + return addressUnknown; + } + public String getLocationStr() { if (menuController != null && menuController.needTypeStr()) { return typeStr; @@ -288,6 +294,7 @@ public class MapContextMenu { typeStr = ""; } else { nameStr = app.getResources().getString(R.string.address_unknown); + addressUnknown = true; } } } @@ -307,6 +314,7 @@ public class MapContextMenu { if (!Algorithms.isEmpty(streetStr)) { if (getObject() == null) { nameStr = streetStr; + addressUnknown = false; streetStr = ""; } mapActivity.runOnUiThread(new Runnable() { @@ -379,6 +387,7 @@ public class MapContextMenu { bundle.putString(KEY_CTX_MENU_NAME_STR, nameStr); bundle.putString(KEY_CTX_MENU_TYPE_STR, typeStr); bundle.putString(KEY_CTX_MENU_STREET_STR, streetStr); + bundle.putString(KEY_CTX_MENU_ADDR_UNKNOWN, Boolean.toString(addressUnknown)); } public void restoreMenuState(Bundle bundle) { @@ -400,6 +409,7 @@ public class MapContextMenu { nameStr = bundle.getString(KEY_CTX_MENU_NAME_STR); typeStr = bundle.getString(KEY_CTX_MENU_TYPE_STR); streetStr = bundle.getString(KEY_CTX_MENU_STREET_STR); + addressUnknown = Boolean.parseBoolean(bundle.getString(KEY_CTX_MENU_ADDR_UNKNOWN)); acquireIcons();