Change public transport RP buttons
This commit is contained in:
parent
b4e2b03917
commit
87033868ba
6 changed files with 77 additions and 19 deletions
|
@ -791,6 +791,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
mapActivity.getMapView().setMapPositionX(visible ? 0 : 1);
|
||||
}
|
||||
}
|
||||
mapActivity.updateStatusBarColor();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -856,7 +857,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex, int initialMenuState) {
|
||||
public static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex, int initialMenuState) {
|
||||
try {
|
||||
ChooseRouteFragment fragment = new ChooseRouteFragment();
|
||||
Bundle args = new Bundle();
|
||||
|
@ -880,7 +881,9 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
if (mapActivity != null) {
|
||||
useRouteInfoMenu = false;
|
||||
dismiss();
|
||||
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||
if (!mapActivity.getMyApplication().getRoutingHelper().isPublicTransportMode()) {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -530,6 +530,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
for (int i = 0; i < routes.size(); i++) {
|
||||
route = routes.get(i);
|
||||
PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, i);
|
||||
card.setShowButtonCustomTitle(mapActivity.getString(R.string.shared_string_show_on_map));
|
||||
card.setShowBottomShadow(i == routes.size() - 1 && !showPedestrianCard);
|
||||
card.setShowTopShadow(i != 0);
|
||||
card.setListener(this);
|
||||
|
@ -673,8 +674,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||
((PublicTransportCard) card).getRouteId(), MenuState.FULL_SCREEN);
|
||||
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
|
||||
setupCards();
|
||||
openMenuHeaderOnly();
|
||||
showRouteOnMap(mapActivity, ((PublicTransportCard) card).getRouteId());
|
||||
}
|
||||
} else if (card instanceof SimpleRouteCard) {
|
||||
hide();
|
||||
|
@ -1387,11 +1387,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
if (app.getRoutingHelper().isPublicTransportMode()) {
|
||||
if (isTransportRouteCalculated() && hasTransportRoutes()) {
|
||||
if (mapActivity.getPointToNavigate() != null) {
|
||||
hide();
|
||||
}
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||
app.getTransportRoutingHelper().getCurrentRoute(), MenuState.HEADER_ONLY);
|
||||
showRouteOnMap(mapActivity, app.getTransportRoutingHelper().getCurrentRoute());
|
||||
}
|
||||
} else {
|
||||
if (mapActivity.getPointToNavigate() != null) {
|
||||
|
@ -1402,6 +1398,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
}
|
||||
|
||||
private void showRouteOnMap(@NonNull MapActivity mapActivity, int routeIndex) {
|
||||
if (mapActivity.getPointToNavigate() != null) {
|
||||
hide();
|
||||
}
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||
routeIndex, MenuState.HEADER_ONLY);
|
||||
}
|
||||
|
||||
private void clickRouteCancel() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
|
|
@ -1608,10 +1608,22 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
|||
|
||||
@Override
|
||||
public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
|
||||
if (card instanceof PublicTransportCard && buttonIndex == 0) {
|
||||
openMenuFullScreen();
|
||||
} else if (card instanceof RouteDirectionsCard && buttonIndex >= 0) {
|
||||
showDirectionsInfo(buttonIndex);
|
||||
if (card instanceof PublicTransportCard) {
|
||||
switch (buttonIndex) {
|
||||
case PublicTransportCard.DETAILS_BUTTON_INDEX:
|
||||
openMenuFullScreen();
|
||||
break;
|
||||
case PublicTransportCard.SHOW_BUTTON_INDEX:
|
||||
RouteDetailsFragmentListener listener = getRouteDetailsListener();
|
||||
if (listener != null) {
|
||||
listener.onNavigationRequested();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (card instanceof RouteDirectionsCard) {
|
||||
if (buttonIndex >= 0) {
|
||||
showDirectionsInfo(buttonIndex);
|
||||
}
|
||||
} else if (card instanceof RouteStatisticCard) {
|
||||
switch (buttonIndex) {
|
||||
case RouteStatisticCard.DETAILS_BUTTON_INDEX:
|
||||
|
|
|
@ -47,6 +47,7 @@ public class PublicTransportCard extends BaseCard {
|
|||
private PublicTransportCardListener transportCardListener;
|
||||
|
||||
private int routeId;
|
||||
private String showButtonCustomTitle;
|
||||
|
||||
public interface PublicTransportCardListener {
|
||||
void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull TransportRouteResultSegment segment);
|
||||
|
@ -54,7 +55,8 @@ public class PublicTransportCard extends BaseCard {
|
|||
void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull LatLon start, @NonNull LatLon end);
|
||||
}
|
||||
|
||||
public PublicTransportCard(MapActivity mapActivity, LatLon startLocation, LatLon endLocation, TransportRouteResult routeResult, int routeId) {
|
||||
public PublicTransportCard(@NonNull MapActivity mapActivity, LatLon startLocation, LatLon endLocation,
|
||||
@NonNull TransportRouteResult routeResult, int routeId) {
|
||||
super(mapActivity);
|
||||
this.startLocation = startLocation;
|
||||
this.endLocation = endLocation;
|
||||
|
@ -75,6 +77,14 @@ public class PublicTransportCard extends BaseCard {
|
|||
this.transportCardListener = listener;
|
||||
}
|
||||
|
||||
public String getShowButtonCustomTitle() {
|
||||
return showButtonCustomTitle;
|
||||
}
|
||||
|
||||
public void setShowButtonCustomTitle(String showButtonCustomTitle) {
|
||||
this.showButtonCustomTitle = showButtonCustomTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateContent() {
|
||||
List<TransportRouteResultSegment> segments = routeResult.getSegments();
|
||||
|
@ -123,8 +133,20 @@ public class PublicTransportCard extends BaseCard {
|
|||
if (isCurrentRoute()) {
|
||||
color = ContextCompat.getColor(app, R.color.card_and_list_background_light);
|
||||
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_active_light, R.drawable.btn_active_dark);
|
||||
showButtonDescr.setText(R.string.shared_string_selected);
|
||||
showButton.setOnClickListener(null);
|
||||
if (!Algorithms.isEmpty(showButtonCustomTitle)) {
|
||||
showButtonDescr.setText(showButtonCustomTitle);
|
||||
} else {
|
||||
showButtonDescr.setText(R.string.shared_string_control_start);
|
||||
}
|
||||
showButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CardListener listener = getListener();
|
||||
if (listener != null) {
|
||||
listener.onCardButtonPressed(PublicTransportCard.this, SHOW_BUTTON_INDEX);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
|
||||
|
@ -132,7 +154,11 @@ public class PublicTransportCard extends BaseCard {
|
|||
} else {
|
||||
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
|
||||
}
|
||||
showButtonDescr.setText(R.string.shared_string_show_on_map);
|
||||
if (!Algorithms.isEmpty(showButtonCustomTitle)) {
|
||||
showButtonDescr.setText(showButtonCustomTitle);
|
||||
} else {
|
||||
showButtonDescr.setText(R.string.shared_string_show_on_map);
|
||||
}
|
||||
showButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -288,6 +288,7 @@ public class TransportRoutingHelper {
|
|||
}
|
||||
|
||||
public synchronized void clearCurrentRoute(LatLon newFinalLocation) {
|
||||
currentRoute = -1;
|
||||
routes = null;
|
||||
walkingRouteSegments = null;
|
||||
app.getWaypointHelper().setNewRoute(new RouteCalculationResult(""));
|
||||
|
|
|
@ -52,9 +52,11 @@ import net.osmand.plus.dialogs.DirectionsDialogs;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.TransportRoutingHelper;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
|
||||
|
@ -396,7 +398,13 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.dismissCardDialog();
|
||||
doRoute(false);
|
||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
TransportRoutingHelper transportRoutingHelper = routingHelper.getTransportRoutingHelper();
|
||||
if (routingHelper.isPublicTransportMode() && transportRoutingHelper.getCurrentRoute() >= 0) {
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), transportRoutingHelper.getCurrentRoute(), MenuState.FULL_SCREEN);
|
||||
} else {
|
||||
doRoute(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -758,6 +766,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// default buttons
|
||||
boolean routePlanningMode = false;
|
||||
RoutingHelper rh = mapActivity.getRoutingHelper();
|
||||
TransportRoutingHelper trh = mapActivity.getRoutingHelper().getTransportRoutingHelper();
|
||||
if (rh.isRoutePlanningMode()) {
|
||||
routePlanningMode = true;
|
||||
} else if ((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) && !rh.isFollowingMode()) {
|
||||
|
@ -773,7 +782,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (rh.isFollowingMode()) {
|
||||
if (rh.isPublicTransportMode() && trh.getCurrentRoute() >= 0) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_action_bus_dark);
|
||||
routePlanningBtn.setIconColorId(R.color.color_myloc_distance);
|
||||
} else if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
routePlanningBtn.setIconColorId(R.color.color_myloc_distance);
|
||||
} else if (routePlanningMode) {
|
||||
|
|
Loading…
Reference in a new issue