Disable online search without online maps plugin enabled

This commit is contained in:
Alexander Sytnyk 2017-10-25 17:52:58 +03:00
parent f13c0145c5
commit 7d7d9409ef
3 changed files with 34 additions and 23 deletions

View file

@ -102,7 +102,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="48dp" android:minHeight="48dp"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -64,6 +64,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -71,6 +72,7 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.resources.RegionAddressRepository; import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI; import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
import net.osmand.plus.search.listitems.QuickSearchButtonListItem; import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
@ -1080,6 +1082,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
for (SearchResult sr : res.getCurrentSearchResults()) { for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr)); rows.add(new QuickSearchListItem(app, sr));
} }
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark, rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
app.getString(R.string.search_online_address), new OnClickListener() { app.getString(R.string.search_online_address), new OnClickListener() {
@Override @Override
@ -1090,6 +1093,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
openKeyboard(); openKeyboard();
} }
})); }));
}
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark, rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark,
app.getString(R.string.custom_search), new OnClickListener() { app.getString(R.string.custom_search), new OnClickListener() {
@Override @Override

View file

@ -20,8 +20,10 @@ import net.osmand.access.AccessibilityAssistant;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashLocationFragment; 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.QuickSearchHeaderListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchListItemType;
@ -233,6 +235,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
view.findViewById(R.id.empty_search).setVisibility(View.GONE); view.findViewById(R.id.empty_search).setVisibility(View.GONE);
view.findViewById(R.id.more_divider).setVisibility(View.GONE); view.findViewById(R.id.more_divider).setVisibility(View.GONE);
} }
if (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() { view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -245,6 +249,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
((QuickSearchMoreListItem) listItem).onlineSearchOnClick(); ((QuickSearchMoreListItem) listItem).onlineSearchOnClick();
} }
}); });
}
} else if (type == QuickSearchListItemType.BUTTON) { } else if (type == QuickSearchListItemType.BUTTON) {
if (convertView == null) { if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app LayoutInflater inflater = (LayoutInflater) app