diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java index c4a4cdb4a5..9c9bcb441a 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java @@ -354,7 +354,13 @@ public class SearchPhrase { } return false; } - + + public void syncWordsWithResults() { + for(SearchWord w : words) { + w.syncWordWithResult(); + } + } + public String getText(boolean includeLastWord) { StringBuilder sb = new StringBuilder(); for(SearchWord s : words) { diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchWord.java b/OsmAnd-java/src/net/osmand/search/core/SearchWord.java index 59a896e218..ac02500afd 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchWord.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchWord.java @@ -22,6 +22,10 @@ public class SearchWord { public SearchResult getResult() { return result; } + + public void syncWordWithResult() { + word = result.wordsSpan != null ? result.wordsSpan : result.localeName.trim(); + } public LatLon getLocation() { return result == null ? null : result.location; diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 19f9a760c0..e8b44bc372 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -1053,11 +1053,24 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC if (searchPhrase.isLastWord(POI_TYPE)) { SearchResult sr = searchPhrase.getLastSelectedWord().getResult(); sr.object = filter; + sr.localeName = filter.getName(); + searchUICore.getPhrase().syncWordsWithResults(); String txt = searchUICore.getPhrase().getText(true); + searchQuery = txt; + searchEditText.setText(txt); + searchEditText.setSelection(txt.length()); runCoreSearch(txt, false, false); } } + public void clearLastWord() { + if (searchEditText.getText().length() > 0) { + String newText = searchUICore.getPhrase().getTextWithoutLastWord(); + searchEditText.setText(newText); + searchEditText.setSelection(newText.length()); + } + } + private void addMoreButton() { QuickSearchMoreListItem moreListItem = new QuickSearchMoreListItem(app, app.getString(R.string.search_POI_level_btn).toUpperCase(), new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java index b034946561..ae5c427d33 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java @@ -269,6 +269,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment { Toast.makeText(getContext(), MessageFormat.format(getContext().getText(R.string.edit_filter_delete_message).toString(), filter.getName()), Toast.LENGTH_SHORT).show(); app.getSearchUICore().refreshCustomPoiFilters(); + QuickSearchDialogFragment quickSearchDialogFragment = (QuickSearchDialogFragment) getParentFragment(); + quickSearchDialogFragment.reloadCategories(); + quickSearchDialogFragment.clearLastWord(); QuickSearchPoiFilterFragment.this.dismiss(); } } @@ -301,13 +304,15 @@ public class QuickSearchPoiFilterFragment extends DialogFragment { PoiUIFilter nFilter = new PoiUIFilter(editText.getText().toString(), null, filter.getAcceptedTypes(), app); applyFilterFields(); if (!Algorithms.isEmpty(filter.getFilterByName())) { + nFilter.setFilterByName(filter.getFilterByName()); nFilter.setSavedFilterByName(filter.getFilterByName()); } if (app.getPoiFilters().createPoiFilter(nFilter)) { Toast.makeText(getContext(), MessageFormat.format(getContext().getText(R.string.edit_filter_create_message).toString(), editText.getText().toString()), Toast.LENGTH_SHORT).show(); - ((QuickSearchDialogFragment) getParentFragment()).replaceQueryWithUiFilter(filter); app.getSearchUICore().refreshCustomPoiFilters(); + ((QuickSearchDialogFragment) getParentFragment()).replaceQueryWithUiFilter(nFilter); + ((QuickSearchDialogFragment) getParentFragment()).reloadCategories(); QuickSearchPoiFilterFragment.this.dismiss(); } }