From 96a7b69be1f3d715291c6d2fd90742a27aefa3e5 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sat, 1 Oct 2016 21:52:19 +0300 Subject: [PATCH] [Quick search] added custom search button --- OsmAnd/res/layout/search_custom_list_item.xml | 33 ++ OsmAnd/res/layout/search_custom_poi.xml | 109 ++++++ OsmAnd/res/values/strings.xml | 3 + .../src/net/osmand/plus/poi/PoiUIFilter.java | 4 + .../search/QuickSearchCustomPoiFragment.java | 352 ++++++++++++++++++ .../search/QuickSearchDialogFragment.java | 57 +++ .../plus/search/QuickSearchListAdapter.java | 18 +- .../plus/search/QuickSearchListFragment.java | 35 +- .../search/QuickSearchPoiFilterFragment.java | 7 +- 9 files changed, 598 insertions(+), 20 deletions(-) create mode 100644 OsmAnd/res/layout/search_custom_list_item.xml create mode 100644 OsmAnd/res/layout/search_custom_poi.xml create mode 100644 OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java diff --git a/OsmAnd/res/layout/search_custom_list_item.xml b/OsmAnd/res/layout/search_custom_list_item.xml new file mode 100644 index 0000000000..6d89f17fe1 --- /dev/null +++ b/OsmAnd/res/layout/search_custom_list_item.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/search_custom_poi.xml b/OsmAnd/res/layout/search_custom_poi.xml new file mode 100644 index 0000000000..b922628014 --- /dev/null +++ b/OsmAnd/res/layout/search_custom_poi.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 99253840ba..60fd9c1f23 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,9 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Selected categories + Create custom POI + Custom search Filters Apply filters Save filter diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 4b81e9019e..f852fbd009 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -541,6 +541,10 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable combineWithPoiFilter(f); } + public int getAcceptedTypesCount() { + return acceptedTypes.size(); + } + public Map> getAcceptedTypes() { return new LinkedHashMap<>(acceptedTypes); } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java new file mode 100644 index 0000000000..18e7b217ea --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java @@ -0,0 +1,352 @@ +package net.osmand.plus.search; + +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.AppCompatImageView; +import android.support.v7.widget.AppCompatTextView; +import android.support.v7.widget.SwitchCompat; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.poi.PoiFiltersHelper; +import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.plus.render.RenderingIcons; +import net.osmand.util.Algorithms; + +import java.text.Collator; +import java.util.Arrays; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +public class QuickSearchCustomPoiFragment extends DialogFragment { + + public static final String TAG = "QuickSearchCustomPoiFragment"; + private static final String QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY = "quick_search_custom_poi_filter_id_key"; + + private View view; + private ListView listView; + private CategoryListAdapter listAdapter; + private String filterId; + private PoiUIFilter filter; + private PoiFiltersHelper helper; + private View bottomBar; + private AppCompatTextView barTitle; + private AppCompatTextView barButton; + + public QuickSearchCustomPoiFragment() { + } + + private OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + boolean isLightTheme = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; + int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; + setStyle(STYLE_NO_FRAME, themeId); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final OsmandApplication app = getMyApplication(); + helper = app.getPoiFilters(); + if (getArguments() != null) { + filterId = getArguments().getString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY); + } else if (savedInstanceState != null) { + filterId = savedInstanceState.getString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY); + } + if (filterId != null) { + filter = helper.getFilterById(filterId); + } + if (filter == null) { + filter = helper.getCustomPOIFilter(); + filter.clearFilter(); + } + + view = inflater.inflate(R.layout.search_custom_poi, container, false); + + Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); + toolbar.setNavigationIcon(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark)); + toolbar.setNavigationContentDescription(R.string.shared_string_close); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + + listView = (ListView) view.findViewById(android.R.id.list); + listView.setBackgroundColor(getResources().getColor( + app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light + : R.color.ctx_menu_info_view_bg_dark)); + + View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null); + listView.addHeaderView(header, null, false); + View footer = inflater.inflate(R.layout.list_shadow_footer, listView, false); + listView.addFooterView(footer, null, false); + listAdapter = new CategoryListAdapter(app, app.getPoiTypes().getCategories(false)); + listView.setAdapter(listAdapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + PoiCategory category = listAdapter.getItem(position - listView.getHeaderViewsCount()); + showDialog(category); + } + }); + + bottomBar = view.findViewById(R.id.bottomBar); + barTitle = (AppCompatTextView) view.findViewById(R.id.barTitle); + barButton = (AppCompatTextView) view.findViewById(R.id.barButton); + bottomBar.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + ((QuickSearchDialogFragment) getParentFragment()).showFilter(filterId); + } + }); + + return view; + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY, filterId); + } + + private int getIconId(PoiCategory category) { + OsmandApplication app = getMyApplication(); + String id = null; + if (category != null) { + if (RenderingIcons.containsBigIcon(category.getIconKeyName())) { + id = category.getIconKeyName(); + } + } + if (id != null) { + return RenderingIcons.getBigIconResourceId(id); + } else { + return 0; + } + } + + public static void showDialog(DialogFragment parentFragment, String filterId) { + Bundle bundle = new Bundle(); + if (filterId != null) { + bundle.putString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY, filterId); + } + QuickSearchCustomPoiFragment fragment = new QuickSearchCustomPoiFragment(); + fragment.setArguments(bundle); + fragment.show(parentFragment.getChildFragmentManager(), TAG); + } + + private class CategoryListAdapter extends ArrayAdapter { + private OsmandApplication app; + + CategoryListAdapter(OsmandApplication app, List items) { + super(app, R.layout.list_item_icon_and_menu, items); + this.app = app; + } + + @NonNull + @Override + public View getView(int position, View convertView, ViewGroup parent) { + LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View row = convertView; + if (row == null) { + row = inflater.inflate(R.layout.list_item_icon_and_menu, parent, false); + } + PoiCategory category = getItem(position); + if (category != null) { + AppCompatImageView iconView = (AppCompatImageView) row.findViewById(R.id.icon); + AppCompatImageView secondaryIconView = (AppCompatImageView) row.findViewById(R.id.secondary_icon); + AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title); + AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description); + SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item); + + boolean categorySelected = filter.isTypeAccepted(category); + IconsCache ic = app.getIconsCache(); + int iconId = getIconId(category); + if (iconId != 0) { + if (categorySelected) { + iconView.setImageDrawable(ic.getIcon(iconId, R.color.osmand_orange)); + } else { + iconView.setImageDrawable(ic.getThemedIcon(iconId)); + } + } else { + iconView.setImageDrawable(null); + } + secondaryIconView.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_additional_option)); + check.setChecked(filter.isTypeAccepted(category)); + String textString = category.getTranslation(); + titleView.setText(textString); + Set subtypes = filter.getAcceptedSubtypes(category); + if (categorySelected) { + if (subtypes == null) { + descView.setText(getString(R.string.shared_string_all)); + } else { + StringBuilder sb = new StringBuilder(); + for (String st : subtypes) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(app.getPoiTypes().getPoiTranslation(st)); + } + descView.setText(sb.toString()); + } + descView.setVisibility(View.VISIBLE); + } else { + descView.setVisibility(View.GONE); + } + row.findViewById(R.id.divider).setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE); + addRowListener(category, check); + } + return (row); + } + + private void addRowListener(final PoiCategory category, final SwitchCompat check) { + check.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (check.isChecked()) { + filter.setTypeToAccept(category, true); + showDialog(category); + } else { + filter.setTypeToAccept(category, false); + saveFilter(); + } + notifyDataSetChanged(); + } + }); + } + } + + private void saveFilter() { + helper.editPoiFilter(filter); + if (filter.isEmpty()) { + bottomBar.setVisibility(View.GONE); + } else { + barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount()); + bottomBar.setVisibility(View.VISIBLE); + } + } + + private void showDialog(final PoiCategory poiCategory) { + final int index = listView.getFirstVisiblePosition(); + View v = listView.getChildAt(0); + final int top = (v == null) ? 0 : v.getTop(); + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + final LinkedHashMap subCategories = new LinkedHashMap(); + Set acceptedCategories = filter.getAcceptedSubtypes(poiCategory); + if (acceptedCategories != null) { + for(String s : acceptedCategories) { + subCategories.put(s, Algorithms.capitalizeFirstLetterAndLowercase(s)); + } + } + for(PoiType pt : poiCategory.getPoiTypes()) { + subCategories.put(pt.getKeyName(), pt.getTranslation()); + } + + final String[] array = subCategories.keySet().toArray(new String[0]); + final Collator cl = Collator.getInstance(); + cl.setStrength(Collator.SECONDARY); + Arrays.sort(array, 0, array.length, new Comparator() { + + @Override + public int compare(String object1, String object2) { + String v1 = subCategories.get(object1); + String v2 = subCategories.get(object2); + return cl.compare(v1, v2); + } + }); + final String[] visibleNames = new String[array.length]; + final boolean[] selected = new boolean[array.length]; + + for (int i = 0; i < array.length; i++) { + final String subcategory = array[i]; + visibleNames[i] = subCategories.get(subcategory); + if (acceptedCategories == null) { + selected[i] = true; + } else { + selected[i] = acceptedCategories.contains(subcategory); + } + } + builder.setTitle(poiCategory.getTranslation()); + + builder.setCancelable(true); + builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.setPositiveButton(getContext().getText(R.string.shared_string_apply), new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + LinkedHashSet accepted = new LinkedHashSet(); + for (int i = 0; i < selected.length; i++) { + if(selected[i]){ + accepted.add(array[i]); + } + } + if (subCategories.size() == accepted.size()) { + filter.selectSubTypesToAccept(poiCategory, null); + } else if(accepted.size() == 0){ + filter.setTypeToAccept(poiCategory, false); + } else { + filter.selectSubTypesToAccept(poiCategory, accepted); + } + saveFilter(); + listAdapter.notifyDataSetChanged(); + listView.setSelectionFromTop(index, top); + } + }); + + /* + builder.setPositiveButton(getContext().getText(R.string.shared_string_select_all), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + selectAllFromCategory(poiCategory); + listView.setSelectionFromTop(index, top); + } + }); + */ + + builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() { + + @Override + public void onClick(DialogInterface dialog, int item, boolean isChecked) { + selected[item] = isChecked; + } + }); + builder.show(); + + } + + public void selectAllFromCategory(PoiCategory poiCategory) { + filter.updateTypesToAccept(poiCategory); + saveFilter(); + listAdapter.notifyDataSetChanged(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 7f1727875e..257a5d7d5c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -5,6 +5,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; @@ -62,6 +63,7 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControll import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.search.SearchUICore; import net.osmand.search.SearchUICore.SearchResultCollection; +import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchCoreAPI; import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI; import net.osmand.search.core.SearchPhrase; @@ -845,6 +847,15 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC for (SearchResult sr : res.getCurrentSearchResults()) { rows.add(new QuickSearchListItem(app, sr)); } + rows.add(new CustomSearchButton(app, new OnClickListener() { + @Override + public void onClick(View v) { + PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter(); + filter.clearFilter(); + QuickSearchCustomPoiFragment.showDialog( + QuickSearchDialogFragment.this, filter.getFilterId()); + } + })); categoriesSearchFragment.updateListAdapter(rows, false); } } catch (IOException e) { @@ -1286,6 +1297,28 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } } + public void showFilter(String filterId) { + PoiUIFilter filter = app.getPoiFilters().getFilterById(filterId); + + SearchResult sr = new SearchResult(searchUICore.getPhrase()); + sr.localeName = filter.getName(); + sr.object = filter; + sr.priority = 0; + sr.objectType = ObjectType.POI_TYPE; + searchUICore.selectSearchResult(sr); + + String txt = filter.getName() + " "; + searchQuery = txt; + searchEditText.setText(txt); + searchEditText.setSelection(txt.length()); + updateToolbarButton(); + SearchSettings settings = searchUICore.getPhrase().getSettings(); + if (settings.getRadiusLevel() != 1) { + searchUICore.updateSettings(settings.setRadiusLevel(1)); + } + runCoreSearch(txt, false, false); + } + public class SearchFragmentPagerAdapter extends FragmentPagerAdapter { private final String[] fragments = new String[]{QuickSearchHistoryListFragment.class.getName(), QuickSearchCategoriesListFragment.class.getName()}; @@ -1397,4 +1430,28 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC super(TopToolbarControllerType.QUICK_SEARCH); } } + + public static class CustomSearchButton extends QuickSearchListItem { + + private OnClickListener onClickListener; + + public CustomSearchButton(OsmandApplication app, OnClickListener onClickListener) { + super(app, null); + this.onClickListener = onClickListener; + } + + @Override + public Drawable getIcon() { + return app.getIconsCache().getIcon(R.drawable.ic_action_search_dark); + } + + @Override + public String getName() { + return app.getString(R.string.custom_search); + } + + public OnClickListener getOnClickListener() { + return onClickListener; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 506d6b53fe..7e833d1e7d 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -18,6 +18,7 @@ import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.dashboard.DashLocationFragment; +import net.osmand.plus.search.QuickSearchDialogFragment.CustomSearchButton; import net.osmand.search.core.SearchPhrase; import net.osmand.util.Algorithms; import net.osmand.util.OpeningHoursParser; @@ -37,6 +38,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { private int searchMoreItemPosition; private int selectAllItemPosition; + private int customSearchItemPosition; private int screenOrientation; private int dp56; @@ -50,6 +52,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { private static final int ITEM_TYPE_REGULAR = 0; private static final int ITEM_TYPE_SEARCH_MORE = 1; private static final int ITEM_TYPE_SELECT_ALL = 2; + private static final int ITEM_TYPE_CUSTOM_SEARCH = 3; public interface OnSelectionListener { @@ -166,11 +169,13 @@ public class QuickSearchListAdapter extends ArrayAdapter { private void acquireAdditionalItemsPositions() { selectAllItemPosition = -1; searchMoreItemPosition = -1; + customSearchItemPosition = -1; if (getCount() > 0) { QuickSearchListItem first = getItem(0); QuickSearchListItem last = getItem(getCount() - 1); selectAllItemPosition = first instanceof QuickSearchSelectAllListItem ? 0 : -1; searchMoreItemPosition = last instanceof QuickSearchMoreListItem ? getCount() - 1 : -1; + customSearchItemPosition = last instanceof CustomSearchButton ? getCount() - 1 : -1; } } @@ -183,6 +188,8 @@ public class QuickSearchListAdapter extends ArrayAdapter { public int getItemViewType(int position) { if (position == searchMoreItemPosition) { return ITEM_TYPE_SEARCH_MORE; + } else if (position == customSearchItemPosition) { + return ITEM_TYPE_CUSTOM_SEARCH; } else if (position == selectAllItemPosition) { return ITEM_TYPE_SELECT_ALL; } else { @@ -192,7 +199,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { @Override public int getViewTypeCount() { - return 3; + return 4; } @Override @@ -211,6 +218,15 @@ public class QuickSearchListAdapter extends ArrayAdapter { } ((TextView) view.findViewById(R.id.title)).setText(listItem.getName()); + } else if (viewType == ITEM_TYPE_CUSTOM_SEARCH) { + if (convertView == null) { + LayoutInflater inflater = (LayoutInflater) app + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = (LinearLayout) inflater.inflate( + R.layout.search_custom_list_item, null); + } else { + view = (LinearLayout) convertView; + } } else if (viewType == ITEM_TYPE_SELECT_ALL) { if (convertView == null) { LayoutInflater inflater = (LayoutInflater) app diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index 3cc02e6a94..81f56d4a15 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.OsmAndListFragment; import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; +import net.osmand.plus.search.QuickSearchDialogFragment.CustomSearchButton; import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchResult; import net.osmand.util.Algorithms; @@ -81,22 +82,26 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { @Override public void onListItemClick(ListView l, View view, int position, long id) { QuickSearchListItem item = listAdapter.getItem(position - l.getHeaderViewsCount()); - if (item instanceof QuickSearchMoreListItem) { - ((QuickSearchMoreListItem) item).getOnClickListener().onClick(view); - } else { - SearchResult sr = item.getSearchResult(); - - if (sr.objectType == ObjectType.POI - || sr.objectType == ObjectType.LOCATION - || sr.objectType == ObjectType.HOUSE - || sr.objectType == ObjectType.FAVORITE - || sr.objectType == ObjectType.RECENT_OBJ - || sr.objectType == ObjectType.WPT - || sr.objectType == ObjectType.STREET_INTERSECTION) { - - showOnMap(sr); + if (item != null) { + if (item instanceof QuickSearchMoreListItem) { + ((QuickSearchMoreListItem) item).getOnClickListener().onClick(view); + } else if (item instanceof CustomSearchButton) { + ((CustomSearchButton) item).getOnClickListener().onClick(view); } else { - dialogFragment.completeQueryWithObject(item.getSearchResult()); + SearchResult sr = item.getSearchResult(); + + if (sr.objectType == ObjectType.POI + || sr.objectType == ObjectType.LOCATION + || sr.objectType == ObjectType.HOUSE + || sr.objectType == ObjectType.FAVORITE + || sr.objectType == ObjectType.RECENT_OBJ + || sr.objectType == ObjectType.WPT + || sr.objectType == ObjectType.STREET_INTERSECTION) { + + showOnMap(sr); + } else { + dialogFragment.completeQueryWithObject(item.getSearchResult()); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java index 7f7c4a3f6a..d7fd4a3c14 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java @@ -216,10 +216,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment { editTextView.findViewById(R.id.checkboxItem).setVisibility(View.GONE); listView.addHeaderView(editTextView); - View bottomShadowView = inflater.inflate(R.layout.card_bottom_divider, listView, false); - bottomShadowView.setMinimumHeight(AndroidUtils.dpToPx(getContext(), 16f)); - listView.addFooterView(bottomShadowView); - adapter = new PoiFilterListAdapter(getMyApplication(), getListItems()); + View bottomShadowView = inflater.inflate(R.layout.list_shadow_footer, listView, false); + listView.addFooterView(bottomShadowView, null, false); + adapter = new PoiFilterListAdapter(app, getListItems()); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override