Add translations to search

This commit is contained in:
Victor Shcherb 2015-05-21 15:04:50 +03:00
parent 6ba1768018
commit 040d116852
2 changed files with 13 additions and 5 deletions

View file

@ -126,7 +126,7 @@ public class MapPoiTypes {
return null;
}
public Map<String, PoiType> getAllTranslatedNames() {
public Map<String, PoiType> getAllTranslatedNames(boolean onlyTranslation) {
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
for(PoiCategory pc : categories) {
for(PoiType pt : pc.getPoiTypes()) {
@ -134,6 +134,12 @@ public class MapPoiTypes {
continue;
}
translation.put(pt.getTranslation(), pt);
if(!onlyTranslation) {
String kn = pt.getKeyName().replace('_', ' ');
if(!pt.getTranslation().toLowerCase().contains(kn)) {
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt);
}
}
}
}
return translation;
@ -169,8 +175,10 @@ public class MapPoiTypes {
for (PoiType pt : pc.getPoiTypes()) {
translation.put(pt.getTranslation(), pt);
if (!onlyTranslation) {
// translation.put(pt.getKeyName(), pt);
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(pt.getKeyName().replace('_', ' ')), pt);
String kn = pt.getKeyName().replace('_', ' ');
if(!pt.getTranslation().toLowerCase().contains(kn)) {
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt);
}
}
}
return translation;

View file

@ -108,7 +108,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
private void prepareProvider() {
poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes();
allTranslatedSubTypes = poiTypes.getAllTranslatedNames();
allTranslatedSubTypes = poiTypes.getAllTranslatedNames(false);
settings = ((OsmandApplication) activity.getApplication()).getSettings();
isLocalEdit = true;
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
@ -610,7 +610,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
private Map<String, PoiType> getSubCategoriesMap(PoiCategory poiCategory) {
Map<String, PoiType> subCategories = new LinkedHashMap<>(poiTypes.getAllTranslatedNames(poiCategory, false));
for (Map.Entry<String, PoiType> s : poiTypes.getAllTranslatedNames().entrySet()) {
for (Map.Entry<String, PoiType> s : allTranslatedSubTypes.entrySet()) {
if (!subCategories.containsKey(s.getKey())) {
subCategories.put(s.getKey(), s.getValue());
}