Add local poi search as 1st item
This commit is contained in:
parent
3e5e65f778
commit
9ffcb85853
4 changed files with 40 additions and 14 deletions
|
@ -292,8 +292,8 @@ public class MapActivityLayers {
|
|||
private void addFilterToList(final ContextMenuAdapter adapter, final List<PoiUIFilter> list, PoiUIFilter f) {
|
||||
list.add(f);
|
||||
Item it = adapter.item(f.getName()).selected(-1);
|
||||
if (RenderingIcons.containsBigIcon(f.getSimplifiedId())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(f.getSimplifiedId()));
|
||||
if (RenderingIcons.containsBigIcon(f.getIconId())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(f.getIconId()));
|
||||
} else {
|
||||
it.icon(R.drawable.mx_user_defined);
|
||||
}
|
||||
|
|
|
@ -268,8 +268,8 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
String name;
|
||||
if (item instanceof PoiUIFilter) {
|
||||
final PoiUIFilter model = (PoiUIFilter) item;
|
||||
if (RenderingIcons.containsBigIcon(model.getSimplifiedId())) {
|
||||
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), model.getSimplifiedId()));
|
||||
if (RenderingIcons.containsBigIcon(model.getIconId())) {
|
||||
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), model.getIconId()));
|
||||
} else if(PoiUIFilter.BY_NAME_FILTER_ID.equals(model.getFilterId()) ||
|
||||
model instanceof NominatimPoiFilter){
|
||||
icon.setImageResource(R.drawable.mx_name_finder);
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteStatement;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class PoiFiltersHelper {
|
||||
private final OsmandApplication application;
|
||||
|
@ -33,8 +34,10 @@ public class PoiFiltersHelper {
|
|||
private PoiUIFilter searchByNamePOIFilter;
|
||||
private PoiUIFilter customPOIFilter;
|
||||
private PoiUIFilter showAllPOIFilter;
|
||||
private PoiUIFilter localWikiPoiFilter;
|
||||
private List<PoiUIFilter> cacheTopStandardFilters;
|
||||
|
||||
|
||||
private static final String UDF_CAR_AID = "car_aid";
|
||||
private static final String UDF_FOR_TOURISTS = "for_tourists";
|
||||
private static final String UDF_FOOD_SHOP = "food_shop";
|
||||
|
@ -78,6 +81,8 @@ public class PoiFiltersHelper {
|
|||
return searchByNamePOIFilter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PoiUIFilter getCustomPOIFilter() {
|
||||
if(customPOIFilter == null){
|
||||
PoiUIFilter filter = new PoiUIFilter(application.getString(R.string.poi_filter_custom_filter),
|
||||
|
@ -88,9 +93,23 @@ public class PoiFiltersHelper {
|
|||
return customPOIFilter;
|
||||
}
|
||||
|
||||
public PoiUIFilter getLocalWikiPOIFilter() {
|
||||
if(localWikiPoiFilter == null){
|
||||
PoiType place = application.getPoiTypes().getPoiTypeByKey("wiki_place");
|
||||
if (place != null && !Algorithms.isEmpty(application.getLanguage())) {
|
||||
PoiUIFilter filter = new PoiUIFilter(place, application, " " +
|
||||
application.getLangTranslation(application.getLanguage())); //$NON-NLS-1$
|
||||
filter.setFilterByName("wiki:lang:"+application.getLanguage());
|
||||
filter.setStandardFilter(true);
|
||||
localWikiPoiFilter = filter;
|
||||
}
|
||||
}
|
||||
return localWikiPoiFilter;
|
||||
}
|
||||
|
||||
public PoiUIFilter getShowAllPOIFilter() {
|
||||
if(showAllPOIFilter == null){
|
||||
PoiUIFilter filter = new PoiUIFilter(null, application); //$NON-NLS-1$
|
||||
PoiUIFilter filter = new PoiUIFilter(null, application, ""); //$NON-NLS-1$
|
||||
filter.setStandardFilter(true);
|
||||
showAllPOIFilter = filter;
|
||||
}
|
||||
|
@ -117,7 +136,7 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
}
|
||||
PoiUIFilter ff = getFilterById(filterId, getCustomPOIFilter(), getSearchByNamePOIFilter(),
|
||||
getShowAllPOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
|
||||
getLocalWikiPOIFilter(), getShowAllPOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
|
||||
if (ff != null) {
|
||||
return ff;
|
||||
}
|
||||
|
@ -125,7 +144,7 @@ public class PoiFiltersHelper {
|
|||
String typeId = filterId.substring(PoiUIFilter.STD_PREFIX.length());
|
||||
AbstractPoiType tp = application.getPoiTypes().getAnyPoiTypeByKey(typeId);
|
||||
if(tp != null) {
|
||||
PoiUIFilter lf = new PoiUIFilter(tp, application);
|
||||
PoiUIFilter lf = new PoiUIFilter(tp, application, "");
|
||||
ArrayList<PoiUIFilter> copy = new ArrayList<PoiUIFilter>(cacheTopStandardFilters);
|
||||
copy.add(lf);
|
||||
sortListOfFilters(copy);
|
||||
|
@ -134,7 +153,7 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
AbstractPoiType lt = application.getPoiTypes().getAnyPoiAdditionalTypeByKey(typeId);
|
||||
if(lt != null) {
|
||||
PoiUIFilter lf = new PoiUIFilter(lt, application);
|
||||
PoiUIFilter lf = new PoiUIFilter(lt, application, "");
|
||||
ArrayList<PoiUIFilter> copy = new ArrayList<PoiUIFilter>(cacheTopStandardFilters);
|
||||
copy.add(lf);
|
||||
sortListOfFilters(copy);
|
||||
|
@ -182,10 +201,13 @@ public class PoiFiltersHelper {
|
|||
List<PoiUIFilter> top = new ArrayList<PoiUIFilter>();
|
||||
// user defined
|
||||
top.addAll(getUserDefinedPoiFilters());
|
||||
if(getLocalWikiPOIFilter() != null) {
|
||||
top.add(getLocalWikiPOIFilter());
|
||||
}
|
||||
// default
|
||||
MapPoiTypes poiTypes = application.getPoiTypes();
|
||||
for (PoiFilter t : poiTypes.getTopVisibleFilters()) {
|
||||
top.add(new PoiUIFilter(t, application));
|
||||
top.add(new PoiUIFilter(t, application, ""));
|
||||
}
|
||||
sortListOfFilters(top);
|
||||
cacheTopStandardFilters = top;
|
||||
|
|
|
@ -46,6 +46,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
|
||||
|
||||
protected String filterId;
|
||||
protected String standardIconId = "";
|
||||
protected String name;
|
||||
protected boolean isStandardFilter;
|
||||
|
||||
|
@ -62,12 +63,14 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
protected List<Amenity> currentSearchResult = null;
|
||||
|
||||
// constructor for standard filters
|
||||
public PoiUIFilter(AbstractPoiType type, OsmandApplication application) {
|
||||
public PoiUIFilter(AbstractPoiType type, OsmandApplication application, String idSuffix) {
|
||||
this.app = application;
|
||||
isStandardFilter = true;
|
||||
filterId = STD_PREFIX + (type == null ? null : type.getKeyName());
|
||||
standardIconId = (type == null ? null : type.getKeyName());
|
||||
filterId = STD_PREFIX + standardIconId + idSuffix;
|
||||
|
||||
poiTypes = application.getPoiTypes();
|
||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
|
||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : (type.getTranslation() + idSuffix); //$NON-NLS-1$
|
||||
if (type == null) {
|
||||
initSearchAll();
|
||||
updatePoiAdditionals();
|
||||
|
@ -79,6 +82,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// search by name standard
|
||||
protected PoiUIFilter(OsmandApplication application) {
|
||||
this.app = application;
|
||||
|
@ -520,9 +524,9 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
return poiAdditionals;
|
||||
}
|
||||
|
||||
public String getSimplifiedId(){
|
||||
public String getIconId(){
|
||||
if(filterId.startsWith(STD_PREFIX)) {
|
||||
return filterId.substring(STD_PREFIX.length()).toLowerCase();
|
||||
return standardIconId;
|
||||
} else if(filterId.startsWith(USER_PREFIX)) {
|
||||
return filterId.substring(USER_PREFIX.length()).toLowerCase();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue