Fix show poi on map (search). Fix compilation.

This commit is contained in:
max-klaus 2020-06-05 17:22:02 +03:00
parent 3ccb9bc037
commit 629fa232c9
7 changed files with 125 additions and 45 deletions

View file

@ -9,11 +9,13 @@ import net.osmand.data.City;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.MapObject; import net.osmand.data.MapObject;
import net.osmand.data.Street; import net.osmand.data.Street;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.search.core.CustomSearchPoiFilter; import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.ObjectType; import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI; import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory; import net.osmand.search.core.SearchCoreFactory;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityByTypeAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI; import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI; import net.osmand.search.core.SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI;
import net.osmand.search.core.SearchCoreFactory.SearchStreetByCityAPI; import net.osmand.search.core.SearchCoreFactory.SearchStreetByCityAPI;
@ -324,7 +326,7 @@ public class SearchUICore {
apis.add(new SearchCoreFactory.SearchLocationAndUrlAPI()); apis.add(new SearchCoreFactory.SearchLocationAndUrlAPI());
SearchAmenityTypesAPI searchAmenityTypesAPI = new SearchAmenityTypesAPI(poiTypes); SearchAmenityTypesAPI searchAmenityTypesAPI = new SearchAmenityTypesAPI(poiTypes);
apis.add(searchAmenityTypesAPI); apis.add(searchAmenityTypesAPI);
apis.add(new SearchCoreFactory.SearchAmenityByTypeAPI(poiTypes, searchAmenityTypesAPI)); apis.add(new SearchAmenityByTypeAPI(poiTypes, searchAmenityTypesAPI));
apis.add(new SearchCoreFactory.SearchAmenityByNameAPI()); apis.add(new SearchCoreFactory.SearchAmenityByNameAPI());
SearchBuildingAndIntersectionsByStreetAPI streetsApi = SearchBuildingAndIntersectionsByStreetAPI streetsApi =
new SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI(); new SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI();
@ -572,6 +574,24 @@ public class SearchUICore {
return radius; return radius;
} }
public AbstractPoiType getUnselectedPoiType() {
for (SearchCoreAPI capi : apis) {
if (capi instanceof SearchAmenityByTypeAPI) {
return ((SearchAmenityByTypeAPI) capi).getUnselectedPoiType();
}
}
return null;
}
public String getCustomNameFilter() {
for (SearchCoreAPI capi : apis) {
if (capi instanceof SearchAmenityByTypeAPI) {
return ((SearchAmenityByTypeAPI) capi).getNameFilter();
}
}
return null;
}
void searchInternal(final SearchPhrase phrase, SearchResultMatcher matcher) { void searchInternal(final SearchPhrase phrase, SearchResultMatcher matcher) {
preparePhrase(phrase); preparePhrase(phrase);
ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis); ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis);

View file

