use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class DestinationReachedMenuFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null || menu == null) {
return null;
}
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, menu.isLight() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
LayoutInflater inf = LayoutInflater.from(ctx);
View view = inf.inflate(R.layout.dest_reached_menu_fragment, container, false);
AndroidUtils.addStatusBarPadding21v(ctx, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finishNavigation();
}
});
UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
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) {
finishNavigation();
}
});
Button removeDestButton = (Button) view.findViewById(R.id.removeDestButton);
removeDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_done, menu.isLight()), null, null, null);
removeDestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finishNavigation();
}
});
Button recalcDestButton = (Button) view.findViewById(R.id.recalcDestButton);
recalcDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_gdirections_dark, menu.isLight()), null, null, null);
recalcDestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
TargetPointsHelper helper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPoint target = helper.getPointToNavigate();
dismissMenu();
if (target != null) {
helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()), true, -1, target.getOriginalPointDescription());
mapActivity.getMapActions().recalculateRoute(false);
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
}
}
}
});
Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton);
ApplicationMode appMode = mapActivity.getMyApplication().getRoutingHelper().getAppMode();
if (!appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
findParkingButton.setVisibility(View.GONE);
}
findParkingButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_parking_dark, menu.isLight()), null, null, null);
findParkingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
PoiFiltersHelper helper = mapActivity.getMyApplication().getPoiFilters();
PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
mapActivity.showQuickSearch(parkingFilter);
}
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);
}
return view;
}
use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class FavouritesBottomSheetMenuFragment method selectFavorite.
private void selectFavorite(FavouritePoint point) {
OsmandApplication app = getMyApplication();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
FavouritesHelper favorites = app.getFavoritesHelper();
LatLon ll = new LatLon(point.getLatitude(), point.getLongitude());
switch(pointType) {
case START:
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription(app));
break;
case TARGET:
if (getActivity() != null) {
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(getActivity());
}
break;
case INTERMEDIATE:
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription(app));
break;
case HOME:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
break;
case WORK:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
break;
}
MapRouteInfoMenu routeMenu = getMapRouteInfoMenu();
if (routeMenu != null) {
setupMapRouteInfoMenuSpinners(routeMenu);
updateMapRouteInfoMenuFromIcon(routeMenu);
}
Fragment fragment = getTargetFragment();
if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), 0, null);
}
dismiss();
}
use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class DirectionsDialogs method directionsToDialogAndLaunchMap.
public static void directionsToDialogAndLaunchMap(final Activity act, final double lat, final double lon, final PointDescription name) {
final OsmandApplication ctx = (OsmandApplication) act.getApplication();
final TargetPointsHelper targetPointsHelper = ctx.getTargetPointsHelper();
if (targetPointsHelper.getIntermediatePoints().size() > 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(act);
builder.setTitle(R.string.new_directions_point_dialog);
builder.setItems(new String[] { act.getString(R.string.keep_intermediate_points), act.getString(R.string.clear_intermediate_points) }, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 1) {
targetPointsHelper.clearPointToNavigate(false);
}
ctx.getSettings().navigateDialog();
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
MapActivity.launchMapActivityMoveToTop(act);
}
});
builder.show();
} else {
ctx.getSettings().navigateDialog();
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
MapActivity.launchMapActivityMoveToTop(act);
}
}
use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class DashWaypointsFragment method setupTargets.
private void setupTargets() {
OsmandApplication app = getMyApplication();
View mainView = getView();
if (mainView == null || app == null) {
return;
}
final TargetPointsHelper helper = app.getTargetPointsHelper();
if (helper.getPointToNavigate() == null) {
AndroidUiHelper.updateVisibility(mainView.findViewById(R.id.main_fav), false);
return;
} else {
AndroidUiHelper.updateVisibility(mainView.findViewById(R.id.main_fav), true);
}
String collapseOrShowAll = SHOW_ALL ? getString(R.string.shared_string_collapse) : getString(R.string.shared_string_show_all);
((Button) mainView.findViewById(R.id.show_all)).setText(collapseOrShowAll);
mainView.findViewById(R.id.show_all).setOnClickListener(v -> {
SHOW_ALL = !SHOW_ALL;
setupView();
});
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.shared_string_waypoints) + " (" + helper.getIntermediatePointsWithTarget().size() + ")");
LinearLayout favorites = mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<TargetPoint> targetPoints = SHOW_ALL ? helper.getIntermediatePointsWithTarget() : Collections.singletonList(helper.getPointToNavigate());
List<DashLocationView> distances = new ArrayList<>();
for (final TargetPoint point : targetPoints) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.favorites_list_item, null, false);
TextView name = view.findViewById(R.id.favourite_label);
TextView label = view.findViewById(R.id.distance);
ImageView direction = 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(app.getUIUtilities().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 = view.findViewById(R.id.options);
options.setVisibility(View.VISIBLE);
final boolean optionsVisible = (SHOW_ALL && app.getTargetPointsHelper().getIntermediatePoints().size() > 0);
options.setImageDrawable(app.getUIUtilities().getThemedIcon(optionsVisible ? R.drawable.ic_overflow_menu_white : R.drawable.ic_action_remove_dark));
options.setOnClickListener(v -> {
if (optionsVisible) {
selectTargetModel(point, v);
} else {
deletePointConfirm(point, v);
}
});
ImageButton navigate = view.findViewById(R.id.navigate_to);
navigate.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_gdirections_dark));
navigate.setVisibility(target ? View.VISIBLE : View.GONE);
navigate.setOnClickListener(v -> dashboard.navigationAction());
view.setOnClickListener(v -> {
if (getActivity() != null) {
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), 15, point.getPointDescription(getActivity()), false, point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
favorites.addView(view);
}
this.distances = distances;
}
use of net.osmand.plus.helpers.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(ColorUtilities.getSecondaryTextColorId(nightMode)).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(ColorUtilities.getSecondaryTextColorId(nightMode)).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) {
targetPointsHelper.setStartPoint(latLon, true, name);
dismiss();
}
}).create();
items.add(replaceStartItem);
items.add(new DividerHalfItem(getContext(), getDividerColorId()));
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.subsequent_dest_description)).setDescriptionColorId(ColorUtilities.getSecondaryTextColorId(nightMode)).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(ColorUtilities.getSecondaryTextColorId(nightMode)).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(ColorUtilities.getSecondaryTextColorId(nightMode)).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