Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-10-14 21:11:58 +02:00
commit 8014e24588
3 changed files with 36 additions and 31 deletions

View file

@ -321,7 +321,7 @@ public class MapPoiTypes {
}
lastCategory.addPoiType(tp);
} else if (name.equals("poi_reference")) {
PoiType tp = new PoiType(this, lastCategory, parser.getAttributeValue("", "name"));
PoiType tp = new PoiType(this, lastCategory, lastFilter, parser.getAttributeValue("", "name"));
referenceTypes.add(tp);
tp.setReferenceType(tp);
if (lastFilter != null) {
@ -465,7 +465,7 @@ public class MapPoiTypes {
if (lang != null) {
otag += ":" + lang;
}
PoiType tp = new PoiType(this, lastCategory, oname);
PoiType tp = new PoiType(this, lastCategory, lastFilter, oname);
tp.setBaseLangType(langBaseType);
tp.setLang(lang);
tp.setAdditional(lastType != null ? lastType :
@ -499,7 +499,7 @@ public class MapPoiTypes {
if (lang != null) {
oname += ":" + lang;
}
PoiType tp = new PoiType(this, lastCategory, oname);
PoiType tp = new PoiType(this, lastCategory, lastFilter, oname);
String otag = parser.getAttributeValue("", "tag");
if (lang != null) {
otag += ":" + lang;

View file

@ -6,6 +6,7 @@ import java.util.Map;
public class PoiType extends AbstractPoiType {
private PoiCategory category;
private PoiFilter filter;
private AbstractPoiType parentType;
private PoiType referenceType;
private String osmTag;
@ -22,11 +23,12 @@ public class PoiType extends AbstractPoiType {
private int order = 90;
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name) {
public PoiType(MapPoiTypes poiTypes, PoiCategory category, PoiFilter filter, String name) {
super(name, poiTypes);
this.category = category;
this.filter = filter;
}
public PoiType getReferenceType() {
return referenceType;
}
@ -104,7 +106,11 @@ public class PoiType extends AbstractPoiType {
public PoiCategory getCategory() {
return category;
}
public PoiFilter getFilter() {
return filter;
}
public Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
if (isAdditional()) {
return parentType.putTypes(acceptedTypes);

View file

@ -466,33 +466,34 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
for (PoiFilter f : entry.getKey().getPoiFilters()) {
for (PoiType t : f.getPoiTypes()) {
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
if (entry.getKey().getExcludedPoiAdditionalCategories() != null) {
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
}
if (entry.getValue() != null) {
for (String keyName : entry.getValue()) {
PoiType poiType = poiTypes.getPoiTypeByKey(keyName);
if (poiType != null) {
collectExcludedPoiAdditionalCategories(poiType, excludedPoiAdditionalCategories);
PoiFilter poiFilter = poiType.getFilter();
if (poiFilter != null) {
collectExcludedPoiAdditionalCategories(poiFilter, excludedPoiAdditionalCategories);
}
PoiCategory poiCategory = poiType.getCategory();
if (poiCategory != null) {
collectExcludedPoiAdditionalCategories(poiCategory, excludedPoiAdditionalCategories);
}
}
}
collectExcludedCategories(poiTypes, f, null, excludedPoiAdditionalCategories);
}
for (PoiType t : entry.getKey().getPoiTypes()) {
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
}
collectExcludedCategories(poiTypes, entry.getKey(), entry.getValue(), excludedPoiAdditionalCategories);
}
return excludedPoiAdditionalCategories;
}
private void collectExcludedCategories(MapPoiTypes poiTypes,
AbstractPoiType type, LinkedHashSet<String> names,
Set<String> excludedPoiAdditionalCategories) {
if (type.getExcludedPoiAdditionalCategories() != null) {
excludedPoiAdditionalCategories.addAll(type.getExcludedPoiAdditionalCategories());
}
if (names != null) {
for (String keyName : names) {
List<String> categories = poiTypes.getPoiTypeByKey(keyName).getExcludedPoiAdditionalCategories();
if (categories != null) {
excludedPoiAdditionalCategories.addAll(categories);
}
}
private void collectExcludedPoiAdditionalCategories(AbstractPoiType abstractPoiType,
Set<String> excludedPoiAdditionalCategories) {
List<String> categories = abstractPoiType.getExcludedPoiAdditionalCategories();
if (categories != null) {
excludedPoiAdditionalCategories.addAll(categories);
}
}
@ -528,11 +529,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
int categoryIconId;
int categoryIconId = 0;
if (!Algorithms.isEmpty(categoryIconStr)) {
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
} else {
categoryIconId = RenderingIcons.getBigIconResourceId(category);
categoryIconId = RenderingIcons.getBigIconResourceId(categoryIconStr);
}
if (categoryIconId == 0) {
categoryIconId = R.drawable.ic_action_folder_stroke;