commit
b2294a6c5c
6 changed files with 58 additions and 3 deletions
|
@ -527,6 +527,17 @@ public class SearchUICore {
|
|||
return radius;
|
||||
}
|
||||
|
||||
public int getNextSearchRadius(SearchPhrase phrase) {
|
||||
int radius = Integer.MAX_VALUE;
|
||||
for (SearchCoreAPI api : apis) {
|
||||
int apiNextSearchRadius = api.getNextSearchRadius(phrase);
|
||||
if (apiNextSearchRadius > 0 && apiNextSearchRadius < radius) {
|
||||
radius = apiNextSearchRadius;
|
||||
}
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
|
||||
private void searchInBackground(final SearchPhrase phrase, SearchResultMatcher matcher) {
|
||||
preparePhrase(phrase);
|
||||
ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis);
|
||||
|
|
|
@ -27,4 +27,10 @@ public interface SearchCoreAPI {
|
|||
* @return minimal search radius in meters
|
||||
*/
|
||||
int getMinimalSearchRadius(SearchPhrase phrase);
|
||||
|
||||
/**
|
||||
* @param phrase
|
||||
* @return next search radius in meters
|
||||
*/
|
||||
int getNextSearchRadius(SearchPhrase phrase);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,11 @@ public class SearchCoreFactory {
|
|||
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextSearchRadius(SearchPhrase phrase) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void subSearchApiOrPublish(SearchPhrase phrase,
|
||||
SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
|
||||
|
@ -267,6 +272,11 @@ public class SearchCoreFactory {
|
|||
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getNextRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException {
|
||||
|
@ -592,6 +602,11 @@ public class SearchCoreFactory {
|
|||
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getRadiusSearch(BBOX_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getNextRadiusSearch(BBOX_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -735,6 +750,11 @@ public class SearchCoreFactory {
|
|||
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getRadiusSearch(BBOX_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextSearchRadius(SearchPhrase phrase) {
|
||||
return phrase.getNextRadiusSearch(BBOX_RADIUS);
|
||||
}
|
||||
|
||||
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
|
||||
LinkedHashSet<String>>();
|
||||
|
|
|
@ -662,6 +662,10 @@ public class SearchPhrase {
|
|||
public int getRadiusSearch(int meters) {
|
||||
return (1 << (getRadiusLevel() - 1)) * meters;
|
||||
}
|
||||
|
||||
public int getNextRadiusSearch(int meters) {
|
||||
return (1 << (getRadiusLevel())) * meters;
|
||||
}
|
||||
|
||||
public static int icompare(int x, int y) {
|
||||
return (x < y) ? -1 : ((x == y) ? 0 : 1);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||
Thx - Hardy
|
||||
-->
|
||||
<string name="increase_search_radius_to">Increase search radius to %1$s</string>
|
||||
<string name="send_search_query_description"><![CDATA[We will send your search query: <b>\"%1$s\"</b>, as well as your location.<br/><br/>
|
||||
We do not collect personal information, we only need search data to improve the search algorithm.<br/>]]></string>
|
||||
<string name="search_no_results_description">No results?\nTell us about this.</string>
|
||||
|
|
|
@ -15,7 +15,6 @@ 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;
|
||||
|
@ -24,7 +23,6 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||
|
@ -32,6 +30,7 @@ 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.search.core.SearchWord;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
|
@ -39,6 +38,8 @@ import java.util.ArrayList;
|
|||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
||||
|
||||
public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||
|
||||
private OsmandApplication app;
|
||||
|
@ -212,10 +213,22 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
view.findViewById(R.id.empty_search).setVisibility(emptySearchVisible ? View.VISIBLE : View.GONE);
|
||||
view.findViewById(R.id.more_divider).setVisibility(moreDividerVisible ? View.VISIBLE : View.GONE);
|
||||
SearchUICore searchUICore = app.getSearchUICore().getCore();
|
||||
SearchPhrase searchPhrase = searchUICore.getPhrase();
|
||||
|
||||
String textTitle = app.getString(R.string.nothing_found_in_radius) + " "
|
||||
+ OsmAndFormatter.getFormattedDistance(searchUICore.getMinimalSearchRadius(searchUICore.getPhrase()), app);
|
||||
+ OsmAndFormatter.getFormattedDistance(searchUICore.getMinimalSearchRadius(searchPhrase), app);
|
||||
((TextView) view.findViewById(R.id.empty_search_title)).setText(textTitle);
|
||||
View increaseRadiusRow = view.findViewById(R.id.increase_radius_row);
|
||||
|
||||
SearchWord word = searchPhrase.getLastSelectedWord();
|
||||
if (word != null && word.getType() != null && word.getType().equals(POI_TYPE)) {
|
||||
String textIncreaseRadiusTo = app.getString(R.string.increase_search_radius_to,
|
||||
OsmAndFormatter.getFormattedDistance(searchUICore.getNextSearchRadius(searchPhrase), app));
|
||||
((TextView) view.findViewById(R.id.title)).setText(textIncreaseRadiusTo);
|
||||
} else {
|
||||
((TextView) view.findViewById(R.id.title)).setText(app.getString(R.string.increase_search_radius));
|
||||
}
|
||||
|
||||
increaseRadiusRow.setVisibility(searchMoreItem.isSearchMoreAvailable() ? View.VISIBLE : View.GONE);
|
||||
increaseRadiusRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue