[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent
This commit is contained in:
committed by
Łukasz Paczos
parent
cf7752c80c
commit
907612e93d
File diff suppressed because it is too large
Load Diff
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils;
|
||||
package com.mapbox.mapboxsdk.location.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user