diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchSettings.java b/OsmAnd-java/src/net/osmand/search/core/SearchSettings.java index 5c34ed2df4..e5655214f7 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchSettings.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchSettings.java @@ -142,4 +142,15 @@ public class SearchSettings { s.addressSearch = addressSearch; return s; } + + public boolean alreadyInOnlineSearch() { + if (searchTypes != null) { + for (ObjectType type : searchTypes) { + if (type == ObjectType.ONLINE_SEARCH) { + return true; + } + } + } + return false; + } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index b4de2ed219..1adac0a2e7 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -530,10 +530,6 @@ public abstract class OsmandPlugin { return getEnabledPlugin(OsmandDevelopmentPlugin.class) != null; } - public static boolean isOnlineMapsTurnedOn() { - return getEnabledPlugin(OsmandRasterMapsPlugin.class) != null; - } - public static void addMyPlacesTabPlugins(FavoritesActivity favoritesActivity, List mTabs, Intent intent) { for (OsmandPlugin p : getEnabledPlugins()) { p.addMyPlacesTab(favoritesActivity, mTabs, intent); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 9b61bf5746..a6db6a435c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -72,6 +72,7 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.resources.RegionAddressRepository; import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI; import net.osmand.plus.search.listitems.QuickSearchButtonListItem; @@ -1081,7 +1082,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC for (SearchResult sr : res.getCurrentSearchResults()) { rows.add(new QuickSearchListItem(app, sr)); } - if (OsmandPlugin.isOnlineMapsTurnedOn()) { + if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark, app.getString(R.string.search_online_address), new OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 0af7e02bce..5640c3e0a2 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -23,12 +23,12 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.dashboard.DashLocationFragment; +import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.search.listitems.QuickSearchHeaderListItem; import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchMoreListItem; import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem; -import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchPhrase; import net.osmand.util.Algorithms; import net.osmand.util.OpeningHoursParser; @@ -235,7 +235,8 @@ public class QuickSearchListAdapter extends ArrayAdapter { view.findViewById(R.id.empty_search).setVisibility(View.GONE); view.findViewById(R.id.more_divider).setVisibility(View.GONE); } - if (!alreadyInOnlineSearch() && OsmandPlugin.isOnlineMapsTurnedOn()) { + if (!app.getSearchUICore().getCore().getSearchSettings().alreadyInOnlineSearch() + && OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE); view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() { @Override @@ -430,18 +431,6 @@ public class QuickSearchListAdapter extends ArrayAdapter { return view; } - private boolean alreadyInOnlineSearch() { - ObjectType[] types = app.getSearchUICore().getCore().getSearchSettings().getSearchTypes(); - if (types != null) { - for (ObjectType type : types) { - if (type == ObjectType.ONLINE_SEARCH) { - return true; - } - } - } - return false; - } - public void toggleCheckbox(int position, CheckBox ch) { QuickSearchListItemType type = getItem(position).getType(); if (type == QuickSearchListItemType.SELECT_ALL) { diff --git a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchMoreListItem.java b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchMoreListItem.java index 763d1bc9a8..c3a6290dc0 100644 --- a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchMoreListItem.java +++ b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchMoreListItem.java @@ -1,5 +1,7 @@ package net.osmand.plus.search.listitems; +import android.support.annotation.Nullable; + import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -13,7 +15,7 @@ public class QuickSearchMoreListItem extends QuickSearchListItem { private String restartSearch; private String increaseRadius; - public QuickSearchMoreListItem(OsmandApplication app, String name, SearchMoreItemOnClickListener onClickListener) { + public QuickSearchMoreListItem(OsmandApplication app, String name, @Nullable SearchMoreItemOnClickListener onClickListener) { super(app, null); this.name = name; this.onClickListener = onClickListener; @@ -58,11 +60,15 @@ public class QuickSearchMoreListItem extends QuickSearchListItem { } public void increaseRadiusOnClick() { - onClickListener.increaseRadiusOnClick(); + if (onClickListener != null) { + onClickListener.increaseRadiusOnClick(); + } } public void onlineSearchOnClick() { - onClickListener.onlineSearchOnClick(); + if (onClickListener != null) { + onClickListener.onlineSearchOnClick(); + } } public interface SearchMoreItemOnClickListener {