diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index e02f709a36..896e2cae16 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -105,7 +105,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - return searchMore(); + return search(); } }); @@ -159,7 +159,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa return tb; } - private boolean searchMore() { + private boolean search() { String query = searchFilter.getText().toString().trim(); if (query.length() < 2 && isNameSearch()) { AccessibleToast.makeText(SearchPOIActivity.this, R.string.poi_namefinder_query_empty, Toast.LENGTH_LONG) @@ -171,6 +171,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa filter.setFilterByName(query); runNewSearchQuery(location, NEW_SEARCH_INIT); } else { + filter.setFilterByName(query); runNewSearchQuery(location, SEARCH_FURTHER); } return true; @@ -243,6 +244,11 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa runNewSearchQuery(location, NEW_SEARCH_INIT); } updateButtonState(); + if (filter != null) { + String text = filter.getFilterByName() != null ? filter.getFilterByName() : ""; + searchFilter.setText(text); + searchFilterLayout.setVisibility(text.length() > 0 || isNameSearch() ? View.VISIBLE : View.GONE); + } if (filter != null) { if (searchNearBy) { app.getLocationProvider().addLocationListener(this); @@ -251,15 +257,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa } updateLocation(location); } - if (isNameSearch()) { - searchFilterLayout.setVisibility(View.VISIBLE); - } - if(searchFilterLayout.getVisibility() == View.VISIBLE) { - searchFilter.requestFocus(); - } - if(filter != null) { - searchFilter.setText(filter.getFilterByName() != null ? filter.getFilterByName() : ""); - } + // Freeze the direction arrows (reference is constant north) when Accessibility mode = ON, so screen can be read // aloud without continuous updates if (!app.accessibilityEnabled()) { @@ -272,10 +270,12 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa private void changeFilter(CharSequence s) { // if (!isNameSearch() ) { amenityAdapter.getFilter().filter(s); - if (filter != null && !isNameSearch()) { + String cfilter = filter.getFilterByName() == null ? "" : + filter.getFilterByName().toLowerCase(); + if(!isNameSearch() && !s.toString().toLowerCase().startsWith(cfilter)) { filter.setFilterByName(s.toString()); + runNewSearchQuery(location, SEARCH_AGAIN); } - updateButtonState(); } @@ -298,8 +298,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa boolean enabled = taskAlreadyFinished && location != null && filter != null && filter.isSearchFurtherAvailable(); if(isNameSearch() && !Algorithms.objectEquals(searchFilter.getText().toString(), filter.getFilterByName())) { - searchPOILevel.setEnabled(true); - searchPOILevel.setTitle(R.string.search_button); + enabled = true; + title = R.string.search_button; } searchPOILevel.setEnabled(enabled); searchPOILevel.setTitle(title); @@ -470,7 +470,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa @Override protected void onPreExecute() { - // getSherlock().setProgressBarIndeterminateVisibility(true); + setSupportProgressBarIndeterminateVisibility(true); if (searchPOILevel != null) { searchPOILevel.setEnabled(false); } @@ -492,7 +492,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa @Override protected void onPostExecute(List result) { - // getSherlock().setProgressBarIndeterminateVisibility(false); + setSupportProgressBarIndeterminateVisibility(false); currentSearchTask = null; updateButtonState(); if (isNameSearch()) { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index 72163fdc10..2cca7a154d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -190,7 +190,10 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv } showFilterActivity(model.getFilterId()); } else { - showFilterActivity(PoiLegacyFilter.STD_PREFIX + ((AbstractPoiType) item).getKeyName()); + PoiLegacyFilter custom = getApp().getPoiFilters().getCustomPOIFilter(); + custom.setFilterByName(null); + custom.updateTypesToAccept(((AbstractPoiType) item)); + showFilterActivity(custom.getFilterId()); } } diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java index 94eaf15c57..b0d9c6fd19 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java @@ -130,6 +130,8 @@ public class PoiFiltersHelper { public void reloadAllPoiFilters() { cacheTopStandardFilters = null; + showAllPOIFilter = null; + getShowAllPOIFilter(); getTopDefinedPoiFilters(); } diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java index 19bf589e95..9a463e9f6d 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiLegacyFilter.java @@ -312,6 +312,11 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter { } } + public void updateTypesToAccept(AbstractPoiType pt) { + acceptedTypes.clear(); + pt.putTypes(acceptedTypes); + } + public Map> getAcceptedTypes(){ return new LinkedHashMap>(acceptedTypes); diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 568b0fc26c..7fa8ace503 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -12,7 +12,6 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; -import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiType; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; @@ -198,7 +197,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon data.queryNewData(tileBox); objects = data.getResults(); if (objects != null) { - MapPoiTypes poiTypes = view.getApplication().getPoiTypes(); int r = getRadiusPoi(tileBox); for (Amenity o : objects) { int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation() @@ -214,8 +212,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon id = st.getKeyName(); } else if (RenderingIcons.containsIcon(st.getOsmTag() + "_" + st.getOsmValue())) { id = st.getOsmTag() + "_" + st.getOsmValue(); - } else if (RenderingIcons.containsIcon(st.getOsmValue())) { - id = st.getOsmValue(); } } if (id != null) {