Adding pulsing circle to LocationComponent options (#172)

* [location] added pulsing locationcomponent circle

* adjusting style switching to roll through all styles

* refactored methods and variables for prefix continuity

* refactoring to after making start and stop private methods

* refactoring to stop pulsing when LocationComponent is disabled and color/speed is then selected

* refactoring to swap interpolator string paramete for interpolator interface parameter

* LocationLayerControllerTest adjustments

* removing unneeded test

* more rebase adjustments

* [location] added pulsing locationcomponent circle

* refactoring to swap interpolator string paramete for interpolator interface parameter

* consolidating pulse ui update methods

* gl-native vendor bump

* refactor to check for activation with locationcomponent

* Update MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java

Co-Authored-By: Łukasz Paczos <lukasz.paczos@mapbox.com>

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

Co-Authored-By: Łukasz Paczos <lukasz.paczos@mapbox.com>

* Update MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java

Co-Authored-By: Łukasz Paczos <lukasz.paczos@mapbox.com>

* Update MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java

Co-Authored-By: Łukasz Paczos <lukasz.paczos@mapbox.com>

* Update MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java

Co-Authored-By: Łukasz Paczos <lukasz.paczos@mapbox.com>

* Added incompatibility docs

* Added pulse alpha range explanation

* Do not wrap pulsing circle animator with an animator set to avoid leaks

Co-authored-by: Łukasz Paczos <lukasz.paczos@mapbox.com>
This commit is contained in:
Langston Smith
2020-04-30 03:28:36 -07:00
committed by GitHub
parent 6fd498ed16
commit 9bfe77df40
32 changed files with 1772 additions and 213 deletions

View File

@@ -35,7 +35,9 @@ class LocationAnimatorCoordinatorTest {
@Before
fun setUp() {
locationAnimatorCoordinator = LocationAnimatorCoordinator(projection, animatorSetProvider, animatorProvider)
locationAnimatorCoordinator = LocationAnimatorCoordinator(projection,
animatorSetProvider,
animatorProvider)
configureAnimatorProvider()
every { projection.getMetersPerPixelAtLatitude(any()) } answers { 1.0 }
every { animatorSetProvider.startAnimation(any(), any(), any()) } answers {}

View File

@@ -3,6 +3,9 @@ package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.view.animation.LinearInterpolator;
import androidx.annotation.NonNull;
import com.mapbox.mapboxsdk.R;
@@ -66,6 +69,44 @@ public class LocationComponentActivationOptionsTest {
assertNotNull(locationComponentActivationOptions);
}
@Test
public void sanityWithDefaultPulsingCircle() throws Exception {
when(style.isFullyLoaded()).thenReturn(true);
LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
.accuracyAlpha(0.5f)
.pulseEnabled(true)
.build();
assertNotNull(locationComponentOptions);
LocationComponentActivationOptions locationComponentActivationOptions =
LocationComponentActivationOptions.builder(context, style)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(true)
.build();
assertNotNull(locationComponentActivationOptions);
}
@Test
public void sanityWithCustomizedPulsingCircle() throws Exception {
when(style.isFullyLoaded()).thenReturn(true);
LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
.accuracyAlpha(0.5f)
.pulseEnabled(true)
.pulseColor(Color.RED)
.pulseInterpolator(new LinearInterpolator())
.build();
assertNotNull(locationComponentOptions);
LocationComponentActivationOptions locationComponentActivationOptions =
LocationComponentActivationOptions.builder(context, style)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(true)
.build();
assertNotNull(locationComponentActivationOptions);
}
@Test
public void includingBothStyleResAndComponentOptions_causesExceptionToBeThrown() throws Exception {

View File

@@ -72,7 +72,7 @@ public class LocationComponentOptionsTest {
public void passingBothLayerPositionOptions_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("You cannot set both layerAbove and layerBelow options."
+ "Choose one or the other.");
+ " Choose one or the other.");
LocationComponentOptions.builder(context)
.layerAbove("above")
.layerBelow("below")

View File

@@ -37,6 +37,7 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PULSING_CIRCLE_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_ACCURACY;
@@ -167,6 +168,23 @@ public class LocationLayerControllerTest {
verify(style).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
}
@Test
public void onInitialization_pulsingCircleLayerIsAdded() {
OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
LayerSourceProvider sourceProvider = buildLayerProvider();
Layer pulsingCircleLayer = mock(Layer.class);
when(sourceProvider.generatePulsingCircleLayer()).thenReturn(pulsingCircleLayer);
GeoJsonSource locationSource = mock(GeoJsonSource.class);
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(pulsingCircleLayer, ACCURACY_LAYER);
}
@Test
public void onInitialization_numberOfCachedLayerIdsIsConstant() {
OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
@@ -184,7 +202,7 @@ public class LocationLayerControllerTest {
controller.initializeComponents(mapboxMap.getStyle(), options);
assertEquals(5, layerSet.size());
assertEquals(6, layerSet.size());
}
@Test
@@ -402,7 +420,7 @@ public class LocationLayerControllerTest {
layerController.applyStyle(options);
verify(style, times(0)).removeLayer(any(String.class));
verify(style, times(5)).addLayerBelow(any(Layer.class), any(String.class));
verify(style, times(6)).addLayerBelow(any(Layer.class), any(String.class));
}
@Test
@@ -424,7 +442,7 @@ public class LocationLayerControllerTest {
verify(style, times(0)).removeLayer(any(String.class));
verify(style, times(1)).addLayer(any(Layer.class));
verify(style, times(4)).addLayerBelow(any(Layer.class), Mockito.<String>any());
verify(style, times(5)).addLayerBelow(any(Layer.class), Mockito.<String>any());
}
@Test
@@ -726,6 +744,9 @@ public class LocationLayerControllerTest {
Layer accuracyLayer = mock(Layer.class);
when(accuracyLayer.getId()).thenReturn(ACCURACY_LAYER);
when(layerSourceProvider.generateAccuracyLayer()).thenReturn(accuracyLayer);
Layer pulsingCircleLayer = mock(Layer.class);
when(pulsingCircleLayer.getId()).thenReturn(PULSING_CIRCLE_LAYER);
when(layerSourceProvider.generatePulsingCircleLayer()).thenReturn(pulsingCircleLayer);
return layerSourceProvider;
}