Update poi search

This commit is contained in:
Victor Shcherb 2015-04-08 18:42:25 +02:00
parent 97f987ebe7
commit 6479c894c7
4 changed files with 17 additions and 9 deletions

View file

@ -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(

View file

@ -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,12 +189,14 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
}
showFilterActivity(model.getFilterId());
} else {
PoiLegacyFilter custom = getApp().getPoiFilters().getCustomPOIFilter();
PoiLegacyFilter custom = getApp().getPoiFilters().getFilterById(PoiLegacyFilter.STD_PREFIX + ((AbstractPoiType) item).getKeyName());
if(custom != null) {
custom.setFilterByName(null);
custom.updateTypesToAccept(((AbstractPoiType) item));
showFilterActivity(custom.getFilterId());
}
}
}
private void showFilterActivity(String filterId) {
final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);

View file

@ -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 {
}
}

View file

@ -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();