diff --git a/app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/IsolatedActivityPluginTest.kt b/app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/IsolatedActivityPluginTest.kt index 437b2c220..64609494d 100644 --- a/app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/IsolatedActivityPluginTest.kt +++ b/app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/IsolatedActivityPluginTest.kt @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.plugins.locationlayer import android.Manifest import android.R import android.content.Context +import android.graphics.Color import android.location.Location import android.support.test.espresso.Espresso import android.support.test.espresso.IdlingRegistry @@ -160,6 +161,34 @@ class IsolatedActivityPluginTest { executePluginTest(pluginAction) } + @Test + fun locationLayerOptions_accuracyRingShownUsingTheSetColor() { + val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction { + override fun onGenericPluginAction(plugin: LocationLayerPlugin?, mapboxMap: MapboxMap?, + uiController: UiController, context: Context) { + mapView = fragment?.view as MapView? + LocationLayerPlugin(mapView!!, mapboxMap!!, null).apply { + renderMode = RenderMode.NORMAL + } + + uiController.loopMainThreadForAtLeast(500) + + val color = Color.parseColor("#4A90E2") + + // Check that the source property changes correctly + val source: GeoJsonSource? = mapboxMap.getSourceAs(LOCATION_SOURCE) + source?.querySourceFeatures(null)?.forEach { + assertThat(it.getNumberProperty(PROPERTY_ACCURACY_COLOR).toInt(), `is`(equalTo(color))) + } + + // Check that the layer shows the correct color + val layer: CircleLayer? = mapboxMap.getLayerAs(ACCURACY_LAYER) + assertThat(layer?.circleColor?.colorInt, `is`(equalTo(color))) + } + } + executePluginTest(pluginAction) + } + @After fun afterTest() { Timber.e("@After: unregister idle resource") diff --git a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayer.java b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayer.java index 277bf563f..6649b8dc9 100644 --- a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayer.java +++ b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayer.java @@ -68,6 +68,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchAlignment; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.colorToRgbaString; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; @@ -357,7 +358,7 @@ private void styleBearing(LocationLayerOptions options) { private void styleAccuracy(float accuracyAlpha, @ColorInt int accuracyColor) { locationFeature.addNumberProperty(PROPERTY_ACCURACY_ALPHA, accuracyAlpha); - locationFeature.addNumberProperty(PROPERTY_ACCURACY_COLOR, accuracyColor); + locationFeature.addStringProperty(PROPERTY_ACCURACY_COLOR, colorToRgbaString(accuracyColor)); refreshSource(); }