Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -160,6 +161,34 @@ class IsolatedActivityPluginTest {
executePluginTest(pluginAction)
}

@Test
fun locationLayerOptions_accuracyRingShownUsingTheSetColor() {
val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction<LocationLayerPlugin> {
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down