Search in sources :

Example 16 with PoiUIFilter

use of net.osmand.plus.poi.PoiUIFilter in project Osmand by osmandapp.

the class SearchPoiFilterFragment method showOptionsMenu.

private void showOptionsMenu(View v) {
    // Show menu with search all, name finder, name finder poi
    IconsCache iconsCache = getMyApplication().getIconsCache();
    final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
    MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            PoiUIFilter filter = getApp().getPoiFilters().getCustomPOIFilter();
            filter.clearFilter();
            showFilterActivity(filter.getFilterId());
            return true;
        }
    });
    optionsMenu.show();
}
Also used : MenuItem(android.view.MenuItem) IconsCache(net.osmand.plus.IconsCache) PopupMenu(android.support.v7.widget.PopupMenu) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 17 with PoiUIFilter

use of net.osmand.plus.poi.PoiUIFilter 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)

Example 18 with PoiUIFilter

use of net.osmand.plus.poi.PoiUIFilter in project Osmand by osmandapp.

the class AmenityMenuBuilder method getPoiAdditionalCollapsableView.

private CollapsableView getPoiAdditionalCollapsableView(final Context context, boolean collapsed, @NonNull final List<PoiType> categoryTypes, AmenityInfoRow textCuisineRow) {
    final List<TextViewEx> buttons = new ArrayList<>();
    LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
    for (final PoiType pt : categoryTypes) {
        TextViewEx button = buildButtonInCollapsableView(context, false, false);
        String name = pt.getTranslation();
        button.setText(name);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (amenity.getType() != null) {
                    PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName());
                    if (filter != null) {
                        filter.clearFilter();
                        filter.setTypeToAccept(amenity.getType(), true);
                        filter.updateTypesToAccept(pt);
                        filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
                        getMapActivity().showQuickSearch(filter);
                    }
                }
            }
        });
        buttons.add(button);
        if (buttons.size() > 3 && categoryTypes.size() > 4) {
            button.setVisibility(View.GONE);
        }
        view.addView(button);
    }
    if (textCuisineRow != null) {
        TextViewEx button = buildButtonInCollapsableView(context, true, false, false);
        String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase();
        button.setText(name);
        view.addView(button);
    }
    if (categoryTypes.size() > 4) {
        final TextViewEx button = buildButtonInCollapsableView(context, false, true);
        button.setText(context.getString(R.string.shared_string_show_all));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                for (TextViewEx b : buttons) {
                    if (b.getVisibility() != View.VISIBLE) {
                        b.setVisibility(View.VISIBLE);
                    }
                }
                button.setVisibility(View.GONE);
            }
        });
        view.addView(button);
    }
    return new CollapsableView(view, this, collapsed);
}
Also used : TextViewEx(net.osmand.plus.widgets.TextViewEx) ArrayList(java.util.ArrayList) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 19 with PoiUIFilter

use of net.osmand.plus.poi.PoiUIFilter in project Osmand by osmandapp.

the class WaypointHelper method calculatePoi.

protected void calculatePoi(RouteCalculationResult route, List<LocationPointWrapper> locationPoints, boolean announcePOI) {
    if (app.getPoiFilters().isShowingAnyPoi()) {
        final List<Location> locs = route.getImmutableAllLocations();
        List<Amenity> amenities = new ArrayList<>();
        for (PoiUIFilter pf : app.getPoiFilters().getSelectedPoiFilters()) {
            amenities.addAll(pf.searchAmenitiesOnThePath(locs, poiSearchDeviationRadius));
        }
        for (Amenity a : amenities) {
            AmenityRoutePoint rp = a.getRoutePoint();
            int i = locs.indexOf(rp.pointA);
            if (i >= 0) {
                LocationPointWrapper lwp = new LocationPointWrapper(route, POI, new AmenityLocationPoint(a), (float) rp.deviateDistance, i);
                lwp.deviationDirectionRight = rp.deviationDirectionRight;
                lwp.setAnnounce(announcePOI);
                locationPoints.add(lwp);
            }
        }
    }
}
Also used : Amenity(net.osmand.data.Amenity) AmenityRoutePoint(net.osmand.data.Amenity.AmenityRoutePoint) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) AmenityRoutePoint(net.osmand.data.Amenity.AmenityRoutePoint) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LocationPoint(net.osmand.data.LocationPoint) Location(net.osmand.Location) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 20 with PoiUIFilter

use of net.osmand.plus.poi.PoiUIFilter in project Osmand by osmandapp.

the class SearchPoiFilterFragment method setupSearchEditText.

private void setupSearchEditText(EditText e) {
    searchEditText = e;
    searchEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (currentTask != null) {
                currentTask.cancel(true);
            }
            currentTask = new SearchPoiByNameTask();
            currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, s.toString().trim());
        }
    });
    searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                final PoiUIFilter poiFilter = getApp().getPoiFilters().getSearchByNamePOIFilter();
                poiFilter.setFilterByName(searchEditText.getText().toString());
                showFilterActivity(poiFilter.getFilterId());
                handled = true;
            }
            return handled;
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Aggregations

PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)28 ArrayList (java.util.ArrayList)12 PoiFiltersHelper (net.osmand.plus.poi.PoiFiltersHelper)8 TextView (android.widget.TextView)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 DialogInterface (android.content.DialogInterface)6 AlertDialog (android.support.v7.app.AlertDialog)6 View (android.view.View)5 AbstractPoiType (net.osmand.osm.AbstractPoiType)5 PoiType (net.osmand.osm.PoiType)5 SearchResult (net.osmand.search.core.SearchResult)5 SpannableString (android.text.SpannableString)4 Button (android.widget.Button)4 LinearLayout (android.widget.LinearLayout)4 Drawable (android.graphics.drawable.Drawable)3 AdapterView (android.widget.AdapterView)3 EditText (android.widget.EditText)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)3