From 4178a232da652b5d851a3a8e7b6f33f95cb69d4c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sun, 17 Jan 2016 20:03:24 +0300 Subject: [PATCH] Fix - Address not found in targets --- .../plus/helpers/WaypointDialogHelper.java | 34 +++++++++---------- .../plus/mapcontextmenu/MapContextMenu.java | 23 +++++++------ .../mapcontextmenu/MenuTitleController.java | 5 +++ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 3fc85eb8ae..96fb56b676 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -116,6 +116,19 @@ public class WaypointDialogHelper { } } + String descr; + PointDescription pd = point.getPointDescription(app); + if (Algorithms.isEmpty(pd.getName())) { + descr = pd.getTypeName(); + } else { + descr = pd.getName(); + } + + if (textShadow != null) { + textShadow.setText(descr); + } + text.setText(descr); + String pointDescription = ""; TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text); if (descText != null) { @@ -137,6 +150,10 @@ public class WaypointDialogHelper { } } + if (descr.equals(pointDescription)) { + pointDescription = ""; + } + if (dist > 0) { String dd = OsmAndFormatter.getFormattedDistance(dist, app); if (ps.deviationDistance > 0) { @@ -153,23 +170,6 @@ public class WaypointDialogHelper { if (descText != null) { descText.setText(pointDescription); } - - String descr; - PointDescription pd = point.getPointDescription(app); - if (Algorithms.isEmpty(pd.getName())) { - descr = pd.getTypeName(); - } else { - descr = pd.getName(); - } - - if (textShadow != null) { - textShadow.setText(descr); - } - text.setText(descr); - -// ((Spannable) text.getText()).setSpan( -// new ForegroundColorSpan(ctx.getResources().getColor(R.color.color_distance)), 0, distance.length() - 1, -// 0); } private List getPoints() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 67c13c6604..7c035c7c1b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -31,7 +31,6 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.PointEditor; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; -import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; @@ -422,7 +421,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL hide(); final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper(); if (targets.getIntermediatePoints().isEmpty()) { - targets.navigateToPoint(latLon, true, -1, getPointDescription()); + targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget()); mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true); } else { Builder bld = new AlertDialog.Builder(mapActivity); @@ -431,7 +430,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL bld.setSingleChoiceItems(new String[]{ mapActivity.getString(R.string.clear_intermediate_points), mapActivity.getString(R.string.keep_intermediate_points) -// mapActivity.getString(R.string.keep_and_add_destination_point) }, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -444,11 +442,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL public void onClick(DialogInterface dialog, int which) { if (defaultVls[0] == 0) { targets.removeAllWayPoints(false); - targets.navigateToPoint(latLon, true, -1, getPointDescription()); + targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget()); mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true); } else { - //targets.navigateToPoint(latLon, true, targets.getIntermediatePoints().size() + 1, getPointDescription()); - targets.navigateToPoint(latLon, true, -1, getPointDescription()); + targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget()); mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true); } } @@ -468,7 +465,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL @Override public void run() { mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), - pointDescription); + getPointDescriptionForTarget()); } }); } @@ -528,13 +525,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } + private PointDescription getPointDescriptionForTarget() { + return hasKnownTitle() ? null : pointDescription; + } + public void addAsLastIntermediate() { callMenuAction(true, new MenuAction() { @Override public void run() { mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon, true, mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(), - pointDescription); + getPointDescriptionForTarget()); close(); } }); @@ -544,7 +545,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL callMenuAction(true, new MenuAction() { @Override public void run() { - mapActivity.getMyApplication().getTargetPointsHelper().setStartPoint(latLon, true, pointDescription); + mapActivity.getMyApplication().getTargetPointsHelper().setStartPoint(latLon, true, + getPointDescriptionForTarget()); if (openRouteInfoMenu) { mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show(); } @@ -556,7 +558,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL callMenuAction(true, new MenuAction() { @Override public void run() { - mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon, true, -1, pointDescription); + mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon, true, -1, + getPointDescriptionForTarget()); if (openRouteInfoMenu) { mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index e2179bae7c..d5f6857abd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -46,6 +46,11 @@ public abstract class MenuTitleController { } } + public boolean hasKnownTitle() { + String title = getTitleStr(); + return getMapActivity().getString(R.string.no_address_found).equals(title) || addressNotKnownStr.equals(title); + } + public int getLeftIconId() { return leftIconId; }