use of net.osmand.plus.TargetPointsHelper 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.TargetPointsHelper in project Osmand by osmandapp.
the class FavouritesBottomSheetMenuFragment method selectFavorite.
private void selectFavorite(FavouritePoint point) {
TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
LatLon ll = new LatLon(point.getLatitude(), point.getLongitude());
if (intermediate) {
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription());
} else if (target) {
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription());
} else {
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription());
}
MapRouteInfoMenu routeMenu = getMapRouteInfoMenu();
if (routeMenu != null) {
setupMapRouteInfoMenuSpinners(routeMenu);
updateMapRouteInfoMenuFromIcon(routeMenu);
}
dismiss();
}
use of net.osmand.plus.TargetPointsHelper in project Osmand by osmandapp.
the class RoutePreferencesMenu method updateGpxRoutingParameter.
private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) {
RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
boolean selected = gpxParam.isSelected(settings);
if (rp != null) {
if (gpxParam.id == R.string.gpx_option_reverse_route) {
rp.setReverse(selected);
TargetPointsHelper tg = app.getTargetPointsHelper();
List<Location> ps = rp.getPoints();
if (ps.size() > 0) {
Location first = ps.get(0);
Location end = ps.get(ps.size() - 1);
TargetPointsHelper.TargetPoint pn = tg.getPointToNavigate();
boolean update = false;
if (pn == null || MapUtils.getDistance(pn.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) {
tg.navigateToPoint(new LatLon(end.getLatitude(), end.getLongitude()), false, -1);
update = true;
}
if (tg.getPointToStart() == null || MapUtils.getDistance(tg.getPointToStart().point, new LatLon(end.getLatitude(), end.getLongitude())) < 10) {
tg.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), false, null);
update = true;
}
if (update) {
tg.updateRouteAndRefresh(true);
}
}
} else if (gpxParam.id == R.string.gpx_option_calculate_first_last_segment) {
rp.setCalculateOsmAndRouteParts(selected);
settings.GPX_ROUTE_CALC_OSMAND_PARTS.set(selected);
} else if (gpxParam.id == R.string.gpx_option_from_start_point) {
rp.setPassWholeRoute(selected);
} else if (gpxParam.id == R.string.use_points_as_intermediates) {
settings.GPX_CALCULATE_RTEPT.set(selected);
rp.setUseIntermediatePointsRTE(selected);
} else if (gpxParam.id == R.string.calculate_osmand_route_gpx) {
settings.GPX_ROUTE_CALC.set(selected);
rp.setCalculateOsmAndRoute(selected);
updateParameters();
}
}
if (gpxParam.id == R.string.calculate_osmand_route_without_internet) {
settings.GPX_ROUTE_CALC_OSMAND_PARTS.set(selected);
}
if (gpxParam.id == R.string.fast_route_mode) {
settings.FAST_ROUTE_MODE.set(selected);
}
if (gpxParam.id == R.string.speak_favorites) {
settings.ANNOUNCE_NEARBY_FAVORITES.set(selected);
}
}
use of net.osmand.plus.TargetPointsHelper in project Osmand by osmandapp.
the class DashWaypointsFragment method setupTargets.
public void setupTargets() {
View mainView = getView();
final TargetPointsHelper helper = getMyApplication().getTargetPointsHelper();
if (helper.getPointToNavigate() == null) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
points = SHOW_ALL ? helper.getIntermediatePointsWithTarget() : Collections.singletonList(helper.getPointToNavigate());
((Button) mainView.findViewById(R.id.show_all)).setText(SHOW_ALL ? getString(R.string.shared_string_collapse) : getString(R.string.shared_string_show_all));
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SHOW_ALL = !SHOW_ALL;
setupView();
}
});
((Button) mainView.findViewById(R.id.show_all)).setVisibility(helper.getIntermediatePoints().size() == 0 ? View.INVISIBLE : View.VISIBLE);
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.waypoints) + " (" + helper.getIntermediatePointsWithTarget().size() + ")");
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final TargetPoint point : points) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.favorites_list_item, null, false);
TextView name = (TextView) view.findViewById(R.id.favourite_label);
TextView label = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
direction.setVisibility(View.VISIBLE);
label.setVisibility(View.VISIBLE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.findViewById(R.id.group_image).setVisibility(View.GONE);
boolean target = helper.getPointToNavigate() == point;
int id;
if (!target) {
id = R.drawable.list_intermediate;
} else {
id = R.drawable.list_destination;
}
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache().getIcon(id, 0));
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(), point.getLongitude()));
distances.add(dv);
name.setText(PointDescription.getSimpleName(point, getActivity()));
ImageButton options = ((ImageButton) view.findViewById(R.id.options));
options.setVisibility(View.VISIBLE);
final boolean optionsVisible = (SHOW_ALL && getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(optionsVisible ? R.drawable.ic_overflow_menu_white : R.drawable.ic_action_remove_dark));
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (optionsVisible) {
selectTargetModel(point, view);
} else {
deletePointConfirm(point, view);
}
}
});
ImageButton navigate = ((ImageButton) view.findViewById(R.id.navigate_to));
navigate.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_gdirections_dark));
navigate.setVisibility(target ? View.VISIBLE : View.GONE);
navigate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dashboard.navigationAction();
}
});
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), 15, point.getPointDescription(getActivity()), false, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
favorites.addView(view);
}
this.distances = distances;
}
use of net.osmand.plus.TargetPointsHelper in project Osmand by osmandapp.
the class AddWaypointBottomSheetDialogFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
final LatLon latLon = new LatLon(args.getDouble(LAT_KEY), args.getDouble(LON_KEY));
final PointDescription name = PointDescription.deserializeFromString(args.getString(POINT_DESCRIPTION_KEY), latLon);
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
items.add(new TitleItem(getString(R.string.new_destination_point_dialog)));
BaseBottomSheetItem replaceDestItem = new BottomSheetItemWithDescription.Builder().setDescription(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getIcon(R.drawable.list_destination, 0)).setTitle(getString(R.string.replace_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
targetPointsHelper.navigateToPoint(latLon, true, -1, name);
dismiss();
}
}).create();
items.add(replaceDestItem);
BaseBottomSheetItem replaceStartItem = new BottomSheetItemWithDescription.Builder().setDescription(getCurrentPointName(targetPointsHelper.getPointToStart(), true)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getIcon(R.drawable.list_startpoint, 0)).setTitle(getString(R.string.make_as_start_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TargetPoint start = targetPointsHelper.getPointToStart();
if (start != null) {
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()), false, 0, start.getOriginalPointDescription());
}
targetPointsHelper.setStartPoint(latLon, true, name);
dismiss();
}
}).create();
items.add(replaceStartItem);
items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.subsequent_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getSubsequentDestIcon()).setTitle(getString(R.string.keep_and_add_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size() + 1, name);
dismiss();
}
}).create();
items.add(subsequentDestItem);
BaseBottomSheetItem firstIntermItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.first_intermediate_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getFirstIntermDestIcon()).setTitle(getString(R.string.add_as_first_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
targetPointsHelper.navigateToPoint(latLon, true, 0, name);
dismiss();
}
}).create();
items.add(firstIntermItem);
BaseBottomSheetItem lastIntermItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.last_intermediate_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getLastIntermDistIcon()).setTitle(getString(R.string.add_as_last_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), name);
dismiss();
}
}).create();
items.add(lastIntermItem);
}
Aggregations