diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 9a1bbcda99..6fafb86f46 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -306,7 +306,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa showFilterItem.setVisible(filter != null && !isNameSearch()); } if (filter != null) { - int maxLength = 30; + int maxLength = 24; String name = filter.getGeneratedName(maxLength); if(name.length() >= maxLength) { name = name.substring(0, maxLength) + getString(R.string.shared_string_ellipsis); @@ -807,7 +807,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa null, filter.getAcceptedTypes(), (OsmandApplication) getApplication()); if(searchFilter.getText().toString().length() > 0) { - nFilter.setFilterByName(searchFilter.getText().toString()); + nFilter.setSavedFilterByName(searchFilter.getText().toString()); } if (app.getPoiFilters().createPoiFilter(nFilter)) { AccessibleToast.makeText( diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index 884fea4d40..4f1844980b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -123,7 +123,7 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv } else { PoiFiltersHelper poiFilters = getApp().getPoiFilters(); for(PoiLegacyFilter pf : poiFilters.getTopDefinedPoiFilters()) { - if(!pf.isStandardFilter()) { + if(!pf.isStandardFilter() && pf.getName().toLowerCase().startsWith(s.toLowerCase())) { filters.add(pf); } } @@ -189,10 +189,12 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv } showFilterActivity(model.getFilterId()); } else { - PoiLegacyFilter custom = getApp().getPoiFilters().getCustomPOIFilter(); - custom.setFilterByName(null); - custom.updateTypesToAccept(((AbstractPoiType) item)); - showFilterActivity(custom.getFilterId()); + PoiLegacyFilter custom = getApp().getPoiFilters().getFilterById(PoiLegacyFilter.STD_PREFIX + ((AbstractPoiType) item).getKeyName()); + if(custom != null) { + custom.setFilterByName(null); + custom.updateTypesToAccept(((AbstractPoiType) item)); + showFilterActivity(custom.getFilterId()); + } } } diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java index 8b6d2de56d..6eaee977b7 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import net.osmand.access.AccessibilityPlugin; +import net.osmand.osm.AbstractPoiType; import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; @@ -123,7 +124,10 @@ public class PoiFiltersHelper { String typeId = filterId.substring(PoiLegacyFilter.STD_PREFIX.length()); PoiType tp = application.getPoiTypes().getPoiTypeByKey(typeId); if(tp != null) { - return new PoiLegacyFilter(tp, application); + PoiLegacyFilter lf = new PoiLegacyFilter(tp, application); + cacheTopStandardFilters.add(lf); + sortListOfFilters(cacheTopStandardFilters); + return lf; } } return null; @@ -424,4 +428,5 @@ public class PoiFiltersHelper { } + } diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java index 0084f1e263..48b542fac4 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java @@ -274,7 +274,8 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter { } public String getGeneratedName(int chars) { - if (areAllTypesAccepted() || acceptedTypes.isEmpty()) { + if (!filterId.equals(CUSTOM_FILTER_ID) || + areAllTypesAccepted() || acceptedTypes.isEmpty()) { return getName(); } StringBuilder res = new StringBuilder();