diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp')
15 files changed, 529 insertions, 529 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPluginTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt index e9552f974b..1d7c0c404b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPluginTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.locationlayer +package com.mapbox.mapboxsdk.location import android.Manifest import android.R @@ -19,14 +19,14 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import com.mapbox.mapboxsdk.constants.Style import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.* -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode -import com.mapbox.mapboxsdk.plugins.utils.* -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.pushSourceUpdates +import com.mapbox.mapboxsdk.location.LocationComponentConstants.* +import com.mapbox.mapboxsdk.location.modes.CameraMode +import com.mapbox.mapboxsdk.location.modes.RenderMode +import com.mapbox.mapboxsdk.location.utils.* +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest import com.mapbox.mapboxsdk.testapp.activity.SingleActivity import com.mapbox.mapboxsdk.utils.ColorUtils @@ -37,7 +37,7 @@ import org.junit.Assert.assertTrue import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class LocationLayerPluginTest : BaseActivityTest() { +class LocationComponentTest : BaseActivityTest() { @Rule @JvmField @@ -49,7 +49,7 @@ class LocationLayerPluginTest : BaseActivityTest() { private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource private val location: Location by lazy { - val initLocation = Location("test") + val initLocation = Location("") initLocation.latitude = 15.0 initLocation.longitude = 17.0 initLocation.bearing = 10f @@ -65,14 +65,14 @@ class LocationLayerPluginTest : BaseActivityTest() { } @Test - fun locationLayerPlugin_initializesLocationEngineCorrectlyWhenOnesNotProvided() { + fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context) + component.activateLocationComponent(context) - val locationEngine = plugin.locationEngine + val locationEngine = component.locationEngine assertThat(locationEngine, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) @@ -80,82 +80,82 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerPlugin_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() { + fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin( + component.activateLocationComponent( context, - LocationLayerOptions.builder(context) + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .accuracyAlpha(.5f) .accuracyColor(Color.BLUE) .build()) - val locationEngine = plugin.locationEngine - val pluginOptions = plugin.locationLayerOptions + val locationEngine = component.locationEngine + val componentOptions = component.locationComponentOptions assertThat(locationEngine, notNullValue()) - assertThat(pluginOptions, notNullValue()) + assertThat(componentOptions, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) assertThat(locationEngine?.isConnected, `is`(true)) - assertThat(pluginOptions?.accuracyAlpha(), `is`(.5f)) - assertThat(pluginOptions?.accuracyColor(), `is`(Color.BLUE)) + assertThat(componentOptions?.accuracyAlpha(), `is`(.5f)) + assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerPlugin_doesntInitializeEngineWhenNullProvided() { + fun locationComponent_doesntInitializeEngineWhenNullProvided() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin( + component.activateLocationComponent( null, - LocationLayerOptions.builder(context) + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .accuracyAlpha(.5f) .accuracyColor(Color.BLUE) .build()) - val locationEngine = plugin.locationEngine - val pluginOptions = plugin.locationLayerOptions + val locationEngine = component.locationEngine + val componentOptions = component.locationComponentOptions assertThat(locationEngine, nullValue()) - assertThat(pluginOptions, notNullValue()) + assertThat(componentOptions, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) - assertThat(pluginOptions?.accuracyAlpha(), `is`(.5f)) - assertThat(pluginOptions?.accuracyColor(), `is`(Color.BLUE)) + assertThat(componentOptions?.accuracyAlpha(), `is`(.5f)) + assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun settingMapStyleImmediatelyBeforeLoadingPlugin_doesStillLoadLayersProperly() { + fun settingMapStyleImmediatelyBeforeLoadingComponent_doesStillLoadLayersProperly() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { mapboxMap.setStyle(Style.LIGHT) - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - assertThat(plugin.renderMode, `is`(equalTo(RenderMode.NORMAL))) + assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL))) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true)) @@ -164,16 +164,16 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayer_doesntShowUntilFirstLocationFix() { + fun locationComponent_doesntShowUntilFirstLocationFix() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) // Source should be present but empty val mapView = (rule.activity as SingleActivity).mapView @@ -182,14 +182,14 @@ class LocationLayerPluginTest : BaseActivityTest() { .isEmpty(), `is`(true)) // Force the first location update - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) // Check if the puck is visible assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } // @@ -197,18 +197,18 @@ class LocationLayerPluginTest : BaseActivityTest() { // @Test - fun locationLayerOptions_disablingStaleStateDoesWorkCorrectly() { + fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() { validateTestSetup() - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(200) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) @@ -221,16 +221,16 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_loadsForegroundBitmapFromNameOption() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_loadsForegroundBitmapFromNameOption() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .backgroundName("custom-background-bitmap") .foregroundStaleName("custom-foreground-stale-bitmap") @@ -247,7 +247,7 @@ class LocationLayerPluginTest : BaseActivityTest() { mapboxMap.addImageFromDrawable("custom-bearing-bitmap", it) } - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false)) @@ -260,22 +260,22 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_loadsGpsNameWithGpsRenderMode() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundDrawable = ContextCompat.getDrawable(context, R.drawable.ic_media_play) foregroundDrawable?.let { @@ -288,28 +288,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_customIconNameRevertsToDefault() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_customIconNameRevertsToDefault() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap"))) - plugin.applyStyle(LocationLayerOptions.builder(context).build()) + component.applyStyle(LocationComponentOptions.builder(context).build()) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val revertedForegroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) @@ -317,28 +317,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_customGpsIconNameChangeBackWithMode() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_customGpsIconNameChangeBackWithMode() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap"))) - plugin.renderMode = RenderMode.NORMAL + component.renderMode = RenderMode.NORMAL uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val revertedForegroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) @@ -346,27 +346,27 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun stillStaleAfterResuming() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .staleStateTimeout(200) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(250) // engaging stale state uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true)) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true)) @@ -374,44 +374,44 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun stillNotStaleAfterResuming() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false)) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false)) assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_accuracyRingWithColor() { + fun locationComponentOptions_accuracyRingWithColor() { val color = Color.parseColor("#4A90E2") val rgbaColor = ColorUtils.colorToRgbaString(color) - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .accuracyColor(color) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) // Check that the source property changes correctly @@ -423,173 +423,173 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point - assertThat(plugin.locationEngine, nullValue()) + assertThat(component.locationEngine, nullValue()) assertEquals(point.latitude(), location.latitude, 0.1) assertEquals(point.longitude(), location.longitude, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun disablingPluginHidesPuck() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun disablingComponentHidesPuck() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER)[0].geometry() as Point assertEquals(point.latitude(), location.latitude, 0.1) assertEquals(point.longitude(), location.longitude, 0.1) - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun disablingPluginAndChangingStyleAllowsToEnableAgain() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun disablingComponentAndChangingStyleAllowsToEnableAgain() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() mapboxMap.setStyle(Style.LIGHT) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_isDisabledOnStart() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.activateLocationLayerPlugin(context, false) - assertThat(plugin.isLocationLayerEnabled, `is`(true)) + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.activateLocationComponent(context, false) + assertThat(component.isLocationLayerEnabled, `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_keepsEnabledWhenStoppedAndStarted() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - assertThat(plugin.isLocationLayerEnabled, `is`(true)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(true)) + component.activateLocationComponent(context, false) + assertThat(component.isLocationLayerEnabled, `is`(true)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_keepsDisabledWhenStoppedAndStarted() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.deactivateLocationLayerPlugin() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) + component.activateLocationComponent(context, false) + component.deactivateLocationComponent() + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_ableToChangeStyleAfterResuming() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() mapboxMap.setStyle(Style.DARK) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_interruptedDuringStyleChange() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) mapboxMap.setStyle(Style.DARK) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_forceLocationUpdateAfterStopped() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.onStop() - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.onStop() + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE).isEmpty(), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.onStop() - plugin.forceLocationUpdate(location) - plugin.onStart() + component.activateLocationComponent(context, false) + component.onStop() + component.forceLocationUpdate(location) + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point @@ -597,20 +597,20 @@ class LocationLayerPluginTest : BaseActivityTest() { assertEquals(point.longitude(), location.longitude, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_lifecycleChangeRightAfterStyleReload() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.setStyle(Style.LIGHT) - plugin.onStop() + component.onStop() uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) - plugin.onStart() + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point @@ -624,28 +624,28 @@ class LocationLayerPluginTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun mapChange_settingPluginStyle() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun mapChange_settingComponentStyle() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) - val options = LocationLayerOptions.builder(context) + val options = LocationComponentOptions.builder(context) .accuracyColor(Color.RED) .build() pushSourceUpdates(styleChangeIdlingResource) { - plugin.applyStyle(options) + component.applyStyle(options) } uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) @@ -653,44 +653,44 @@ class LocationLayerPluginTest : BaseActivityTest() { @Test fun mapChange_forcingLocation() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) pushSourceUpdates(styleChangeIdlingResource) { - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) } uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) } @Test - fun mapChange_settingMapStyleBeforePluginCreation() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun mapChange_settingMapStyleBeforeComponentCreation() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) - val options = LocationLayerOptions.builder(context) + val options = LocationComponentOptions.builder(context) .accuracyColor(Color.RED) .build() pushSourceUpdates(styleChangeIdlingResource) { - plugin.forceLocationUpdate(location) - plugin.applyStyle(options) + component.forceLocationUpdate(location) + component.applyStyle(options) } } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) @@ -698,35 +698,35 @@ class LocationLayerPluginTest : BaseActivityTest() { @Test fun animators_layerBearingCorrect() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.GPS + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.GPS location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1) location.bearing = 92f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(92.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraLatLngBearingCorrect() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING_GPS + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING_GPS location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(location.latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -735,7 +735,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(location.latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -743,21 +743,21 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraBearingCorrect() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.NONE_GPS + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE_GPS val latitude = mapboxMap.cameraPosition.target.latitude val longitude = mapboxMap.cameraPosition.target.longitude location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -766,7 +766,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -774,22 +774,22 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraNoneCorrect() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val latitude = mapboxMap.cameraPosition.target.latitude val longitude = mapboxMap.cameraPosition.target.longitude val bearing = mapboxMap.cameraPosition.bearing location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -798,7 +798,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -806,231 +806,231 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_focalPointAdjustment() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.cameraMode = CameraMode.NONE - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.cameraMode = CameraMode.NONE + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.uiSettings.focalPoint, nullValue()) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontZoomWhileNotTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val zoom = mapboxMap.cameraPosition.zoom - plugin.zoomWhileTracking(10.0) + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_zoomWhileTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(10.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(10.0, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_zoomWhileTrackingCanceledOnModeChange() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(15.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(15.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) - plugin.cameraMode = CameraMode.NONE + component.cameraMode = CameraMode.NONE uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontZoomWhileStopped() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) - plugin.cameraMode = CameraMode.TRACKING + component.cameraMode = CameraMode.TRACKING uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val zoom = mapboxMap.cameraPosition.zoom - plugin.onStop() - plugin.zoomWhileTracking(10.0) + component.onStop() + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_cancelZoomWhileTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(15.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(15.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) - plugin.cancelZoomWhileTrackingAnimation() + component.cancelZoomWhileTrackingAnimation() uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontTiltWhileNotTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val tilt = mapboxMap.cameraPosition.tilt - plugin.tiltWhileTracking(30.0) + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_tiltWhileTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(30.0, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_tiltWhileTrackingCanceledOnModeChange() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) - plugin.cameraMode = CameraMode.NONE + component.cameraMode = CameraMode.NONE uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) assertEquals(30.0 / 2.0, mapboxMap.cameraPosition.tilt, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontTiltWhileStopped() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING val tilt = mapboxMap.cameraPosition.tilt - plugin.onStop() - plugin.tiltWhileTracking(30.0) + component.onStop() + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_cancelTiltWhileTracking() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) - plugin.cancelTiltWhileTrackingAnimation() + component.cancelTiltWhileTrackingAnimation() uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) assertEquals(30.0 / 2.0, mapboxMap.cameraPosition.tilt, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun cameraPositionAdjustedToTrackingModeWhenPluginEnabled() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING_GPS - plugin.forceLocationUpdate(location) - plugin.deactivateLocationLayerPlugin() + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING_GPS + component.forceLocationUpdate(location) + component.deactivateLocationComponent() mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(51.0, 17.0))) mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(90.0)) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(location.bearing.toDouble(), mapboxMap.cameraPosition.bearing, 0.1) @@ -1039,28 +1039,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun compassEngine_onPluginInitializedDefaultIsProvided() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun compassEngine_onComponentInitializedDefaultIsProvided() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - assertTrue(plugin.compassEngine is LocationLayerCompassEngine) + component.activateLocationComponent(context, false) + assertTrue(component.compassEngine is LocationComponentCompassEngine) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun compassEngine_changesWhenNewProvided() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) val engine: CompassEngine = object : CompassEngine { override fun addCompassListener(compassListener: CompassListener) { } @@ -1083,13 +1083,13 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - plugin.compassEngine = engine - assertThat(plugin.compassEngine, notNullValue()) - assertThat(plugin.compassEngine, `is`(equalTo(engine))) + component.compassEngine = engine + assertThat(component.compassEngine, notNullValue()) + assertThat(component.compassEngine, `is`(equalTo(engine))) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @After @@ -1098,7 +1098,7 @@ class LocationLayerPluginTest : BaseActivityTest() { IdlingRegistry.getInstance().unregister(styleChangeIdlingResource) } - private fun executePluginTest(listener: LocationLayerPluginAction.OnPerformLocationLayerPluginAction) { - onView(withId(R.id.content)).perform(LocationLayerPluginAction(mapboxMap, listener)) + private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) { + onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener)) } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt index a0f23ce485..c50d1817fd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.locationlayer +package com.mapbox.mapboxsdk.location import android.Manifest import android.R @@ -17,13 +17,13 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import com.mapbox.mapboxsdk.constants.Style import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.* -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode -import com.mapbox.mapboxsdk.plugins.utils.* -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY -import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.pushSourceUpdates +import com.mapbox.mapboxsdk.location.LocationComponentConstants.* +import com.mapbox.mapboxsdk.location.modes.RenderMode +import com.mapbox.mapboxsdk.location.utils.* +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY +import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates import com.mapbox.mapboxsdk.style.sources.GeoJsonSource import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest import com.mapbox.mapboxsdk.testapp.activity.SingleActivity @@ -39,7 +39,7 @@ import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class LocationLayerTest : BaseActivityTest() { +class LocationLayerControllerTest : BaseActivityTest() { @Rule @JvmField @@ -51,7 +51,7 @@ class LocationLayerTest : BaseActivityTest() { private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource private val location: Location by lazy { - val initLocation = Location("test") + val initLocation = Location("") initLocation.latitude = 15.0 initLocation.longitude = 17.0 initLocation.bearing = 10f @@ -72,16 +72,16 @@ class LocationLayerTest : BaseActivityTest() { @Test fun renderModeNormal_sourceDoesGetAdded() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.NORMAL + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.NORMAL uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.getSource(LOCATION_SOURCE), notNullValue()) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } // @@ -90,12 +90,12 @@ class LocationLayerTest : BaseActivityTest() { @Test fun renderModeNormal_trackingNormalLayersDoGetAdded() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.NORMAL - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.NORMAL + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true)) @@ -104,17 +104,17 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun renderModeCompass_bearingLayersDoGetAdded() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.COMPASS - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.COMPASS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true)) @@ -123,17 +123,17 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun renderModeGps_navigationLayersDoGetAdded() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true)) @@ -142,20 +142,20 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun dontShowPuckWhenRenderModeSetAndPluginDisabled() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun dontShowPuckWhenRenderModeSetAndComponentDisabled() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true) - plugin.renderMode = RenderMode.GPS + component.renderMode = RenderMode.GPS uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false)) @@ -164,19 +164,19 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun whenLocationLayerPluginDisabled_doesSetAllLayersToVisibilityNone() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.NORMAL - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.NORMAL + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) @@ -188,24 +188,24 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun onMapChange_locationLayerLayersDoGetRedrawn() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun onMapChange_locationComponentLayersDoGetRedrawn() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.renderMode = RenderMode.NORMAL - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.NORMAL + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) mapboxMap.setStyleUrl(Style.LIGHT) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - assertThat(plugin.renderMode, `is`(equalTo(RenderMode.NORMAL))) + assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL))) // Check that the Source has been re-added to the new map style val source: GeoJsonSource? = mapboxMap.getSourceAs(LOCATION_SOURCE) @@ -219,17 +219,17 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun whenStyleChanged_continuesUsingStaleIcons() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(100).build()) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build()) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(150) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) @@ -243,23 +243,23 @@ class LocationLayerTest : BaseActivityTest() { assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun whenStyleChanged_staleStateChanges() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(1).build()) + component.activateLocationComponent(context, false) + component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build()) styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) pushSourceUpdates(styleChangeIdlingResource) { - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) } } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) @@ -267,16 +267,16 @@ class LocationLayerTest : BaseActivityTest() { @Test fun whenStyleChanged_layerVisibilityUpdates() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) var show = true pushSourceUpdates(styleChangeIdlingResource) { if (show) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) } else { - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() } show = !show } @@ -284,7 +284,7 @@ class LocationLayerTest : BaseActivityTest() { uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) @@ -292,12 +292,12 @@ class LocationLayerTest : BaseActivityTest() { @Test fun accuracy_visibleWithNewLocation() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0)) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION) @@ -306,16 +306,16 @@ class LocationLayerTest : BaseActivityTest() { .getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun accuracy_visibleWhenCameraEased() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0), 300) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300) @@ -325,17 +325,17 @@ class LocationLayerTest : BaseActivityTest() { .getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun accuracy_visibleWhenCameraMoved() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0)) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300) @@ -345,7 +345,7 @@ class LocationLayerTest : BaseActivityTest() { .getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @After @@ -354,7 +354,7 @@ class LocationLayerTest : BaseActivityTest() { IdlingRegistry.getInstance().unregister(styleChangeIdlingResource) } - private fun executePluginTest(listener: LocationLayerPluginAction.OnPerformLocationLayerPluginAction) { - onView(withId(R.id.content)).perform(LocationLayerPluginAction(mapboxMap, listener)) + private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) { + onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener)) } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/LocationLayerPluginAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt index af2c9adf35..ad80a3333e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/LocationLayerPluginAction.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.content.Context import android.support.test.espresso.UiController @@ -6,11 +6,11 @@ import android.support.test.espresso.ViewAction import android.support.test.espresso.matcher.ViewMatchers.isDisplayed import android.view.View import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin +import com.mapbox.mapboxsdk.location.LocationComponent import org.hamcrest.Matcher -class LocationLayerPluginAction(private val mapboxMap: MapboxMap, - private val onPerformLocationLayerPluginAction: OnPerformLocationLayerPluginAction) : ViewAction { +class LocationComponentAction(private val mapboxMap: MapboxMap, + private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction { override fun getConstraints(): Matcher<View> { return isDisplayed() @@ -21,20 +21,20 @@ class LocationLayerPluginAction(private val mapboxMap: MapboxMap, } override fun perform(uiController: UiController, view: View) { - val plugin = mapboxMap.locationLayerPlugin + val component = mapboxMap.locationComponent while (mapboxMap.getSource("mapbox-location-source") == null) { uiController.loopMainThreadForAtLeast(MapboxTestingUtils.MAP_RENDER_DELAY) } - onPerformLocationLayerPluginAction.onLocationLayerPluginAction( - plugin, + onPerformLocationComponentAction.onLocationComponentAction( + component, mapboxMap, uiController, view.context) } - interface OnPerformLocationLayerPluginAction { - fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, uiController: UiController, context: Context) + interface OnPerformLocationComponentAction { + fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/MapboxTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt index b77ab127d9..591901385f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/MapboxTestingUtils.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.graphics.Bitmap import android.graphics.Canvas diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapFragmentReadyIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapFragmentReadyIdlingResource.kt index fa6b732770..4d02a4d2bf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapFragmentReadyIdlingResource.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapFragmentReadyIdlingResource.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.os.Handler import android.os.Looper diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java index f084343594..9adb30ee32 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapReadyIdlingResource.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils; +package com.mapbox.mapboxsdk.location.utils; import android.app.Activity; import android.os.Handler; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt index ab2c855c65..0f37498a29 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/StyleChangeIdlingResource.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.support.test.espresso.IdlingResource import com.mapbox.mapboxsdk.maps.MapView diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 8597a9ac14..a0594d8b83 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -816,7 +816,7 @@ android:value="com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" /> </activity> <activity - android:name=".activity.location.LocationLayerMapChangeActivity" + android:name=".activity.location.LocationMapChangeActivity" android:description="@string/description_location_map_change" android:label="@string/activity_location_map_change"> <meta-data @@ -827,7 +827,7 @@ android:value=".activity.FeatureOverviewActivity" /> </activity> <activity - android:name=".activity.location.LocationLayerModesActivity" + android:name=".activity.location.LocationModesActivity" android:description="@string/description_location_modes" android:label="@string/activity_location_modes"> <meta-data @@ -838,7 +838,7 @@ android:value=".activity.FeatureOverviewActivity" /> </activity> <activity - android:name=".activity.location.LocationLayerFragmentActivity" + android:name=".activity.location.LocationFragmentActivity" android:description="@string/description_location_fragment" android:label="@string/activity_location_fragment"> <meta-data diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerFragmentActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt index fa2c84ab92..974dc5c571 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerFragmentActivity.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt @@ -17,11 +17,11 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.MapView import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin +import com.mapbox.mapboxsdk.location.LocationComponent import com.mapbox.mapboxsdk.testapp.R import kotlinx.android.synthetic.main.activity_location_layer_fragment.* -class LocationLayerFragmentActivity : AppCompatActivity() { +class LocationFragmentActivity : AppCompatActivity() { private lateinit var permissionsManager: PermissionsManager override fun onCreate(savedInstanceState: Bundle?) { @@ -46,13 +46,13 @@ class LocationLayerFragmentActivity : AppCompatActivity() { if (savedInstanceState == null) { fragmentManager .beginTransaction() - .replace(R.id.container, LocationLayerFragment.newInstance(), LocationLayerFragment.TAG) + .replace(R.id.container, LocationFragment.newInstance(), LocationFragment.TAG) .commit() } } else { permissionsManager = PermissionsManager(object : PermissionsListener { override fun onExplanationNeeded(permissionsToExplain: MutableList<String>?) { - Toast.makeText(this@LocationLayerFragmentActivity, "You need to accept location permissions.", + Toast.makeText(this@LocationFragmentActivity, "You need to accept location permissions.", Toast.LENGTH_SHORT).show() } @@ -61,7 +61,7 @@ class LocationLayerFragmentActivity : AppCompatActivity() { if (savedInstanceState == null) { fragmentManager .beginTransaction() - .replace(R.id.container, LocationLayerFragment.newInstance(), LocationLayerFragment.TAG) + .replace(R.id.container, LocationFragment.newInstance(), LocationFragment.TAG) .commit() } } else { @@ -78,17 +78,17 @@ class LocationLayerFragmentActivity : AppCompatActivity() { permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults) } - class LocationLayerFragment : Fragment(), LocationEngineListener { + class LocationFragment : Fragment(), LocationEngineListener { companion object { - const val TAG = "LLFragment" - fun newInstance(): LocationLayerFragment { - return LocationLayerFragment() + const val TAG = "LFragment" + fun newInstance(): LocationFragment { + return LocationFragment() } } private lateinit var mapView: MapView private lateinit var mapboxMap: MapboxMap - private var plugin: LocationLayerPlugin? = null + private var component: LocationComponent? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { mapView = MapView(inflater.context) @@ -100,16 +100,16 @@ class LocationLayerFragmentActivity : AppCompatActivity() { mapView.onCreate(savedInstanceState) mapView.getMapAsync { mapboxMap = it - plugin = mapboxMap.locationLayerPlugin - plugin?.activateLocationLayerPlugin(activity) - plugin?.locationEngine?.addLocationEngineListener(this) + component = mapboxMap.locationComponent + component?.activateLocationComponent(activity) + component?.locationEngine?.addLocationEngineListener(this) } } override fun onLocationChanged(location: Location?) { if (location != null) { mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 12.0)) - plugin?.locationEngine?.removeLocationEngineListener(this) + component?.locationEngine?.removeLocationEngineListener(this) } } @@ -150,7 +150,7 @@ class LocationLayerFragmentActivity : AppCompatActivity() { override fun onDestroyView() { super.onDestroyView() mapView.onDestroy() - plugin?.locationEngine?.removeLocationEngineListener(this) + component?.locationEngine?.removeLocationEngineListener(this) } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerMapChangeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java index e59627d35e..6fa514e28b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerMapChangeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java @@ -13,13 +13,13 @@ import com.mapbox.android.core.permissions.PermissionsManager; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin; -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode; +import com.mapbox.mapboxsdk.location.LocationComponent; +import com.mapbox.mapboxsdk.location.modes.RenderMode; import com.mapbox.mapboxsdk.testapp.R; import java.util.List; -public class LocationLayerMapChangeActivity extends AppCompatActivity implements OnMapReadyCallback { +public class LocationMapChangeActivity extends AppCompatActivity implements OnMapReadyCallback { private MapView mapView; private MapboxMap mapboxMap; @@ -51,14 +51,14 @@ public class LocationLayerMapChangeActivity extends AppCompatActivity implements permissionsManager = new PermissionsManager(new PermissionsListener() { @Override public void onExplanationNeeded(List<String> permissionsToExplain) { - Toast.makeText(LocationLayerMapChangeActivity.this, "You need to accept location permissions.", + Toast.makeText(LocationMapChangeActivity.this, "You need to accept location permissions.", Toast.LENGTH_SHORT).show(); } @Override public void onPermissionResult(boolean granted) { if (granted) { - mapView.getMapAsync(LocationLayerMapChangeActivity.this); + mapView.getMapAsync(LocationMapChangeActivity.this); } else { finish(); } @@ -77,14 +77,14 @@ public class LocationLayerMapChangeActivity extends AppCompatActivity implements @Override public void onMapReady(MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; - activateLocationLayer(); + activateLocationComponent(); } @SuppressLint("MissingPermission") - private void activateLocationLayer() { - LocationLayerPlugin locationPlugin = mapboxMap.getLocationLayerPlugin(); - locationPlugin.activateLocationLayerPlugin(this); - locationPlugin.setRenderMode(RenderMode.COMPASS); + private void activateLocationComponent() { + LocationComponent locationComponent = mapboxMap.getLocationComponent(); + locationComponent.activateLocationComponent(this); + locationComponent.setRenderMode(RenderMode.COMPASS); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerModesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java index 4c8c8eda4b..f2f57c854d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationLayerModesActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java @@ -25,19 +25,19 @@ import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions; -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin; -import com.mapbox.mapboxsdk.plugins.locationlayer.OnCameraTrackingChangedListener; -import com.mapbox.mapboxsdk.plugins.locationlayer.OnLocationLayerClickListener; -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode; -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode; +import com.mapbox.mapboxsdk.location.LocationComponentOptions; +import com.mapbox.mapboxsdk.location.LocationComponent; +import com.mapbox.mapboxsdk.location.OnCameraTrackingChangedListener; +import com.mapbox.mapboxsdk.location.OnLocationComponentClickListener; +import com.mapbox.mapboxsdk.location.modes.CameraMode; +import com.mapbox.mapboxsdk.location.modes.RenderMode; import com.mapbox.mapboxsdk.testapp.R; import java.util.ArrayList; import java.util.List; -public class LocationLayerModesActivity extends AppCompatActivity implements OnMapReadyCallback, - LocationEngineListener, OnLocationLayerClickListener, OnCameraTrackingChangedListener { +public class LocationModesActivity extends AppCompatActivity implements OnMapReadyCallback, + LocationEngineListener, OnLocationComponentClickListener, OnCameraTrackingChangedListener { private MapView mapView; private Button locationModeBtn; @@ -45,7 +45,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM private PermissionsManager permissionsManager; - private LocationLayerPlugin locationLayerPlugin; + private LocationComponent locationComponent; private LocationEngine locationEngine; private MapboxMap mapboxMap; private boolean customStyle; @@ -63,7 +63,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM locationModeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (locationLayerPlugin == null) { + if (locationComponent == null) { return; } showModeListDialog(); @@ -74,7 +74,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM locationTrackingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (locationLayerPlugin == null) { + if (locationComponent == null) { return; } showTrackingListDialog(); @@ -89,14 +89,14 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM permissionsManager = new PermissionsManager(new PermissionsListener() { @Override public void onExplanationNeeded(List<String> permissionsToExplain) { - Toast.makeText(LocationLayerModesActivity.this, "You need to accept location permissions.", + Toast.makeText(LocationModesActivity.this, "You need to accept location permissions.", Toast.LENGTH_SHORT).show(); } @Override public void onPermissionResult(boolean granted) { if (granted) { - mapView.getMapAsync(LocationLayerModesActivity.this); + mapView.getMapAsync(LocationModesActivity.this); } else { finish(); } @@ -125,11 +125,11 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM locationEngine.addLocationEngineListener(this); locationEngine.activate(); - locationLayerPlugin = mapboxMap.getLocationLayerPlugin(); - locationLayerPlugin.addOnLocationClickListener(this); - locationLayerPlugin.addOnCameraTrackingChangedListener(this); + locationComponent = mapboxMap.getLocationComponent(); + locationComponent.addOnLocationClickListener(this); + locationComponent.addOnCameraTrackingChangedListener(this); - activateLocationLayer(); + activateLocationComponent(); } @Override @@ -141,7 +141,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM @SuppressLint("MissingPermission") @Override public boolean onOptionsItemSelected(MenuItem item) { - if (locationLayerPlugin == null) { + if (locationComponent == null) { return super.onOptionsItemSelected(item); } @@ -152,19 +152,19 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM } else if (id == R.id.action_map_style_change) { toggleMapStyle(); return true; - } else if (id == R.id.action_plugin_disable) { - locationLayerPlugin.deactivateLocationLayerPlugin(); + } else if (id == R.id.action_component_disable) { + locationComponent.deactivateLocationComponent(); return true; - } else if (id == R.id.action_plugin_enabled) { - activateLocationLayer(); + } else if (id == R.id.action_component_enabled) { + activateLocationComponent(); return true; } return super.onOptionsItemSelected(item); } - private void activateLocationLayer() { - if (locationLayerPlugin != null) { + private void activateLocationComponent() { + if (locationComponent != null) { int[] padding; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { padding = new int[] {0, 750, 0, 0}; @@ -173,30 +173,30 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM } if (savedInstanceState == null) { - LocationLayerOptions options = LocationLayerOptions.builder(this) + LocationComponentOptions options = LocationComponentOptions.builder(this) .padding(padding) .layerBelow("waterway-label") .build(); - locationLayerPlugin.activateLocationLayerPlugin(locationEngine, options); + locationComponent.activateLocationComponent(locationEngine, options); } else { - LocationLayerOptions options = locationLayerPlugin - .getLocationLayerOptions() + LocationComponentOptions options = locationComponent + .getLocationComponentOptions() .toBuilder() .padding(padding) .build(); - locationLayerPlugin.setLocationEngine(locationEngine); - locationLayerPlugin.applyStyle(options); + locationComponent.setLocationEngine(locationEngine); + locationComponent.applyStyle(options); } } } public void toggleStyle() { customStyle = !customStyle; - locationLayerPlugin.applyStyle( + locationComponent.applyStyle( this, - customStyle ? R.style.CustomLocationLayer : R.style.mapbox_LocationLayer); + customStyle ? R.style.CustomLocationComponent : R.style.mapbox_LocationComponent); } public void toggleMapStyle() { @@ -274,8 +274,8 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM } @Override - public void onLocationLayerClick() { - Toast.makeText(this, "OnLocationLayerClick", Toast.LENGTH_LONG).show(); + public void onLocationComponentClick() { + Toast.makeText(this, "OnlocationComponentClick", Toast.LENGTH_LONG).show(); } private void showModeListDialog() { @@ -304,7 +304,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM } private void setRendererMode(@RenderMode.Mode int mode) { - locationLayerPlugin.setRenderMode(mode); + locationComponent.setRenderMode(mode); if (mode == RenderMode.NORMAL) { locationModeBtn.setText("Normal"); } else if (mode == RenderMode.COMPASS) { @@ -330,20 +330,20 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM String selectedTrackingType = trackingTypes.get(position); locationTrackingBtn.setText(selectedTrackingType); if (selectedTrackingType.contentEquals("None")) { - locationLayerPlugin.setCameraMode(CameraMode.NONE); + locationComponent.setCameraMode(CameraMode.NONE); } else if (selectedTrackingType.contentEquals("Tracking")) { - locationLayerPlugin.setCameraMode(CameraMode.TRACKING); + locationComponent.setCameraMode(CameraMode.TRACKING); } else if (selectedTrackingType.contentEquals("Tracking Compass")) { - locationLayerPlugin.setCameraMode(CameraMode.TRACKING_COMPASS); + locationComponent.setCameraMode(CameraMode.TRACKING_COMPASS); } else if (selectedTrackingType.contentEquals("Tracking GPS")) { - locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS); + locationComponent.setCameraMode(CameraMode.TRACKING_GPS); } else if (selectedTrackingType.contentEquals("Tracking GPS North")) { - locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS_NORTH); + locationComponent.setCameraMode(CameraMode.TRACKING_GPS_NORTH); } listPopup.dismiss(); - if (locationLayerPlugin.getCameraMode() != CameraMode.NONE) { - locationLayerPlugin.zoomWhileTracking(15, 750, new MapboxMap.CancelableCallback() { + if (locationComponent.getCameraMode() != CameraMode.NONE) { + locationComponent.zoomWhileTracking(15, 750, new MapboxMap.CancelableCallback() { @Override public void onCancel() { // No impl @@ -351,7 +351,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM @Override public void onFinish() { - locationLayerPlugin.tiltWhileTracking(45); + locationComponent.tiltWhileTracking(45); } }); } else { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java index 3e9f0853ea..5750e97d63 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java @@ -18,8 +18,8 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin; -import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode; +import com.mapbox.mapboxsdk.location.LocationComponent; +import com.mapbox.mapboxsdk.location.modes.RenderMode; import com.mapbox.mapboxsdk.testapp.R; import java.util.List; @@ -30,7 +30,7 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements LocationEngineListener { private MapView mapView; - private LocationLayerPlugin locationLayerPlugin; + private LocationComponent locationComponent; private LocationEngine locationEngine; private PermissionsManager permissionsManager; @@ -43,8 +43,8 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements fabManualUpdate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (locationLayerPlugin != null && locationLayerPlugin.getLocationEngine() == null) { - locationLayerPlugin.forceLocationUpdate( + if (locationComponent != null && locationComponent.getLocationEngine() == null) { + locationComponent.forceLocationUpdate( Utils.getRandomLocation(LatLngBounds.from(60, 25, 40, -5))); } } @@ -55,11 +55,11 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements fabToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (locationLayerPlugin != null) { - locationLayerPlugin.setLocationEngine(locationLayerPlugin.getLocationEngine() == null ? locationEngine : + if (locationComponent != null) { + locationComponent.setLocationEngine(locationComponent.getLocationEngine() == null ? locationEngine : null); - if (locationLayerPlugin.getLocationEngine() == null) { + if (locationComponent.getLocationEngine() == null) { fabToggle.setImageResource(R.drawable.ic_layers_clear); fabManualUpdate.setEnabled(true); fabManualUpdate.setAlpha(1f); @@ -118,9 +118,9 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements locationEngine.addLocationEngineListener(this); locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); locationEngine.activate(); - locationLayerPlugin = mapboxMap.getLocationLayerPlugin(); - locationLayerPlugin.activateLocationLayerPlugin(this, locationEngine); - locationLayerPlugin.setRenderMode(RenderMode.COMPASS); + locationComponent = mapboxMap.getLocationComponent(); + locationComponent.activateLocationComponent(this, locationEngine); + locationComponent.setRenderMode(RenderMode.COMPASS); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_mode.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_mode.xml index 7ce217ecd9..7004999f88 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_mode.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_mode.xml @@ -9,12 +9,12 @@ android:title="Toggle custom Map style" app:showAsAction="never"/> - <item android:id="@+id/action_plugin_disable" + <item android:id="@+id/action_component_disable" android:title="Disable" app:showAsAction="never"/> - <item android:id="@+id/action_plugin_enabled" + <item android:id="@+id/action_component_enabled" android:title="Enabled" app:showAsAction="never"/> </menu>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml index 05035760f9..cb9c2043dc 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml @@ -73,6 +73,6 @@ <string name="description_draggable_marker">Click to add a marker, long-click to drag</string> <string name="description_location_map_change">Change map\'s style while location is displayed</string> <string name="description_location_modes">Showcases location render and tracking modes</string> - <string name="description_location_fragment">Uses LocationLayer in a Fragment</string> + <string name="description_location_fragment">Uses LocationComponent in a Fragment</string> <string name="description_location_manual">Force location updates and don\'t rely on the engine</string> </resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml index facc169299..a0525171a5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml @@ -38,7 +38,7 @@ <style name="AppTheme" parent="AppBaseTheme" /> - <style name="CustomLocationLayer" parent="mapbox_LocationLayer"> + <style name="CustomLocationComponent" parent="mapbox_LocationComponent"> <item name="mapbox_foregroundDrawable">@drawable/custom_user_icon</item> <item name="mapbox_bearingDrawable">@drawable/custom_user_arrow</item> |