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