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

View file

@ -42,7 +42,7 @@ public class DashNavigationFragment extends DashBaseFragment {
public void onClick(View view) { public void onClick(View view) {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity instanceof MapActivity) { 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())); items.add(new DividerHalfItem(getContext()));
if (addLineMode) { if (addLineMode && !snapToRoadEnabled) {
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)) .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
.setTitle(getString(R.string.shared_string_save)) .setTitle(getString(R.string.shared_string_save))

View file

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