Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-05 14:15:46 +02:00
commit 82e3231571
5 changed files with 44 additions and 18 deletions

View file

@ -53,11 +53,11 @@ public class SearchUICore {
private MapPoiTypes poiTypes;
public SearchUICore(MapPoiTypes poiTypes, String locale) {
public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) {
this.poiTypes = poiTypes;
taskQueue = new LinkedBlockingQueue<Runnable>();
searchSettings = new SearchSettings(new ArrayList<BinaryMapIndexReader>());
searchSettings = searchSettings.setLang(locale);
searchSettings = searchSettings.setLang(locale, transliterate);
phrase = new SearchPhrase(searchSettings, OsmAndCollator.primaryCollator());
currentSearchResult = new SearchResultCollection(phrase);
singleThreadedExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, taskQueue);

View file

@ -234,7 +234,7 @@ public class SearchCoreFactory {
SearchResult res = new SearchResult(phrase);
res.object = c;
res.file = (BinaryMapIndexReader) c.getReferenceFile();
res.localeName = c.getName(phrase.getSettings().getLang(), true);
res.localeName = c.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.otherNames = c.getAllNames(true);
res.localeRelatedObjectName = res.file.getRegionName();
res.relatedObject = res.file;
@ -276,7 +276,7 @@ public class SearchCoreFactory {
SearchResult sr = new SearchResult(phrase);
sr.object = object;
sr.file = currentFile[0];
sr.localeName = object.getName(phrase.getSettings().getLang(), true);
sr.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
sr.otherNames = object.getAllNames(true);
sr.localeRelatedObjectName = sr.file.getRegionName();
sr.relatedObject = sr.file;
@ -294,7 +294,7 @@ public class SearchCoreFactory {
return false;
}
sr.objectType = ObjectType.STREET;
sr.localeRelatedObjectName = ((Street)object).getCity().getName(phrase.getSettings().getLang(), true);
sr.localeRelatedObjectName = ((Street)object).getCity().getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
sr.relatedObject = ((Street)object).getCity();
} else if (object instanceof City) {
CityType type = ((City)object).getType();
@ -334,7 +334,7 @@ public class SearchCoreFactory {
}
}
if(c != null) {
sr.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), true);
sr.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
sr.relatedObject = c;
sr.distRelatedObjectName = minDist;
}
@ -372,7 +372,7 @@ public class SearchCoreFactory {
for (SearchResult res : immediateResults) {
if(res.objectType == ObjectType.STREET) {
City ct = ((Street) res.object).getCity();
phrase.countUnknownWordsMatch(res, ct.getName(phrase.getSettings().getLang(), true),
phrase.countUnknownWordsMatch(res, ct.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate()),
ct.getAllNames(true));
subSearchApiOrPublish(phrase, resultMatcher, res, streetsApi);
} else {
@ -417,7 +417,7 @@ public class SearchCoreFactory {
}
SearchResult sr = new SearchResult(phrase);
sr.otherNames = object.getAllNames(true);
sr.localeName = object.getName(phrase.getSettings().getLang(), true);
sr.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
if(phrase.isUnknownSearchWordComplete()) {
if(!nm.matches(sr.localeName) || !nm.matches(sr.otherNames)) {
return false;
@ -640,7 +640,7 @@ public class SearchCoreFactory {
@Override
public boolean publish(Amenity object) {
SearchResult res = new SearchResult(phrase);
res.localeName = object.getName(phrase.getSettings().getLang(), true);
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.otherNames = object.getAllNames(true);
if (Algorithms.isEmpty(res.localeName)) {
AbstractPoiType st = types.getAnyPoiTypeByKey(object.getSubType());
@ -746,7 +746,7 @@ public class SearchCoreFactory {
for (Street object : c.getStreets()) {
SearchResult res = new SearchResult(phrase);
res.localeName = object.getName(phrase.getSettings().getLang(), true);
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.otherNames = object.getAllNames(true);
if(object.getName().startsWith("<")) {
// streets related to city
@ -756,7 +756,7 @@ public class SearchCoreFactory {
&& !(nm.matches(res.localeName) || nm.matches(res.otherNames))) {
continue;
}
res.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), true);
res.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.object = object;
res.preferredZoom = 17;
res.file = sw.getResult().file;
@ -865,14 +865,14 @@ public class SearchCoreFactory {
continue;
}
res.localeName = b.getName(phrase.getSettings().getLang(), true);
res.localeName = b.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.otherNames = b.getAllNames(true);
res.object = b;
res.file = file;
res.priority = priority;
res.priorityDistance = 0;
res.relatedObject = s;
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), true);
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.objectType = ObjectType.HOUSE;
if(interpolation) {
res.location = b.getLocation(b.interpolation(lw));
@ -889,11 +889,11 @@ public class SearchCoreFactory {
continue;
}
res.otherNames = street.getAllNames(true);
res.localeName = street.getName(phrase.getSettings().getLang(), true);
res.localeName = street.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.object = street;
res.file = file;
res.relatedObject = s;
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), true);
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.priorityDistance = 0;
res.objectType = ObjectType.STREET_INTERSECTION;
res.location = street.getLocation();

View file

@ -15,6 +15,7 @@ public class SearchSettings {
private int radiusLevel = 1;
private int totalLimit = -1;
private String lang;
private boolean transliterateIfMissing;
public SearchSettings(SearchSettings s) {
if(s != null) {
@ -47,9 +48,10 @@ public class SearchSettings {
return lang;
}
public SearchSettings setLang(String lang) {
public SearchSettings setLang(String lang, boolean transliterateIfMissing) {
SearchSettings s = new SearchSettings(this);
s.lang = lang;
s.transliterateIfMissing = transliterateIfMissing;
return s;
}
@ -79,5 +81,9 @@ public class SearchSettings {
return s;
}
public boolean isTransliterate() {
return transliterateIfMissing;
}
}

View file

@ -471,7 +471,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
SearchSettings settings = searchUICore.getSearchSettings().setOriginalLocation(
new LatLon(searchLatLon.getLatitude(), searchLatLon.getLongitude()));
settings = settings.setLang(locale);
settings = settings.setLang(locale, false);
searchUICore.updateSettings(settings);
searchUICore.setOnResultsComplete(new Runnable() {
@Override

View file

@ -38,7 +38,7 @@ public class QuickSearchHelper implements ResourceListener {
public QuickSearchHelper(OsmandApplication app) {
this.app = app;
core = new SearchUICore(app.getPoiTypes(), app.getSettings().MAP_PREFERRED_LOCALE.get());
core = new SearchUICore(app.getPoiTypes(), app.getSettings().MAP_PREFERRED_LOCALE.get(), false);
app.getResourceManager().addResourceListener(this);
}
@ -65,6 +65,11 @@ public class QuickSearchHelper implements ResourceListener {
// Register favorites search api
core.registerAPI(new SearchCoreFactory.SearchBaseAPI() {
@Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return false;
}
@Override
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) {
List<FavouritePoint> favList = app.getFavorites().getFavouritePoints();
@ -96,6 +101,11 @@ public class QuickSearchHelper implements ResourceListener {
// Register favorites by category search api
core.registerAPI(new SearchCoreFactory.SearchBaseAPI() {
@Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return false;
}
@Override
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) {
@ -153,6 +163,11 @@ public class QuickSearchHelper implements ResourceListener {
public SearchWptAPI(OsmandApplication app) {
this.app = app;
}
@Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return false;
}
@Override
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) {
@ -201,6 +216,11 @@ public class QuickSearchHelper implements ResourceListener {
public SearchHistoryAPI(OsmandApplication app) {
this.app = app;
}
@Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return false;
}
@Override
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) {