@ -838,6 +838,8 @@ public class SearchCoreFactory {
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory, private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
LinkedHashSet<String>>(); LinkedHashSet<String>>();
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>(); private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
private AbstractPoiType unselectedPoiType;
private String nameFilter;
public SearchAmenityByTypeAPI(MapPoiTypes types, SearchAmenityTypesAPI searchAmenityTypesAPI) { public SearchAmenityByTypeAPI(MapPoiTypes types, SearchAmenityTypesAPI searchAmenityTypesAPI) {
super(ObjectType.POI); super(ObjectType.POI);
@ -845,6 +847,14 @@ public class SearchCoreFactory {
this.searchAmenityTypesAPI = searchAmenityTypesAPI; this.searchAmenityTypesAPI = searchAmenityTypesAPI;
} }
public AbstractPoiType getUnselectedPoiType() {
return unselectedPoiType;
}
public String getNameFilter() {
return nameFilter;
}
@Override @Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) { public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase); return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase);
@ -870,6 +880,7 @@ public class SearchCoreFactory {
@Override @Override
public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException { public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException {
unselectedPoiType = null;
SearchPoiTypeFilter poiTypeFilter = null; SearchPoiTypeFilter poiTypeFilter = null;
String nameFilter = null; String nameFilter = null;
int countExtraWords = 0; int countExtraWords = 0;
@ -907,10 +918,12 @@ public class SearchCoreFactory {
} }
} }
poiTypeFilter = getPoiTypeFilter(poiType.getKey()); poiTypeFilter = getPoiTypeFilter(poiType.getKey());
unselectedPoiType = poiType.getKey();
} }
} }
} }
} }
this.nameFilter = nameFilter;
if (poiTypeFilter != null) { if (poiTypeFilter != null) {
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS); QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS);
List<BinaryMapIndexReader> offlineIndexes = phrase.getOfflineIndexes(); List<BinaryMapIndexReader> offlineIndexes = phrase.getOfflineIndexes();
@ -935,7 +948,7 @@ public class SearchCoreFactory {
final BinaryMapIndexReader selected, final Set<String> searchedPois, final BinaryMapIndexReader selected, final Set<String> searchedPois,
final int countExtraWords) { final int countExtraWords) {
NameStringMatcher ns = nameFilter == null ? null : new NameStringMatcher(nameFilter, StringMatcherMode.CHECK_STARTS_FROM_SPACE); final NameStringMatcher ns = nameFilter == null ? null : new NameStringMatcher(nameFilter, StringMatcherMode.CHECK_STARTS_FROM_SPACE);
return new ResultMatcher<Amenity>() { return new ResultMatcher<Amenity>() {
@Override @Override

View file

@ -25,7 +25,10 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -372,24 +375,55 @@ public class OsmAndFormatter {
public static String getPoiStringWithoutType(Amenity amenity, String locale, boolean transliterate) { public static String getPoiStringWithoutType(Amenity amenity, String locale, boolean transliterate) {
PoiCategory pc = amenity.getType(); PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType()); PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
String nm = amenity.getSubType(); String typeName = amenity.getSubType();
if (pt != null) { if (pt != null) {
nm = pt.getTranslation(); typeName = pt.getTranslation();
} else if(nm != null){ } else if(typeName != null){
nm = Algorithms.capitalizeFirstLetterAndLowercase(nm.replace('_', ' ')); typeName = Algorithms.capitalizeFirstLetterAndLowercase(typeName.replace('_', ' '));
} }
String n = amenity.getName(locale, transliterate); String localName = amenity.getName(locale, transliterate);
if (n.indexOf(nm) != -1) { if (typeName != null && localName.contains(typeName)) {
// type is contained in name e.g. // type is contained in name e.g.
// n = "Bakery the Corner" // localName = "Bakery the Corner"
// type = "Bakery" // type = "Bakery"
// no need to repeat this // no need to repeat this
return n; return localName;
} }
if (n.length() == 0) { if (localName.length() == 0) {
return nm; return typeName;
} }
return nm + " " + n; //$NON-NLS-1$ return typeName + " " + localName; //$NON-NLS-1$
}
public static List<String> getPoiStringsWithoutType(Amenity amenity, String locale, boolean transliterate) {
PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
String typeName = amenity.getSubType();
if (pt != null) {
typeName = pt.getTranslation();
} else if(typeName != null){
typeName = Algorithms.capitalizeFirstLetterAndLowercase(typeName.replace('_', ' '));
}
List<String> res = new ArrayList<>();
String localName = amenity.getName(locale, transliterate);
addPoiString(typeName, localName, res);
for (String name : amenity.getAllNames(true)) {
addPoiString(typeName, name, res);
}
for (String name : amenity.getAdditionalInfo().values()) {
addPoiString(typeName, name, res);
}
return res;
}
private static void addPoiString(String poiTypeName, String poiName, List<String> res) {
if (poiTypeName != null && poiName.contains(poiTypeName)) {
res.add(poiName);
}
if (poiName.length() == 0) {
res.add(poiTypeName);
}
res.add(poiTypeName + " " + poiName);
} }
public static String getAmenityDescriptionContent(OsmandApplication ctx, Amenity amenity, boolean shortDescription) { public static String getAmenityDescriptionContent(OsmandApplication ctx, Amenity amenity, boolean shortDescription) {

View file

@ -11,13 +11,13 @@ import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.api.SQLiteAPI; import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import net.osmand.plus.api.SQLiteAPI.SQLiteStatement; import net.osmand.plus.api.SQLiteAPI.SQLiteStatement;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.wikipedia.WikipediaPoiMenu; import net.osmand.plus.wikipedia.WikipediaPoiMenu;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -227,7 +227,7 @@ public class PoiFiltersHelper {
AbstractPoiType tp = application.getPoiTypes().getAnyPoiTypeByKey(typeId); AbstractPoiType tp = application.getPoiTypes().getAnyPoiTypeByKey(typeId);
if (tp != null) { if (tp != null) {
PoiUIFilter lf = new PoiUIFilter(tp, application, ""); PoiUIFilter lf = new PoiUIFilter(tp, application, "");
ArrayList<PoiUIFilter> copy = new ArrayList<>(cacheTopStandardFilters); ArrayList<PoiUIFilter> copy = cacheTopStandardFilters != null ? new ArrayList<>(cacheTopStandardFilters) : new ArrayList<PoiUIFilter>();
copy.add(lf); copy.add(lf);
cacheTopStandardFilters = copy; cacheTopStandardFilters = copy;
return lf; return lf;
@ -235,7 +235,7 @@ public class PoiFiltersHelper {
AbstractPoiType lt = application.getPoiTypes().getAnyPoiAdditionalTypeByKey(typeId); AbstractPoiType lt = application.getPoiTypes().getAnyPoiAdditionalTypeByKey(typeId);
if (lt != null) { if (lt != null) {
PoiUIFilter lf = new PoiUIFilter(lt, application, ""); PoiUIFilter lf = new PoiUIFilter(lt, application, "");
ArrayList<PoiUIFilter> copy = new ArrayList<>(cacheTopStandardFilters); ArrayList<PoiUIFilter> copy = cacheTopStandardFilters != null ? new ArrayList<>(cacheTopStandardFilters) : new ArrayList<PoiUIFilter>();
copy.add(lf); copy.add(lf);
cacheTopStandardFilters = copy; cacheTopStandardFilters = copy;
return lf; return lf;
@ -279,8 +279,9 @@ public class PoiFiltersHelper {
} }
public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) { public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) {
if (cacheTopStandardFilters == null) { List<PoiUIFilter> top = this.cacheTopStandardFilters;
List<PoiUIFilter> top = new ArrayList<>(); if (top == null) {
top = new ArrayList<>();
// user defined // user defined
top.addAll(getUserDefinedPoiFilters(true)); top.addAll(getUserDefinedPoiFilters(true));
if (getLocalWikiPOIFilter() != null) { if (getLocalWikiPOIFilter() != null) {
@ -292,10 +293,10 @@ public class PoiFiltersHelper {
PoiUIFilter f = new PoiUIFilter(t, application, ""); PoiUIFilter f = new PoiUIFilter(t, application, "");
top.add(f); top.add(f);
} }
cacheTopStandardFilters = top; this.cacheTopStandardFilters = top;
} }
List<PoiUIFilter> result = new ArrayList<>(); List<PoiUIFilter> result = new ArrayList<>();
for (PoiUIFilter filter : cacheTopStandardFilters) { for (PoiUIFilter filter : top) {
if (includeDeleted || !filter.isDeleted()) { if (includeDeleted || !filter.isDeleted()) {
result.add(filter); result.add(filter);
} }
@ -462,7 +463,7 @@ public class PoiFiltersHelper {
} }
boolean res = helper.addFilter(filter, helper.getWritableDatabase(), false, forHistory); boolean res = helper.addFilter(filter, helper.getWritableDatabase(), false, forHistory);
if (res) { if (res) {
ArrayList<PoiUIFilter> copy = new ArrayList<>(cacheTopStandardFilters); ArrayList<PoiUIFilter> copy = cacheTopStandardFilters != null ? new ArrayList<>(cacheTopStandardFilters) : new ArrayList<PoiUIFilter>();
copy.add(filter); copy.add(filter);
Collections.sort(copy); Collections.sort(copy);
cacheTopStandardFilters = copy; cacheTopStandardFilters = copy;
@ -510,13 +511,17 @@ public class PoiFiltersHelper {
if (filter.isTopWikiFilter()) { if (filter.isTopWikiFilter()) {
prepareTopWikiFilter(filter); prepareTopWikiFilter(filter);
} }
Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>(this.selectedPoiFilters);
selectedPoiFilters.add(filter); selectedPoiFilters.add(filter);
saveSelectedPoiFilters(); saveSelectedPoiFilters(selectedPoiFilters);
this.selectedPoiFilters = selectedPoiFilters;
} }
public void removeSelectedPoiFilter(PoiUIFilter filter) { public void removeSelectedPoiFilter(PoiUIFilter filter) {
Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>(this.selectedPoiFilters);
selectedPoiFilters.remove(filter); selectedPoiFilters.remove(filter);
saveSelectedPoiFilters(); saveSelectedPoiFilters(selectedPoiFilters);
this.selectedPoiFilters = selectedPoiFilters;
} }
public boolean isShowingAnyPoi(PoiUIFilter ... filtersToExclude) { public boolean isShowingAnyPoi(PoiUIFilter ... filtersToExclude) {
@ -524,6 +529,7 @@ public class PoiFiltersHelper {
} }
public void clearSelectedPoiFilters(PoiUIFilter ... filtersToExclude) { public void clearSelectedPoiFilters(PoiUIFilter ... filtersToExclude) {
Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>(this.selectedPoiFilters);
if (filtersToExclude != null && filtersToExclude.length > 0) { if (filtersToExclude != null && filtersToExclude.length > 0) {
Iterator<PoiUIFilter> it = selectedPoiFilters.iterator(); Iterator<PoiUIFilter> it = selectedPoiFilters.iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -544,7 +550,8 @@ public class PoiFiltersHelper {
} else { } else {
selectedPoiFilters.clear(); selectedPoiFilters.clear();
} }
saveSelectedPoiFilters(); saveSelectedPoiFilters(selectedPoiFilters);
this.selectedPoiFilters = selectedPoiFilters;
} }
public String getFiltersName(Set<PoiUIFilter> filters) { public String getFiltersName(Set<PoiUIFilter> filters) {
@ -591,7 +598,7 @@ public class PoiFiltersHelper {
if(!application.getPoiTypes().isInit()) { if(!application.getPoiTypes().isInit()) {
return; return;
} }
selectedPoiFilters = new TreeSet<>(); Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>();
for (String f : application.getSettings().getSelectedPoiFilters()) { for (String f : application.getSettings().getSelectedPoiFilters()) {
PoiUIFilter filter = getFilterById(f); PoiUIFilter filter = getFilterById(f);
if (filter != null) { if (filter != null) {
@ -601,6 +608,7 @@ public class PoiFiltersHelper {
selectedPoiFilters.add(filter); selectedPoiFilters.add(filter);
} }
} }
this.selectedPoiFilters = selectedPoiFilters;
} }
@Nullable @Nullable
@ -630,7 +638,7 @@ public class PoiFiltersHelper {
} }
} }
private void saveSelectedPoiFilters() { private void saveSelectedPoiFilters(Set<PoiUIFilter> selectedPoiFilters) {
Set<String> filters = new HashSet<>(); Set<String> filters = new HashSet<>();
for (PoiUIFilter filter : selectedPoiFilters) { for (PoiUIFilter filter : selectedPoiFilters) {
filters.add(filter.filterId); filters.add(filter.filterId);

View file

@ -4,7 +4,6 @@ package net.osmand.plus.poi;
import android.content.Context; import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.CollatorStringMatcher.StringMatcherMode;
@ -380,17 +379,23 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
private AmenityNameFilter getNameFilterInternal(StringBuilder nmFilter, private AmenityNameFilter getNameFilterInternal(StringBuilder nmFilter,
final boolean allTime, final boolean open, final List<PoiType> poiAdditionals) { final boolean allTime, final boolean open, final List<PoiType> poiAdditionals) {
final CollatorStringMatcher sm = final CollatorStringMatcher sm = nmFilter.length() > 0 ?
nmFilter.length() > 0 ?
new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null; new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null;
return new AmenityNameFilter() { return new AmenityNameFilter() {
@Override @Override
public boolean accept(Amenity a) { public boolean accept(Amenity a) {
if (sm != null) { if (sm != null) {
String lower = OsmAndFormatter.getPoiStringWithoutType(a, List<String> names = OsmAndFormatter.getPoiStringsWithoutType(a,
app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get()); app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get());
if (!sm.matches(lower)) { boolean match = false;
for (String name : names) {
if (sm.matches(name)) {
match = true;
break;
}
}
if (!match) {
return false; return false;
} }
} }

View file

@ -68,14 +68,12 @@ import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.LockableViewPager; import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version; import net.osmand.plus.Version;
@ -92,6 +90,8 @@ import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.plus.search.listitems.QuickSearchMoreListItem; import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
import net.osmand.plus.search.listitems.QuickSearchMoreListItem.SearchMoreItemOnClickListener; import net.osmand.plus.search.listitems.QuickSearchMoreListItem.SearchMoreItemOnClickListener;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.search.SearchUICore; import net.osmand.search.SearchUICore;
@ -354,15 +354,15 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(POI_TYPE)) { } else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(POI_TYPE)) {
PoiUIFilter filter; PoiUIFilter filter;
if (searchPhrase.isNoSelectedType()) { if (searchPhrase.isNoSelectedType()) {
AbstractPoiType uselectedPoiType = searchUICore.getUnselectedPoiType();
if (isOnlineSearch() && !Algorithms.isEmpty(searchPhrase.getFirstUnknownSearchWord())) { if (isOnlineSearch() && !Algorithms.isEmpty(searchPhrase.getFirstUnknownSearchWord())) {
app.getPoiFilters().resetNominatimFilters(); app.getPoiFilters().resetNominatimFilters();
filter = app.getPoiFilters().getNominatimPOIFilter(); filter = app.getPoiFilters().getNominatimPOIFilter();
filter.setFilterByName(searchPhrase.getUnknownSearchPhrase()); filter.setFilterByName(searchPhrase.getUnknownSearchPhrase());
filter.clearCurrentResults(); filter.clearCurrentResults();
} else if (searchPhrase.hasUnknownSearchWordPoiType()) { } else if (uselectedPoiType != null) {
AbstractPoiType pt = searchPhrase.getUnknownSearchWordPoiType(); filter = new PoiUIFilter(uselectedPoiType, app, "");
filter = new PoiUIFilter(pt, app, ""); String customName = searchUICore.getCustomNameFilter();
String customName = searchPhrase.getPoiNameFilter();
if (!Algorithms.isEmpty(customName)) { if (!Algorithms.isEmpty(customName)) {
filter.setFilterByName(customName); filter.setFilterByName(customName);
} }

View file

@ -201,9 +201,9 @@ public class QuickSearchHelper implements ResourceListener {
//sr.localeRelatedObjectName = app.getRegions().getCountryName(sr.location); //sr.localeRelatedObjectName = app.getRegions().getCountryName(sr.location);
sr.relatedObject = selectedGpx.getGpxFile(); sr.relatedObject = selectedGpx.getGpxFile();
sr.preferredZoom = 17; sr.preferredZoom = 17;
if (phrase.getUnknownSearchWordLength() <= 1 && phrase.isNoSelectedType()) { if (phrase.getFullSearchPhrase().length() <= 1 && phrase.isNoSelectedType()) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} else if (phrase.getNameStringMatcher().matches(sr.localeName)) { } else if (phrase.getFirstUnknownNameStringMatcher().matches(sr.localeName)) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} }
} }
@ -249,7 +249,7 @@ public class QuickSearchHelper implements ResourceListener {
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY; sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
sr.objectType = ObjectType.FAVORITE_GROUP; sr.objectType = ObjectType.FAVORITE_GROUP;
sr.preferredZoom = 17; sr.preferredZoom = 17;
if (phrase.getNameStringMatcher().matches(sr.localeName)) { if (phrase.getFirstUnknownNameStringMatcher().matches(sr.localeName)) {
if (group.getPoints().size() < 5) { if (group.getPoints().size() < 5) {
for (FavouritePoint point : group.getPoints()) { for (FavouritePoint point : group.getPoints()) {
SearchResult srp = new SearchResult(phrase); SearchResult srp = new SearchResult(phrase);
@ -313,10 +313,10 @@ public class QuickSearchHelper implements ResourceListener {
continue; continue;
} }
} }
if (phrase.getUnknownSearchWordLength() <= 1 if (phrase.getFullSearchPhrase().length() <= 1
&& (phrase.isNoSelectedType() || phrase.isLastWord(ObjectType.FAVORITE_GROUP))) { && (phrase.isNoSelectedType() || phrase.isLastWord(ObjectType.FAVORITE_GROUP))) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} else if (phrase.getNameStringMatcher().matches(sr.localeName)) { } else if (phrase.getFirstUnknownNameStringMatcher().matches(sr.localeName)) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} }
} }
@ -457,9 +457,9 @@ public class QuickSearchHelper implements ResourceListener {
} }
if (publish) { if (publish) {
sr.priority = SEARCH_HISTORY_OBJECT_PRIORITY + (p++); sr.priority = SEARCH_HISTORY_OBJECT_PRIORITY + (p++);
if (phrase.getUnknownSearchWordLength() <= 1 && phrase.isNoSelectedType()) { if (phrase.getFullSearchPhrase().length() <= 1 && phrase.isNoSelectedType()) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} else if (phrase.getNameStringMatcher().matches(sr.localeName)) { } else if (phrase.getFirstUnknownNameStringMatcher().matches(sr.localeName)) {
resultMatcher.publish(sr); resultMatcher.publish(sr);
} }
} }