Merge branch 'master' of ssh://github.com/osmandapp/Osmand into RoutePreparationUiImprovements

This commit is contained in:
Chumva 2019-03-12 14:25:09 +02:00
commit 2327ff3426
4 changed files with 36 additions and 14 deletions

View file

@ -131,7 +131,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
public static final String TAG = "ShowRouteInfoDialogFragment";
private static final String ROUTE_ID_KEY = "route_id_key";
private static final String TRANSPORT_ROUTE_ID_KEY = "route_id_key";
private InterceptorLinearLayout mainView;
private View view;
@ -159,7 +159,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
private int shadowHeight;
private int zoomButtonsHeight;
private int routeId;
private int transportRouteId = -1;
private String destinationStreetStr = "";
private boolean paused;
@ -183,7 +183,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
Bundle args = getArguments();
if (args != null) {
routeId = args.getInt(ROUTE_ID_KEY);
transportRouteId = args.getInt(TRANSPORT_ROUTE_ID_KEY);
}
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
topShadowMargin = AndroidUtils.dpToPx(mapActivity, 9f);
@ -423,16 +423,20 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
return view;
}
public boolean isPublicTransportInfo() {
return transportRouteId != -1;
}
private void updateCards() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
cardsContainer.removeAllViews();
if (routeId != -1) {
if (transportRouteId != -1) {
List<TransportRouteResult> routes = routingHelper.getTransportRoutingHelper().getRoutes();
if (routes != null && routes.size() > routeId) {
TransportRouteResult routeResult = routingHelper.getTransportRoutingHelper().getRoutes().get(routeId);
PublicTransportCard card = new PublicTransportCard(mapActivity, routeResult, routeId);
if (routes != null && routes.size() > transportRouteId) {
TransportRouteResult routeResult = routingHelper.getTransportRoutingHelper().getRoutes().get(transportRouteId);
PublicTransportCard card = new PublicTransportCard(mapActivity, routeResult, transportRouteId);
menuCards.add(card);
cardsContainer.addView(card.build(mapActivity));
buildRowDivider(cardsContainer, false);
@ -1723,6 +1727,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
private void buildMenuButtons() {
UiUtilities iconsCache = app.getUIUtilities();
boolean publicTransportInfo = isPublicTransportInfo();
ImageButton printRoute = (ImageButton) view.findViewById(R.id.print_route);
printRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gprint_dark));
printRoute.setOnClickListener(new OnClickListener() {
@ -1731,15 +1737,24 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
print();
}
});
if (publicTransportInfo) {
printRoute.setVisibility(View.GONE);
}
ImageButton saveRoute = (ImageButton) view.findViewById(R.id.save_as_gpx);
saveRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gsave_dark));
saveRoute.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MapActivityActions.createSaveDirections(getActivity(), routingHelper).show();
FragmentActivity activity = getActivity();
if (activity != null) {
MapActivityActions.createSaveDirections(activity, routingHelper).show();
}
}
});
if (publicTransportInfo) {
saveRoute.setVisibility(View.GONE);
}
ImageButton shareRoute = (ImageButton) view.findViewById(R.id.share_as_gpx);
shareRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gshare_dark));
@ -1775,6 +1790,9 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
}
}
});
if (publicTransportInfo) {
shareRoute.setVisibility(View.GONE);
}
}
public class CumulativeInfo {
@ -2021,10 +2039,14 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
return HEADER_ONLY | HALF_SCREEN | FULL_SCREEN;
}
public static boolean showInstance(final MapActivity mapActivity, int routeId) {
public static boolean showInstance(final MapActivity mapActivity) {
return showInstance(mapActivity, -1);
}
public static boolean showInstance(final MapActivity mapActivity, int transportRouteId) {
try {
Bundle args = new Bundle();
args.putInt(ROUTE_ID_KEY, routeId);
args.putInt(TRANSPORT_ROUTE_ID_KEY, transportRouteId);
ShowRouteInfoDialogFragment fragment = new ShowRouteInfoDialogFragment();
fragment.setArguments(args);

View file

@ -42,7 +42,7 @@ public class DashNavigationFragment extends DashBaseFragment {
public void onClick(View view) {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
ShowRouteInfoDialogFragment.showInstance((MapActivity) activity, -1);
ShowRouteInfoDialogFragment.showInstance((MapActivity) activity);
}
}
});

View file

@ -54,7 +54,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
items.add(new DividerHalfItem(getContext()));
if (addLineMode) {
if (addLineMode && !snapToRoadEnabled) {
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
.setTitle(getString(R.string.shared_string_save))

View file

@ -51,7 +51,7 @@ public class SimpleRouteCard extends BaseCard {
info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showInstance(mapActivity, -1);
ShowRouteInfoDialogFragment.showInstance(mapActivity);
}
});
@ -94,7 +94,7 @@ public class SimpleRouteCard extends BaseCard {
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showInstance(mapActivity, -1);
ShowRouteInfoDialogFragment.showInstance(mapActivity);
}
});