use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class ShowHidePoiAction method isCurrentFilters.
private boolean isCurrentFilters(OsmandApplication application) {
PoiFiltersHelper pf = application.getPoiFilters();
List<PoiUIFilter> poiFilters = loadPoiFilters(application.getPoiFilters());
return isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters);
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class ShowHidePoiAction method showSingleChoicePoiFilterDialog.
private void showSingleChoicePoiFilterDialog(final OsmandApplication app, final MapActivity activity, final Adapter filtersAdapter) {
final PoiFiltersHelper poiFilters = app.getPoiFilters();
final ContextMenuAdapter adapter = new ContextMenuAdapter();
final List<PoiUIFilter> list = new ArrayList<>();
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
addFilterToList(adapter, list, f);
}
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
addFilterToList(adapter, list, f);
}
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String oldTitle = getTitle(filtersAdapter.filters);
filtersAdapter.addItem(list.get(which));
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(activity))) {
String newTitle = getTitle(filtersAdapter.filters);
title.setText(newTitle);
}
}
});
builder.setTitle(R.string.show_poi_over_map);
builder.setNegativeButton(R.string.shared_string_dismiss, null);
final AlertDialog alertDialog = builder.create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
}
});
alertDialog.show();
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class MapActivityLayers method showMultichoicePoiFilterDialog.
public void showMultichoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
final OsmandApplication app = getApplication();
final PoiFiltersHelper poiFilters = app.getPoiFilters();
final ContextMenuAdapter adapter = new ContextMenuAdapter();
final List<PoiUIFilter> list = new ArrayList<>();
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
addFilterToList(adapter, list, f, true);
}
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
addFilterToList(adapter, list, f, true);
}
list.add(poiFilters.getCustomPOIFilter());
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final ListView listView = new ListView(activity);
listView.setDivider(null);
listView.setClickable(true);
listView.setAdapter(listAdapter);
listView.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ContextMenuItem item = listAdapter.getItem(position);
item.setSelected(!item.getSelected());
item.getItemClickListener().onContextMenuClick(listAdapter, position, position, item.getSelected(), null);
listAdapter.notifyDataSetChanged();
}
});
builder.setView(listView).setTitle(R.string.show_poi_over_map).setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (int i = 0; i < listAdapter.getCount(); i++) {
ContextMenuItem item = listAdapter.getItem(i);
PoiUIFilter filter = list.get(i);
if (item.getSelected()) {
getApplication().getPoiFilters().addSelectedPoiFilter(filter);
} else {
getApplication().getPoiFilters().removeSelectedPoiFilter(filter);
}
}
mapView.refreshMap();
}
}).setNegativeButton(R.string.shared_string_cancel, null).setNeutralButton(" ", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showSingleChoicePoiFilterDialog(mapView, listener);
}
});
final AlertDialog alertDialog = builder.create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_singleselect);
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
neutralButton.setContentDescription(app.getString(R.string.shared_string_filters));
}
});
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
listener.dismiss();
}
});
alertDialog.show();
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class MapActivityLayers method showSingleChoicePoiFilterDialog.
public void showSingleChoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
final OsmandApplication app = getApplication();
final PoiFiltersHelper poiFilters = app.getPoiFilters();
final ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_search, app).setIcon(R.drawable.ic_action_search_dark).createItem());
final List<PoiUIFilter> list = new ArrayList<>();
list.add(poiFilters.getCustomPOIFilter());
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
addFilterToList(adapter, list, f, false);
}
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
addFilterToList(adapter, list, f, false);
}
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PoiUIFilter pf = list.get(which);
String filterId = pf.getFilterId();
if (filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)) {
if (activity.getDashboard().isVisible()) {
activity.getDashboard().hideDashboard();
}
activity.showQuickSearch(ShowQuickSearchMode.NEW, true);
} else {
getApplication().getPoiFilters().clearSelectedPoiFilters();
getApplication().getPoiFilters().addSelectedPoiFilter(pf);
mapView.refreshMap();
}
}
});
builder.setTitle(R.string.show_poi_over_map);
builder.setNegativeButton(R.string.shared_string_dismiss, null);
builder.setNeutralButton(" ", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showMultichoicePoiFilterDialog(mapView, listener);
}
});
final AlertDialog alertDialog = builder.create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
neutralButton.setContentDescription(app.getString(R.string.apply_filters));
}
});
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
listener.dismiss();
}
});
alertDialog.show();
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class DestinationReachedMenuFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dest_reached_menu_fragment, container, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissMenu();
}
});
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight()));
closeImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissMenu();
}
});
Button removeDestButton = (Button) view.findViewById(R.id.removeDestButton);
removeDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_done, menu.isLight()), null, null, null);
AndroidUtils.setTextPrimaryColor(view.getContext(), removeDestButton, !menu.isLight());
removeDestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getMapActivity().getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
Object contextMenuObj = getMapActivity().getContextMenu().getObject();
if (getMapActivity().getContextMenu().isActive() && contextMenuObj != null && contextMenuObj instanceof TargetPoint) {
TargetPoint targetPoint = (TargetPoint) contextMenuObj;
if (!targetPoint.start && !targetPoint.intermediate) {
getMapActivity().getContextMenu().close();
}
}
OsmandSettings settings = getMapActivity().getMyApplication().getSettings();
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
getMapActivity().getMapActions().stopNavigationWithoutConfirm();
dismissMenu();
}
});
Button recalcDestButton = (Button) view.findViewById(R.id.recalcDestButton);
recalcDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_gdirections_dark, menu.isLight()), null, null, null);
AndroidUtils.setTextPrimaryColor(view.getContext(), recalcDestButton, !menu.isLight());
recalcDestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TargetPointsHelper helper = getMapActivity().getMyApplication().getTargetPointsHelper();
TargetPoint target = helper.getPointToNavigate();
dismissMenu();
if (target != null) {
helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()), true, -1, target.getOriginalPointDescription());
getMapActivity().getMapActions().recalculateRoute(false);
getMapActivity().getMapLayers().getMapControlsLayer().startNavigation();
}
}
});
Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton);
ApplicationMode appMode = getMapActivity().getMyApplication().getRoutingHelper().getAppMode();
if (!appMode.isDerivedRoutingFrom(appMode.CAR)) {
findParkingButton.setVisibility(View.GONE);
}
findParkingButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_parking_dark, menu.isLight()), null, null, null);
AndroidUtils.setTextPrimaryColor(view.getContext(), findParkingButton, !menu.isLight());
findParkingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PoiFiltersHelper helper = getMapActivity().getMyApplication().getPoiFilters();
// PoiType place = getMapActivity().getMyApplication().getPoiTypes().getPoiTypeByKey("parking");
PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
if (parkingFilter != null) {
final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, parkingFilter.getFilterId());
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
startActivityForResult(newIntent, 0);
}
dismissMenu();
}
});
View mainView = view.findViewById(R.id.main_view);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(), R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(), R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
TextView title = (TextView) view.findViewById(R.id.titleTextView);
AndroidUtils.setTextPrimaryColor(view.getContext(), title, !menu.isLight());
return view;
}
Aggregations