diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index e6268796ec..159e1c1908 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1353,17 +1353,27 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven public void showQuickSearch(double latitude, double longitude) { mapContextMenu.hide(); - QuickSearchDialogFragment.showInstance(this, "", new LatLon(latitude, longitude)); + QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); + if (fragment != null) { + fragment.dismiss(); + refreshMap(); + } + QuickSearchDialogFragment.showInstance(this, "", true, new LatLon(latitude, longitude)); } - public void showQuickSearch() { - QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); + public void showQuickSearch(boolean newSearch, boolean showCategories) { mapContextMenu.hide(); + QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); if (fragment != null) { - fragment.show(); + if (newSearch) { + fragment.dismiss(); + QuickSearchDialogFragment.showInstance(this, "", showCategories, null); + } else { + fragment.show(); + } refreshMap(); } else { - QuickSearchDialogFragment.showInstance(this, "", null); + QuickSearchDialogFragment.showInstance(this, "", showCategories, null); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 1b441fce59..4f1c0bb005 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -352,10 +352,10 @@ public class MapActivityLayers { PoiUIFilter pf = list.get(which); String filterId = pf.getFilterId(); if (filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)) { - Intent search = new Intent(activity, SearchActivity.class); - search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX); - activity.startActivity(search); + if (activity.getDashboard().isVisible()) { + activity.getDashboard().hideDashboard(); + } + activity.showQuickSearch(true, true); } else { getApplication().getPoiFilters().clearSelectedPoiFilters(); getApplication().getPoiFilters().addSelectedPoiFilter(pf); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index dad9544879..d8508809be 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -83,6 +83,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC private static final String QUICK_SEARCH_LAT_KEY = "quick_search_lat_key"; private static final String QUICK_SEARCH_LON_KEY = "quick_search_lon_key"; private static final String QUICK_SEARCH_SEARCHING_KEY = "quick_search_searching_key"; + private static final String QUICK_SEARCH_SHOW_CATEGORIES_KEY = "quick_search_show_categories_key"; private Toolbar toolbar; private LockableViewPager viewPager; private SearchFragmentPagerAdapter pagerAdapter; @@ -139,6 +140,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC final MapActivity mapActivity = getMapActivity(); final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false); + Bundle arguments = getArguments(); if (savedInstanceState != null) { searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY); double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN); @@ -148,10 +150,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } interruptedSearch = savedInstanceState.getBoolean(QUICK_SEARCH_SEARCHING_KEY, false); } - if (searchQuery == null) { - searchQuery = getArguments().getString(QUICK_SEARCH_QUERY_KEY); - double lat = getArguments().getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN); - double lon = getArguments().getDouble(QUICK_SEARCH_LON_KEY, Double.NaN); + if (searchQuery == null && arguments != null) { + searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY); + double lat = arguments.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN); + double lon = arguments.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN); if (!Double.isNaN(lat) && !Double.isNaN(lon)) { centerLatLon = new LatLon(lat, lon); } @@ -160,6 +162,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC if (searchQuery == null) searchQuery = ""; + boolean showCategories = false; + if (arguments != null) { + showCategories = arguments.getBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, false); + } + tabToolbarView = view.findViewById(R.id.tab_toolbar_layout); tabsView = view.findViewById(R.id.tabs_view); searchView = view.findViewById(R.id.search_view); @@ -278,7 +285,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC viewPager = (LockableViewPager) view.findViewById(R.id.pager); pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources()); viewPager.setAdapter(pagerAdapter); - if (centerLatLon != null) { + if (centerLatLon != null || showCategories) { viewPager.setCurrentItem(1); } @@ -877,7 +884,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } public static boolean showInstance(final MapActivity mapActivity, final String searchQuery, - final LatLon latLon) { + boolean showCategories, final LatLon latLon) { try { if (mapActivity.isActivityDestroyed()) { @@ -886,6 +893,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC Bundle bundle = new Bundle(); bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); + bundle.putBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, showCategories); if (latLon != null) { bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude()); bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index f30f6f1c1c..4146ac969f 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -223,7 +223,7 @@ public class MapControlsLayer extends OsmandMapLayer { search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - mapActivity.showQuickSearch(); + mapActivity.showQuickSearch(true, false); } }); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index bc91315cdd..2cc8468f60 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -177,14 +177,14 @@ public class MapInfoWidgetsFactory { searchBackButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - map.showQuickSearch(); + map.showQuickSearch(false, false); } }); searchTitle = (TextView) map.findViewById(R.id.search_title); searchTitle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - map.showQuickSearch(); + map.showQuickSearch(false, false); } }); searchCloseButton = (ImageButton) map.findViewById(R.id.search_close_button);