Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-09-28 21:31:44 +02:00
commit 573c04a09f
4 changed files with 30 additions and 2 deletions

View file

@ -355,6 +355,12 @@ 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) {

View file

@ -23,6 +23,10 @@ public class SearchWord {
return result;
}
public void syncWordWithResult() {
word = result.wordsSpan != null ? result.wordsSpan : result.localeName.trim();
}
public LatLon getLocation() {
return result == null ? null : result.location;
}

View file

@ -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() {

View file

@ -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();
}
}