Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
130d81b165
7 changed files with 113 additions and 26 deletions
|
@ -17,7 +17,10 @@ public abstract class AbstractPoiType {
|
|||
private AbstractPoiType baseLangType;
|
||||
private boolean notEditableOsm;
|
||||
private String poiAdditionalCategory;
|
||||
private List<String> excludedPoiAdditionalCategoies;
|
||||
private List<String> excludedPoiAdditionalCategories;
|
||||
private String synonyms;
|
||||
private String enTranslation;
|
||||
private String translation;
|
||||
|
||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||
this.keyName = keyName;
|
||||
|
@ -66,12 +69,24 @@ public abstract class AbstractPoiType {
|
|||
|
||||
|
||||
public String getTranslation() {
|
||||
return registry.getTranslation(this);
|
||||
if(translation == null) {
|
||||
translation = registry.getTranslation(this);
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
public String getSynonyms() {
|
||||
if(synonyms == null) {
|
||||
synonyms = registry.getSynonyms(this);
|
||||
}
|
||||
return synonyms;
|
||||
}
|
||||
|
||||
public String getEnTranslation() {
|
||||
return registry.getEnTranslation(this);
|
||||
if(enTranslation == null) {
|
||||
enTranslation = registry.getEnTranslation(this);
|
||||
}
|
||||
return enTranslation;
|
||||
}
|
||||
|
||||
public String getPoiAdditionalCategoryTranslation() {
|
||||
|
@ -137,14 +152,14 @@ public abstract class AbstractPoiType {
|
|||
}
|
||||
|
||||
public List<String> getExcludedPoiAdditionalCategories() {
|
||||
return excludedPoiAdditionalCategoies;
|
||||
return excludedPoiAdditionalCategories;
|
||||
}
|
||||
|
||||
public void addExcludedPoiAdditionalCategories(String[] excludedPoiAdditionalCategories) {
|
||||
if (excludedPoiAdditionalCategoies == null) {
|
||||
excludedPoiAdditionalCategoies = new ArrayList<>();
|
||||
if (this.excludedPoiAdditionalCategories == null) {
|
||||
this.excludedPoiAdditionalCategories = new ArrayList<>();
|
||||
}
|
||||
Collections.addAll(excludedPoiAdditionalCategoies, excludedPoiAdditionalCategories);
|
||||
Collections.addAll(this.excludedPoiAdditionalCategories, excludedPoiAdditionalCategories);
|
||||
}
|
||||
|
||||
public abstract Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes);
|
||||
|
|
|
@ -55,8 +55,11 @@ public class MapPoiTypes {
|
|||
String getTranslation(String keyName);
|
||||
|
||||
String getEnTranslation(AbstractPoiType type);
|
||||
|
||||
String getEnTranslation(String keyName);
|
||||
|
||||
String getSynonyms(AbstractPoiType type);
|
||||
String getSynonyms(String keyName);
|
||||
|
||||
}
|
||||
|
||||
public static MapPoiTypes getDefaultNoInit() {
|
||||
|
@ -699,6 +702,16 @@ public class MapPoiTypes {
|
|||
|
||||
}
|
||||
|
||||
public String getSynonyms(AbstractPoiType abstractPoiType) {
|
||||
if (poiTranslator != null) {
|
||||
String translation = poiTranslator.getSynonyms(abstractPoiType);
|
||||
if (!Algorithms.isEmpty(translation)) {
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getEnTranslation(AbstractPoiType abstractPoiType) {
|
||||
if (poiTranslator != null) {
|
||||
String translation = poiTranslator.getEnTranslation(abstractPoiType);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.search.core;
|
||||
|
||||
import com.google.openlocationcode.OpenLocationCode;
|
||||
import com.jwetherell.openmap.common.LatLonPoint;
|
||||
import com.jwetherell.openmap.common.UTMPoint;
|
||||
|
||||
|
@ -50,7 +49,6 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
||||
|
||||
public class SearchCoreFactory {
|
||||
|
@ -616,13 +614,19 @@ public class SearchCoreFactory {
|
|||
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>();
|
||||
NameStringMatcher nm = phrase.getNameStringMatcher();
|
||||
for (PoiFilter pf : topVisibleFilters) {
|
||||
if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation()) || nm.matches(pf.getEnTranslation())) {
|
||||
if (!phrase.isUnknownSearchWordPresent()
|
||||
|| nm.matches(pf.getTranslation())
|
||||
|| nm.matches(pf.getEnTranslation())
|
||||
|| nm.matches(pf.getSynonyms())) {
|
||||
results.add(pf);
|
||||
}
|
||||
}
|
||||
if (phrase.isUnknownSearchWordPresent()) {
|
||||
for (PoiCategory c : categories) {
|
||||
if (!results.contains(c) && (nm.matches(c.getTranslation()) || nm.matches(c.getEnTranslation()) ) ) {
|
||||
if (!results.contains(c)
|
||||
&& (nm.matches(c.getTranslation())
|
||||
|| nm.matches(c.getEnTranslation())
|
||||
|| nm.matches(c.getSynonyms()))) {
|
||||
results.add(c);
|
||||
}
|
||||
}
|
||||
|
@ -631,14 +635,19 @@ public class SearchCoreFactory {
|
|||
Entry<String, PoiType> e = it.next();
|
||||
PoiType pt = e.getValue();
|
||||
if (pt.getCategory() != types.getOtherMapCategory()) {
|
||||
if (!results.contains(pt) && ( nm.matches(pt.getEnTranslation()) || nm.matches(pt.getTranslation()) )) {
|
||||
if (!results.contains(pt)
|
||||
&& (nm.matches(pt.getEnTranslation())
|
||||
|| nm.matches(pt.getTranslation())
|
||||
|| nm.matches(pt.getSynonyms()))) {
|
||||
results.add(pt);
|
||||
}
|
||||
List<PoiType> additionals = pt.getPoiAdditionals();
|
||||
if (additionals != null) {
|
||||
for (PoiType a : additionals) {
|
||||
if (!a.isReference() && !results.contains(a) &&
|
||||
( nm.matches(a.getEnTranslation()) || nm.matches(a.getTranslation()) )) {
|
||||
if (!a.isReference() && !results.contains(a)
|
||||
&& (nm.matches(a.getEnTranslation())
|
||||
|| nm.matches(a.getTranslation())
|
||||
|| nm.matches(a.getSynonyms()))) {
|
||||
results.add(a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -549,6 +549,7 @@
|
|||
<string name="poi_theatre_genre_circus">Цирк</string>
|
||||
<string name="poi_dance_floor">Танцплощадка</string>
|
||||
<string name="poi_nightclub">Ночной клуб</string>
|
||||
<string name="synonyms_poi_nightclub">Диско</string>
|
||||
<string name="poi_stripclub">Стрипклуб</string>
|
||||
<string name="poi_beach_resort">Пляжный комплекс</string>
|
||||
<string name="poi_dog_park">Площадка для выгула собак</string>
|
||||
|
|
|
@ -919,6 +919,7 @@
|
|||
<string name="poi_gallery">Art gallery</string>
|
||||
<string name="poi_dance_floor">Dance floor</string>
|
||||
<string name="poi_nightclub">Nightclub</string>
|
||||
<string name="synonyms_poi_nightclub">Disco;Disko</string>
|
||||
<string name="poi_stripclub">Stripclub</string>
|
||||
<string name="poi_ski_resort">Ski resort</string>
|
||||
<string name="poi_beach_resort">Beach resort</string>
|
||||
|
|
|
@ -334,11 +334,11 @@ public class AppInitializer implements IProgress {
|
|||
|
||||
app.poiTypes.setPoiTranslator(new MapPoiTypes.PoiTranslator() {
|
||||
|
||||
|
||||
@Override
|
||||
public String getTranslation(AbstractPoiType type) {
|
||||
if(type.getBaseLangType() != null) {
|
||||
return getTranslation(type.getBaseLangType()) + " (" + app.getLangTranslation(type.getLang()).toLowerCase() +")";
|
||||
AbstractPoiType baseLangType = type.getBaseLangType();
|
||||
if (baseLangType != null) {
|
||||
return getTranslation(baseLangType) + " (" + app.getLangTranslation(type.getLang()).toLowerCase() + ")";
|
||||
}
|
||||
return getTranslation(type.getIconKeyName());
|
||||
}
|
||||
|
@ -352,20 +352,42 @@ public class AppInitializer implements IProgress {
|
|||
return app.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.debug("No translation for "+ keyName + " " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSynonyms(AbstractPoiType type) {
|
||||
AbstractPoiType baseLangType = type.getBaseLangType();
|
||||
if (baseLangType != null) {
|
||||
return getSynonyms(baseLangType);
|
||||
}
|
||||
return getSynonyms(type.getIconKeyName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSynonyms(String keyName) {
|
||||
try {
|
||||
Field f = R.string.class.getField("synonyms_poi_" + keyName);
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return app.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnTranslation(AbstractPoiType type) {
|
||||
if(type.getBaseLangType() != null) {
|
||||
return getEnTranslation(type.getBaseLangType()) + " (" + app.getLangTranslation(type.getLang()).toLowerCase() +")";
|
||||
AbstractPoiType baseLangType = type.getBaseLangType();
|
||||
if (baseLangType != null) {
|
||||
return getEnTranslation(baseLangType) + " (" + app.getLangTranslation(type.getLang()).toLowerCase() + ")";
|
||||
}
|
||||
return getEnTranslation(type.getIconKeyName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEnTranslation(String keyName) {
|
||||
if (en == null) {
|
||||
|
@ -379,7 +401,6 @@ public class AppInitializer implements IProgress {
|
|||
return en.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.debug("No translation for "+ keyName + " " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.access.AccessibilityAssistant;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
|
@ -27,6 +29,7 @@ import net.osmand.plus.search.listitems.QuickSearchListItem;
|
|||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem;
|
||||
import net.osmand.search.SearchUICore;
|
||||
import net.osmand.search.core.SearchPhrase;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
@ -360,6 +363,30 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
}
|
||||
|
||||
String desc = listItem.getTypeName();
|
||||
Object searchResultObject = listItem.getSearchResult().object;
|
||||
if (searchResultObject instanceof AbstractPoiType) {
|
||||
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResultObject;
|
||||
String synonyms[] = abstractPoiType.getSynonyms().split(";");
|
||||
QuickSearchHelper searchHelper = app.getSearchUICore();
|
||||
SearchUICore searchUICore = searchHelper.getCore();
|
||||
String searchPhrase = searchUICore.getPhrase().getText(true);
|
||||
SearchPhrase.NameStringMatcher nm = new SearchPhrase.NameStringMatcher(searchPhrase,
|
||||
CollatorStringMatcher.StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
||||
|
||||
if (!searchPhrase.isEmpty() && !nm.matches(abstractPoiType.getTranslation())) {
|
||||
if (nm.matches(abstractPoiType.getEnTranslation())) {
|
||||
desc = listItem.getTypeName() + " (" + abstractPoiType.getEnTranslation() + ")";
|
||||
} else {
|
||||
for (String syn : synonyms) {
|
||||
if (nm.matches(syn)) {
|
||||
desc = listItem.getTypeName() + " (" + syn + ")";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasDesc = false;
|
||||
if (!Algorithms.isEmpty(desc) && !desc.equals(name)) {
|
||||
subtitle.setText(desc);
|
||||
|
|
Loading…
Reference in a new issue