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();
}
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;
}
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);
}
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);
}
}
}
}
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;
}
});
}
Aggregations