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:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<View
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.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
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.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;
@ -1080,16 +1082,18 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr));
}
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
app.getString(R.string.search_online_address), new OnClickListener() {
@Override
public void onClick(View view) {
startOnlinePoiSearch();
mainSearchFragment.getAdapter().clear();
updateTabbarVisibility(false);
openKeyboard();
}
}));
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
public void onClick(View view) {
startOnlinePoiSearch();
mainSearchFragment.getAdapter().clear();
updateTabbarVisibility(false);
openKeyboard();
}
}));
}
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark,
app.getString(R.string.custom_search), new OnClickListener() {
@Override

View file

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