Search in sources :

Example 1 with PoiFiltersHelper

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);
}
Also used : PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 2 with PoiFiltersHelper

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) Button(android.widget.Button)

Example 3 with PoiFiltersHelper

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ListView(android.widget.ListView) Button(android.widget.Button)

Example 4 with PoiFiltersHelper

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) Button(android.widget.Button)

Example 5 with PoiFiltersHelper

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;
}
Also used : Intent(android.content.Intent) ApplicationMode(net.osmand.plus.ApplicationMode) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TextView(android.widget.TextView) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) SearchPOIActivity(net.osmand.plus.activities.search.SearchPOIActivity) TextView(android.widget.TextView) IconsCache(net.osmand.plus.IconsCache) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) Nullable(android.support.annotation.Nullable)

Aggregations

PoiFiltersHelper (net.osmand.plus.poi.PoiFiltersHelper)8 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)8 Button (android.widget.Button)4 ArrayList (java.util.ArrayList)4 DialogInterface (android.content.DialogInterface)3 Drawable (android.graphics.drawable.Drawable)3 AlertDialog (android.support.v7.app.AlertDialog)3 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)3 ContextMenuItem (net.osmand.plus.ContextMenuItem)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 View (android.view.View)2 Intent (android.content.Intent)1 Nullable (android.support.annotation.Nullable)1 AdapterView (android.widget.AdapterView)1 ImageButton (android.widget.ImageButton)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 Collator (java.text.Collator)1 CollatorStringMatcher (net.osmand.CollatorStringMatcher)1 LatLon (net.osmand.data.LatLon)1