From bb6ddf6e1393b30e56b60d258bfdc98efa8d101c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 29 Jul 2016 10:59:05 +0300 Subject: [PATCH] [Quick search] produce Favs from history, fix context menu of history locationobject --- .../controllers/HistoryMenuController.java | 5 ++++ .../plus/search/QuickSearchListFragment.java | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java index b3ea45969a..fd72169a6f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java @@ -40,6 +40,11 @@ public class HistoryMenuController extends MenuController { return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN; } + @Override + public boolean displayStreetNameInTitle() { + return entry.getName().isLocation(); + } + @Override public boolean displayDistanceDirection() { return true; diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index b920c68e2b..cfbbc5dfdd 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -160,13 +160,25 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { break; case RECENT_OBJ: HistoryEntry entry = (HistoryEntry) object; - Amenity amenity = findAmenity(entry.getName().getName(), entry.getLat(), entry.getLon(), lang); - if (amenity != null) { - object = amenity; - pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI, - OsmAndFormatter.getPoiStringWithoutType(amenity, lang)); - } else { - pointDescription = entry.getName(); + pointDescription = entry.getName(); + if (pointDescription.isPoi()) { + Amenity amenity = findAmenity(entry.getName().getName(), entry.getLat(), entry.getLon(), lang); + if (amenity != null) { + object = amenity; + pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI, + OsmAndFormatter.getPoiStringWithoutType(amenity, lang)); + } + } else if (pointDescription.isFavorite()) { + LatLon entryLatLon = new LatLon(entry.getLat(), entry.getLon()); + List favs = app.getFavorites().getFavouritePoints(); + for (FavouritePoint f : favs) { + if (entryLatLon.equals(new LatLon(f.getLatitude(), f.getLongitude())) + && pointDescription.getName().equals(f.getName())) { + object = f; + pointDescription = f.getPointDescription(); + break; + } + } } break; case FAVORITE: