Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] Fix PT router overriding previous mode if subway layer active #7964

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

Tmpod
Copy link
Contributor

@Tmpod Tmpod commented Apr 20, 2024

The public transportation router was forcibly overriding the previously selected mode whenever the planning activity was resumed, with the subway layer active. For instance, if you started a route planning (which automatically uses PT when that layer is on), switched to car mode and then changed some driving options, when you got back to the planning screen, the router would have changed back to PT, instead of keeping it on car.

This occurred because of RoutingController#rebuildLastRoute, called whenever an activity (such as the driving options) concluded, which would, indirectly, call RoutingController#initLastRouteType. This method is responsible for defaulting the router to the most adequate type for the start+finish point combo, or, if the subway layer is selected, to set it to public transportaton.

So, the fix was rather simple -- instead of only checking if the the subway layer is active (and if we're not comming from a link, but that isn't relevant here), we also check if we were already planning something, or if we're starting a new route plan. We only want to reset the mode to PT on the latter case.

Fixes: #7701

@biodranik biodranik added Android Android development Route Planning Preview and plan your track labels Apr 20, 2024
@Tmpod
Copy link
Contributor Author

Tmpod commented Apr 20, 2024

Is that WebDebug failed test something I broke? Seemed like some network error 🤔

@biodranik
Copy link
Member

You can relaunch failed check manually.

The public transportation router was forcibly overriding the previously
selected mode whenever the planning activity was resumed, with the
subway layer active. For instance, if you started a route planning
(which automatically uses PT when that layer is on), switched to car
mode and then changed some driving options, when you got back to the
planning screen, the router would have changed back to PT, instead of
keeping it on car.

This occurred because of `RoutingController#rebuildLastRoute`, called
whenever an activity (such as the driving options) concluded, which
would, indirectly, call `RoutingController#initLastRouteType`. This
method is responsible for defaulting the router to the most
adequate type for the start+finish point combo, or, if the subway layer
is selected, to set it to public transportaton.

So, the fix was rather simple -- instead of only checking if the the
subway layer is active (and if we're not comming from a link, but that
isn't relevant here), we also check if we were already planning
something, or if we're starting a new route plan. We only want to reset
the mode to PT on the latter case.

Fixes: organicmaps#7701
Signed-off-by: tmpod <tom@tmpod.dev>
Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! I assume that this change was tested, and it works, correct?

Copy link
Member

@Jean-BaptisteC Jean-BaptisteC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Pixel 6 - Android 14

@Tmpod
Copy link
Contributor Author

Tmpod commented Apr 21, 2024 via email

@rtsisyk
Copy link
Contributor

rtsisyk commented Apr 24, 2024

What is blocking this PR from merging?

@Tmpod
Copy link
Contributor Author

Tmpod commented Apr 24, 2024 via email

@biodranik biodranik merged commit 827bf20 into organicmaps:master Apr 24, 2024
6 checks passed
@biodranik
Copy link
Member

@Tmpod Thanks, and welcome to the club!

@Tmpod
Copy link
Contributor Author

Tmpod commented Apr 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android development Route Planning Preview and plan your track
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A bug when building routes
4 participants