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 @@ -150,6 +150,25 @@ class LocationLayerTest {
executePluginTest(pluginAction)
}

@Test
fun dontShowPuckWhenRenderModeSetAndPluginDisabled() {
val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction<LocationLayerPlugin> {
override fun onGenericPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
plugin.forceLocationUpdate(location)
plugin.isLocationLayerEnabled = false
plugin.renderMode = RenderMode.GPS
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executePluginTest(pluginAction)
}

@Test
fun whenLocationLayerPluginDisabled_doesSetAllLayersToVisibilityNone() {
val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction<LocationLayerPlugin> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,40 @@ void applyStyle(@NonNull LocationLayerOptions options) {

void setRenderMode(@RenderMode.Mode int renderMode) {
this.renderMode = renderMode;
boolean isStale = locationFeature.getBooleanProperty(PROPERTY_LOCATION_STALE);

switch (renderMode) {
case RenderMode.NORMAL:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, false);
break;
case RenderMode.COMPASS:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, true);
break;
case RenderMode.GPS:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, false);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, false);
setLayerVisibility(BEARING_LAYER, false);
break;
default:
break;
}

determineIconsSource(options);
if (!isHidden) {
boolean isStale = locationFeature.getBooleanProperty(PROPERTY_LOCATION_STALE);
switch (renderMode) {
case RenderMode.NORMAL:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, false);
break;
case RenderMode.COMPASS:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, true);
break;
case RenderMode.GPS:
styleForeground(options);
setLayerVisibility(SHADOW_LAYER, false);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, false);
setLayerVisibility(BEARING_LAYER, false);
break;
default:
break;
}

determineIconsSource(options);
}
}

int getRenderMode() {
Expand All @@ -177,15 +179,15 @@ int getRenderMode() {
//

void show() {
setRenderMode(renderMode);
isHidden = false;
setRenderMode(renderMode);
}

void hide() {
isHidden = true;
for (String layerId : layerMap) {
setLayerVisibility(layerId, false);
}
isHidden = true;
}

private void setLayerVisibility(String layerId, boolean visible) {
Expand Down