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