Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d379b15

Browse files
tobrunkevin
andauthored
Cherrypick for release-xoai (#477)
* [docs] update changelog for release-xoai final * Set gps bearing immediately while change to gps mode (#470) Co-authored-by: kevin <kevin.li@mapbox.com>
1 parent e7212c1 commit d379b15

File tree

6 files changed

+55
-6
lines changed

6 files changed

+55
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
Mapbox welcomes participation and contributions from everyone. Please read [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) to get started.
44

5-
## 9.3.0-beta.1 - July 9, 2020
6-
7-
- Updated Mapbox GL Native library to v1.8.1. ([#464](https://github.com/mapbox/mapbox-gl-native-android/pull/464))
8-
- Not change file source status while changing cache path ([#457](https://github.com/mapbox/mapbox-gl-native-android/pull/457))
9-
10-
## 9.3.0-alpha.1 - July 2, 2020
5+
## 9.3.0 - July 15, 2020
116
Starting this release, the Mapbox Maps SDK for Android will use a pre-built GL Native binary licensed under the [Mapbox Terms of Service](https://www.mapbox.com/legal/tos). The license of the Maps SDK for Android remains BSD-2. For more information on using this and future releases, see [README.md](https://github.com/mapbox/mapbox-gl-native-android/blob/master/README.md). For more details on licensing, see [LICENSE.md](https://github.com/mapbox/mapbox-gl-native-android/blob/master/LICENSE.md).
127

138
### Improvements and bug fixes
@@ -16,13 +11,16 @@ Starting this release, the Mapbox Maps SDK for Android will use a pre-built GL N
1611
- Clarified the error message when an HTTP request has been cancelled. ([#433](https://github.com/mapbox/mapbox-gl-native-android/pull/433))
1712
- Fixed a memory leak that would occur when a source was removed. ([#412](https://github.com/mapbox/mapbox-gl-native-android/pull/412))
1813
- Fixed a bug that would halt the application during a scheduled snapshot when the map renderer was stopped. ([#390](https://github.com/mapbox/mapbox-gl-native-android/pull/390)
14+
- Not change file source status while changing cache path ([#457](https://github.com/mapbox/mapbox-gl-native-android/pull/457))
15+
- Avoid null pointer exception when the underlying hardware is too slow to create the surface ([#471](https://github.com/mapbox/mapbox-gl-native-android/pull/471))
1916

2017
### User location indicator
2118
- Double-tapping the map when the camera is tracking the user location indicator now zooms to the `LocationComponent`'s location. ([#378](https://github.com/mapbox/mapbox-gl-native-android/pull/378))
2219
- Improved camera rotation to use the shortest path. ([#426](https://github.com/mapbox/mapbox-gl-native-android/pull/426))
2320
- Added support for using a background image on GPS mode when `LocationComponentActivationOptions#useSpecializedLocationLayer` is activated . ([#439](https://github.com/mapbox/mapbox-gl-native-android/pull/439))
2421
- Fixed a bug where an in-progress animation of an updating `LocationComponent` would be interrupted when a style was changed. ([#437](https://github.com/mapbox/mapbox-gl-native-android/pull/437))
2522
- Updated documentation to reflect that the `FOREGROUND_LAYER` constant is usable for relative positioning in both normal and specialized rendering modes. [#413](https://github.com/mapbox/mapbox-gl-native-android/pull/413)
23+
- Set gps bearing immediately while changing to gps mode. ([#470](https://github.com/mapbox/mapbox-gl-native-android/pull/470))
2624

2725
### Other changes
2826
- Updated javadoc documentation for `removeSource`/`removeLayer`/`removeLayerAt`. ([#422](https://github.com/mapbox/mapbox-gl-native-android/pull/422))

MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ void cancelTiltAnimation() {
482482
cancelAnimator(ANIMATOR_TILT);
483483
}
484484

485+
void cancelAndRemoveGpsBearingAnimation() {
486+
cancelAnimator(ANIMATOR_LAYER_GPS_BEARING);
487+
animatorArray.remove(ANIMATOR_LAYER_GPS_BEARING);
488+
}
489+
485490
/**
486491
* Cancel the pulsing circle location animator.
487492
*/

MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION;
4949
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION;
5050
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS;
51+
import static com.mapbox.mapboxsdk.location.modes.RenderMode.GPS;
5152

5253
/**
5354
* The Location Component provides location awareness to your mobile application. Enabling this
@@ -673,6 +674,10 @@ public int getCameraMode() {
673674
*/
674675
public void setRenderMode(@RenderMode.Mode int renderMode) {
675676
checkActivationState();
677+
if (lastLocation != null && renderMode == GPS) {
678+
locationAnimatorCoordinator.cancelAndRemoveGpsBearingAnimation();
679+
locationLayerController.setGpsBearing(lastLocation.getBearing());
680+
}
676681
locationLayerController.setRenderMode(renderMode);
677682
updateLayerOffsets(true);
678683
updateCompassListenerState(true);

MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ void applyStyle(@NonNull LocationComponentOptions options) {
106106
}
107107
}
108108

109+
void setGpsBearing(float gpsBearing) {
110+
locationLayerRenderer.setGpsBearing(gpsBearing);
111+
}
112+
109113
void setRenderMode(@RenderMode.Mode int renderMode) {
110114
if (this.renderMode == renderMode) {
111115
return;

MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,15 @@ class LocationAnimatorCoordinatorTest {
677677
verify { animatorProvider.floatAnimator(any(), any(), 5) }
678678
}
679679

680+
@Test
681+
fun remove_gps_animator() {
682+
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
683+
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
684+
685+
locationAnimatorCoordinator.cancelAndRemoveGpsBearingAnimation()
686+
assertTrue(locationAnimatorCoordinator.animatorArray.get(ANIMATOR_LAYER_GPS_BEARING) == null)
687+
}
688+
680689
private fun getListenerHoldersSet(vararg animatorTypes: Int): Set<AnimatorListenerHolder> {
681690
return HashSet<AnimatorListenerHolder>().also {
682691
for (type in animatorTypes) {

MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,34 @@ class LocationComponentTest {
469469
verify(renderChangeListener).onRenderModeChanged(RenderMode.NORMAL)
470470
}
471471

472+
@Test
473+
fun change_to_gps_mode_symbolLayerBearingValue() {
474+
val location = Location("test")
475+
location.bearing = 50f
476+
val projection: Projection = mock(Projection::class.java)
477+
`when`(projection.getMetersPerPixelAtLatitude(location.latitude)).thenReturn(10.0)
478+
`when`(mapboxMap.projection).thenReturn(projection)
479+
`when`(style.isFullyLoaded).thenReturn(true)
480+
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
481+
482+
locationComponent.activateLocationComponent(
483+
LocationComponentActivationOptions.builder(context, style)
484+
.locationComponentOptions(locationComponentOptions)
485+
.useDefaultLocationEngine(false)
486+
.build()
487+
)
488+
locationComponent.isLocationComponentEnabled = true
489+
locationComponent.onStart()
490+
locationComponent.renderMode = RenderMode.NORMAL
491+
locationComponent.forceLocationUpdate(location)
492+
493+
verify(locationLayerController, times(0)).setGpsBearing(50f)
494+
495+
locationComponent.renderMode = RenderMode.GPS
496+
verify(locationLayerController, times(1)).setGpsBearing(50f)
497+
verify(locationAnimatorCoordinator).cancelAndRemoveGpsBearingAnimation()
498+
}
499+
472500
@Test
473501
fun tiltWhileTracking_notReady() {
474502
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)

0 commit comments

Comments
 (0)