diff --git a/DataExtractionOSM/src/com/osmand/data/Amenity.java b/DataExtractionOSM/src/com/osmand/data/Amenity.java index 0a36d395fc..07cbfca642 100644 --- a/DataExtractionOSM/src/com/osmand/data/Amenity.java +++ b/DataExtractionOSM/src/com/osmand/data/Amenity.java @@ -165,11 +165,15 @@ public class Amenity extends MapObject { public String getSimpleFormat(boolean en){ return Algoritms.capitalizeFirstLetterAndLowercase(getType().toString()) + - " : " + getSubType() + " " +getName(en); + " : " + getStringWithoutType(en); } public String getStringWithoutType(boolean en){ - return getSubType() + " " +getName(en); + String n = getName(en); + if(n.length() == 0){ + return getSubType(); + } + return getSubType() + " " + n; } @Override diff --git a/DataExtractionOSM/src/com/osmand/data/MapObject.java b/DataExtractionOSM/src/com/osmand/data/MapObject.java index 0577753eca..437b6d7fc6 100644 --- a/DataExtractionOSM/src/com/osmand/data/MapObject.java +++ b/DataExtractionOSM/src/com/osmand/data/MapObject.java @@ -54,11 +54,7 @@ public abstract class MapObject implements Comparable { if (this.name != null) { return this.name; } - if (id != null) { - return id + ""; - } else { - return ""; - } + return ""; } public void setName(String name) { @@ -66,7 +62,10 @@ public abstract class MapObject implements Comparable { } public String getEnName() { - return enName; + if(this.enName != null){ + return this.enName; + } + return ""; } public void setEnName(String enName) { diff --git a/OsmAnd/src/com/osmand/activities/search/SearchActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchActivity.java index 4e94eaff0f..b139b120c4 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchActivity.java @@ -23,9 +23,9 @@ public class SearchActivity extends TabActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TabHost host = getTabHost(); - host.addTab(host.newTabSpec("Search_POI").setIndicator("Search POI").setContent(new Intent(this, SearchPOIListActivity.class))); - host.addTab(host.newTabSpec("Search_Address").setIndicator("Search Address").setContent(new Intent(this, SearchAddressActivity.class))); - host.addTab(host.newTabSpec("Search_Location").setIndicator("Search Location").setContent(new Intent(this, NavigatePointActivity.class))); + host.addTab(host.newTabSpec("Search_POI").setIndicator("POI").setContent(new Intent(this, SearchPOIListActivity.class))); + host.addTab(host.newTabSpec("Search_Address").setIndicator("Address").setContent(new Intent(this, SearchAddressActivity.class))); + host.addTab(host.newTabSpec("Search_Location").setIndicator("Location").setContent(new Intent(this, NavigatePointActivity.class))); } } diff --git a/OsmAnd/src/com/osmand/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchByNameAbstractActivity.java index 64d60af6e6..752f53a591 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchByNameAbstractActivity.java @@ -57,6 +57,10 @@ public abstract class SearchByNameAbstractActivity extends ListActivity { }); } + public boolean isFilterableByDefault(){ + return false; + } + public Editable getFilter(){ return searchText.getText(); } @@ -65,14 +69,20 @@ public abstract class SearchByNameAbstractActivity extends ListActivity { runOnUiThread(new Runnable(){ @Override public void run() { + ((NamesAdapter)getListAdapter()).setNotifyOnChange(false); for(T o : objects){ ((NamesAdapter)getListAdapter()).add(o); } + ((NamesAdapter)getListAdapter()).notifyDataSetChanged(); } }); } public void setText(final String filter) { + if(isFilterableByDefault()){ + ((NamesAdapter) getListAdapter()).getFilter().filter(filter); + return; + } ((NamesAdapter) getListAdapter()).clear(); if(handlerToLoop == null){ diff --git a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java index e13d5f1834..ce94131c75 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java @@ -4,7 +4,6 @@ package com.osmand.activities.search; import java.util.List; -import java.util.Map; import android.app.ListActivity; import android.content.Intent; @@ -38,13 +37,12 @@ public class SearchPOIActivity extends ListActivity { public static final String ANENITY_TYPE = "amenity_type"; - Map> filter; - private List amenityList; private Button searchPOILevel; - private int zoom = 12; - private int maxCount = 100; + private final static int maxCount = 100; + private final static int finalZoom = 8; + private int zoom = 13; private AmenityType amenityType; @@ -61,14 +59,16 @@ public class SearchPOIActivity extends ListActivity { @Override public void onClick(View v) { ResourceManager resourceManager = ResourceManager.getResourceManager(); - if ( zoom > 7) { + if ( zoom > finalZoom) { --zoom; } amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation .getLongitude(), zoom, -1); if (amenityList != null) { + MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()); amenityAdapter.setNewModel(amenityList); } + searchPOILevel.setEnabled(zoom > finalZoom); } }); @@ -80,7 +80,9 @@ public class SearchPOIActivity extends ListActivity { amenityType = findAmenityType(anemity); amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation .getLongitude(), zoom, maxCount); + if (amenityList != null) { + MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()); amenityAdapter = new AmenityAdapter(amenityList); setListAdapter(amenityAdapter); } @@ -115,6 +117,7 @@ public class SearchPOIActivity extends ListActivity { } public void setNewModel(List amenityList) { + setNotifyOnChange(false); ((AmenityAdapter) getListAdapter()).clear(); for(Object obj: amenityList){ this.add(obj); diff --git a/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java index 419b5c3e69..4679ba1a5e 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java @@ -33,6 +33,10 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity