-
Notifications
You must be signed in to change notification settings - Fork 319
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
Use theme attribute to update MapView map style URL #1018
Conversation
@danesfeder correct, it's taken into account every time the |
Could you add the example you wrote to try to reproduce #994 as part of this PR? I think that would be great to have it anyway so we can test different scenarios or any regressions that might appear. |
I can confirm that the changes implemented in this PR don't solve #994 👀 When bringing app into the foreground after backgrounding nothing happened either, the map style didn't change 😓 Even after rotating the screen 👀 My hunch either a regression from #939 or the |
When recreating an Activity previously used style is loaded as it's stored with |
25b0876
to
ec0aa54
Compare
@danesfeder latest changes seem to fix the issue of changing the map style automatically between day/night mode (I still have to check if it changes automatically from night to day mode, day to night works 👌) but now during night it doesn't load the proper style at startup time (first time) 👀 Also noticed that if you rotate the screen loads the proper map style (night in the example above) but the upcoming maneuver arrow disappears. |
ec0aa54
to
0b9f8ba
Compare
if (savedInstanceState != null) { | ||
savedInstanceState.putString(MapboxConstants.STATE_STYLE_URL, mapStyleUrl); | ||
} else { | ||
mapView.setStyleUrl(mapStyleUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 found the issue - we were previously only updated when the saved instance state was not null, thus it was always day mode style.
@Guardiola31337 this is ready for 👀 |
0b9f8ba
to
7df894e
Compare
Nah, that doesn't solve it (at least completely) 👀 It fails when closing and then reopening. It seems something with initialization |
50c475b
to
6ced5fc
Compare
I was able to reproduce #1018 (comment) and fixed it by setting the style URL again in the XML, but keeping the saved instance state check in Currently looking into a public API to toggle the style (day vs. night) on the fly. Not sure if it's totally in scope of this PR but would make it easy to create an example. |
6ced5fc
to
ab9c47b
Compare
@Guardiola31337 @devotaaabel this PR is ready for 👀 |
0bcb27c
to
10f7a5a
Compare
10f7a5a
to
170e166
Compare
It's working now 🎉 I'd need to test if the theme changes from night to day but this is definitely good to go 🚀 Well done @danesfeder 👏 |
Closes #994
@mapbox/maps-android the
mapbox_styleUrl
is taken into account every time theMapView
is rendered for the first time correct?If we set the style URL from
navigationViewMapStyle
there shouldn't be any possible issues with caching and we can remove that method fromThemeSwitcher
.FWIW, I created an example that used the cancel btn to change the theme and recreate (simulating if this we to happen mid-drive) and I wasn't able to reproduce. @Guardiola31337 if you can provide a reliable way to reproduce, that would be great.