You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
MapFragment and SupportMapFragment not using account manager #5075
We have deprecated MapboxMapOptions.accessToken() and you should be able to remove it and MapboxAccountManager provide the token. This isn't the case, If you remove options.accessToken() from the testapp fragment activity it will crash.
Adding a note here that we can remove StyleInitializer as a result, this was introduced to be able to handle the case where the user provided a style in xml and the accesstoken in code (this resulted in trying to load the style without an accesstoken). Now we always have a reference to that token so it may be deleted.
Discovered that this is going to be a little bigger lift than the previous conversions as it's possible to store the Access Token in the AppManifest for MapFragment and SupportMapFragment in addition to the usual programmatic style.
Ok, documenting what the final state should look like:
MapFragmentActivity should have MapboxMapOptions.accessToken() removed.
SupportMapFragmentActivity should have MapboxMapOptions.accessToken() removed.
MapFragment.onCreateView() should be refactored to check for MapboxAccountManager.getInstance() and use access token then first and only if it exists while relying on the existing MapboxMapOptions.accessToken() and AppManifest getToken() if it does not exist.
SupportMapFragment.onCreateView() should be refactored to check for MapboxAccountManager.getInstance() and use access token then first and only if it exists while relying on the existing MapboxMapOptions.accessToken() and AppManifest getToken() if it does not exist.
Add Deprecation tags to:
MapboxFragment.getToken()
SupportMapboxFragment.getToken()
MapboxConstants.KEY_META_DATA_MANIFEST
I think this should do it, but will find out after building and feedback from others.
I've noticed that when testing with both the access token set and not set in MapFragmentActivity the activity crashes when I try to load it in the TestApp. I've stepped through the code base and discovered that it makes it through MapFragment.createView() and discovers the access token fine both ways. The stack trace (see below) seems to indicate that it's an issue with Instant Run.
I'm going to verify that it was still good in the TestApp from master before my 3 changes on the branch to make sure that the debug process is starting from a legit spot.
Tested this on both Samsung S5 (API 21) and Nexus 5x (API 23) with both crashing with similar stacktraces. @cammace tested on a Samsung S6 and also had crashes. Next steps are to rebuild off of master from where the dev branch split to verify that it was starting at functioning spot.
Ok, feeling a little better about this now. I just rebuilt from master at the place where the dev branch split from ( 6368403 ) found that both MapFragmentActivity and SupportMapFragmentActivity worked as expected on a Nexus 5x and the Samsung S5. That narrows the issue down to the dev branch and the 3 commits that I made.
I checked out the dev branch again, rebuilt, and got both MapFragmentActivity and SupportMapFragmentActivity to work on both the Nexus 5x and Samsung S5 on the first try. Something must have been cached in locally on my computer. Weird.
After doing that I then re added the access token to both the MapFragmentActivity and SupportMapFragmentActivity and successfully ran them. This means that things are working now with both MapboxAccountManger and the now deprecated inline via MapboxMapOptions (see below). Should be ready to merge.
Activity
tobrun commentedon May 20, 2016
Capturing from chat with @cammace that @bleege is planning to pick this up, if not LMK.
tobrun commentedon May 20, 2016
Adding a note here that we can remove
StyleInitializeras a result, this was introduced to be able to handle the case where the user provided a style in xml and the accesstoken in code (this resulted in trying to load the style without an accesstoken). Now we always have a reference to that token so it may be deleted.bleege commentedon May 24, 2016
Picking this up now...
bleege commentedon May 24, 2016
Discovered that this is going to be a little bigger lift than the previous conversions as it's possible to store the Access Token in the AppManifest for
MapFragmentandSupportMapFragmentin addition to the usual programmatic style.tobrun commentedon May 25, 2016
@bleege while clicking through
MapboxMapOptionsjust now.I noticed that deprecation needs to be updated. I missed this in #5065
bleege commentedon May 25, 2016
@tobrun Yep, deprecation is part of the conversion to use MapboxAccountManager. I'll make sure it gets in there. 👍
bleege commentedon May 25, 2016
Ok, documenting what the final state should look like:
MapFragmentActivityshould have MapboxMapOptions.accessToken() removed.SupportMapFragmentActivityshould have MapboxMapOptions.accessToken() removed.MapFragment.onCreateView()should be refactored to check forMapboxAccountManager.getInstance()and use access token then first and only if it exists while relying on the existingMapboxMapOptions.accessToken()and AppManifestgetToken()if it does not exist.SupportMapFragment.onCreateView()should be refactored to check forMapboxAccountManager.getInstance()and use access token then first and only if it exists while relying on the existingMapboxMapOptions.accessToken()and AppManifestgetToken()if it does not exist.MapboxFragment.getToken()SupportMapboxFragment.getToken()MapboxConstants.KEY_META_DATA_MANIFESTI think this should do it, but will find out after building and feedback from others.
[android] #5075 - Adding deprecation notices
[android] #5075 - Removing options.accessToken() usage in MapFragment…
[android] #5075 - Setting MapboxAccountManager as preferred source fo…
bleege commentedon May 25, 2016
I've noticed that when testing with both the access token set and not set in
MapFragmentActivitythe activity crashes when I try to load it in the TestApp. I've stepped through the code base and discovered that it makes it throughMapFragment.createView()and discovers the access token fine both ways. The stack trace (see below) seems to indicate that it's an issue with Instant Run.I'm going to verify that it was still good in the TestApp from
masterbefore my 3 changes on the branch to make sure that the debug process is starting from a legit spot.bleege commentedon May 25, 2016
Tested this on both Samsung S5 (API 21) and Nexus 5x (API 23) with both crashing with similar stacktraces. @cammace tested on a Samsung S6 and also had crashes. Next steps are to rebuild off of
masterfrom where the dev branch split to verify that it was starting at functioning spot.[-]MapboxMapOptions not using account manager[/-][+]MapFragment and SupportMapFragment not using account manager[/+]bleege commentedon May 25, 2016
Ok, feeling a little better about this now. I just rebuilt from
masterat the place where the dev branch split from ( 6368403 ) found that bothMapFragmentActivityandSupportMapFragmentActivityworked as expected on a Nexus 5x and the Samsung S5. That narrows the issue down to the dev branch and the 3 commits that I made.bleege commentedon May 25, 2016
I checked out the dev branch again, rebuilt, and got both
MapFragmentActivityandSupportMapFragmentActivityto work on both the Nexus 5x and Samsung S5 on the first try. Something must have been cached in locally on my computer. Weird.After doing that I then re added the access token to both the
MapFragmentActivityandSupportMapFragmentActivityand successfully ran them. This means that things are working now with bothMapboxAccountMangerand the now deprecated inline viaMapboxMapOptions(see below). Should be ready to merge.[android] #5075 - Adding deprecation notices
[android] #5075 - Removing options.accessToken() usage in MapFragment…
[android] #5075 - Setting MapboxAccountManager as preferred source fo…
bleege commentedon May 26, 2016
Rebased and Merged!