diff --git a/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserDefaultValueTest.kt b/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserDefaultValueTest.kt index 871163b640..efcea99bd0 100644 --- a/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserDefaultValueTest.kt +++ b/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserDefaultValueTest.kt @@ -4,7 +4,7 @@ package com.mapbox.maps.testapp.gestures.generated import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode import com.mapbox.maps.plugin.gestures.gestures import com.mapbox.maps.testapp.BaseMapTest import org.junit.Assert.assertEquals @@ -27,9 +27,9 @@ class GesturesAttributeParserDefaultValueTest : BaseMapTest() { mapView.gestures.getSettings().rotateEnabled ) assertEquals( - "zoomEnabled test failed..", + "pinchToZoomEnabled test failed..", true, - mapView.gestures.getSettings().zoomEnabled + mapView.gestures.getSettings().pinchToZoomEnabled ) assertEquals( "scrollEnabled test failed..", @@ -42,14 +42,19 @@ class GesturesAttributeParserDefaultValueTest : BaseMapTest() { mapView.gestures.getSettings().pitchEnabled ) assertEquals( - "panScrollMode test failed..", - PanScrollMode.HORIZONTAL_AND_VERTICAL, - mapView.gestures.getSettings().panScrollMode + "scrollMode test failed..", + ScrollMode.HORIZONTAL_AND_VERTICAL, + mapView.gestures.getSettings().scrollMode ) assertEquals( - "doubleTapToZoomEnabled test failed..", + "doubleTapToZoomInEnabled test failed..", true, - mapView.gestures.getSettings().doubleTapToZoomEnabled + mapView.gestures.getSettings().doubleTapToZoomInEnabled + ) + assertEquals( + "doubleTouchToZoomOutEnabled test failed..", + true, + mapView.gestures.getSettings().doubleTouchToZoomOutEnabled ) assertEquals( "quickZoomEnabled test failed..", @@ -62,44 +67,34 @@ class GesturesAttributeParserDefaultValueTest : BaseMapTest() { mapView.gestures.getSettings().focalPoint ) assertEquals( - "scaleVelocityAnimationEnabled test failed..", - true, - mapView.gestures.getSettings().scaleVelocityAnimationEnabled - ) - assertEquals( - "rotateVelocityAnimationEnabled test failed..", + "pinchToZoomDecelerationEnabled test failed..", true, - mapView.gestures.getSettings().rotateVelocityAnimationEnabled + mapView.gestures.getSettings().pinchToZoomDecelerationEnabled ) assertEquals( - "flingVelocityAnimationEnabled test failed..", + "rotateDecelerationEnabled test failed..", true, - mapView.gestures.getSettings().flingVelocityAnimationEnabled + mapView.gestures.getSettings().rotateDecelerationEnabled ) assertEquals( - "increaseRotateThresholdWhenScaling test failed..", + "scrollDecelerationEnabled test failed..", true, - mapView.gestures.getSettings().increaseRotateThresholdWhenScaling + mapView.gestures.getSettings().scrollDecelerationEnabled ) assertEquals( - "disableRotateWhenScaling test failed..", + "increaseRotateThresholdWhenPinchingToZoom test failed..", true, - mapView.gestures.getSettings().disableRotateWhenScaling + mapView.gestures.getSettings().increaseRotateThresholdWhenPinchingToZoom ) assertEquals( - "increaseScaleThresholdWhenRotating test failed..", + "increasePinchToZoomThresholdWhenRotating test failed..", true, - mapView.gestures.getSettings().increaseScaleThresholdWhenRotating + mapView.gestures.getSettings().increasePinchToZoomThresholdWhenRotating ) assertEquals( - "zoomRate test failed..", + "zoomAnimationAmount test failed..", 1f, - mapView.gestures.getSettings().zoomRate - ) - assertEquals( - "pixelRatio test failed..", - pixelRatio, - mapView.gestures.getSettings().pixelRatio + mapView.gestures.getSettings().zoomAnimationAmount ) } } diff --git a/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserTest.kt b/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserTest.kt index bf782a50c5..f79f4a2259 100644 --- a/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserTest.kt +++ b/app/src/androidTest/java/com/mapbox/maps/testapp/gestures/generated/GesturesAttributeParserTest.kt @@ -6,7 +6,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.mapbox.maps.R import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode import com.mapbox.maps.plugin.gestures.gestures import com.mapbox.maps.testapp.BaseMapTest import org.junit.Assert.assertEquals @@ -38,9 +38,9 @@ class GesturesAttributeParserTest : BaseMapTest() { mapView.gestures.getSettings().rotateEnabled ) assertEquals( - "zoomEnabled test failed..", + "pinchToZoomEnabled test failed..", false, - mapView.gestures.getSettings().zoomEnabled + mapView.gestures.getSettings().pinchToZoomEnabled ) assertEquals( "scrollEnabled test failed..", @@ -53,14 +53,19 @@ class GesturesAttributeParserTest : BaseMapTest() { mapView.gestures.getSettings().pitchEnabled ) assertEquals( - "panScrollMode test failed..", - PanScrollMode.HORIZONTAL_AND_VERTICAL, - mapView.gestures.getSettings().panScrollMode + "scrollMode test failed..", + ScrollMode.HORIZONTAL_AND_VERTICAL, + mapView.gestures.getSettings().scrollMode ) assertEquals( - "doubleTapToZoomEnabled test failed..", + "doubleTapToZoomInEnabled test failed..", false, - mapView.gestures.getSettings().doubleTapToZoomEnabled + mapView.gestures.getSettings().doubleTapToZoomInEnabled + ) + assertEquals( + "doubleTouchToZoomOutEnabled test failed..", + false, + mapView.gestures.getSettings().doubleTouchToZoomOutEnabled ) assertEquals( "quickZoomEnabled test failed..", @@ -73,44 +78,34 @@ class GesturesAttributeParserTest : BaseMapTest() { mapView.gestures.getSettings().focalPoint ) assertEquals( - "scaleVelocityAnimationEnabled test failed..", + "pinchToZoomDecelerationEnabled test failed..", false, - mapView.gestures.getSettings().scaleVelocityAnimationEnabled + mapView.gestures.getSettings().pinchToZoomDecelerationEnabled ) assertEquals( - "rotateVelocityAnimationEnabled test failed..", + "rotateDecelerationEnabled test failed..", false, - mapView.gestures.getSettings().rotateVelocityAnimationEnabled + mapView.gestures.getSettings().rotateDecelerationEnabled ) assertEquals( - "flingVelocityAnimationEnabled test failed..", + "scrollDecelerationEnabled test failed..", false, - mapView.gestures.getSettings().flingVelocityAnimationEnabled + mapView.gestures.getSettings().scrollDecelerationEnabled ) assertEquals( - "increaseRotateThresholdWhenScaling test failed..", + "increaseRotateThresholdWhenPinchingToZoom test failed..", false, - mapView.gestures.getSettings().increaseRotateThresholdWhenScaling + mapView.gestures.getSettings().increaseRotateThresholdWhenPinchingToZoom ) assertEquals( - "disableRotateWhenScaling test failed..", + "increasePinchToZoomThresholdWhenRotating test failed..", false, - mapView.gestures.getSettings().disableRotateWhenScaling - ) - assertEquals( - "increaseScaleThresholdWhenRotating test failed..", - false, - mapView.gestures.getSettings().increaseScaleThresholdWhenRotating - ) - assertEquals( - "zoomRate test failed..", - 0.9f, - mapView.gestures.getSettings().zoomRate + mapView.gestures.getSettings().increasePinchToZoomThresholdWhenRotating ) assertEquals( - "pixelRatio test failed..", + "zoomAnimationAmount test failed..", 0.9f, - mapView.gestures.getSettings().pixelRatio + mapView.gestures.getSettings().zoomAnimationAmount ) } } diff --git a/app/src/main/java/com/mapbox/maps/testapp/examples/GesturesActivity.kt b/app/src/main/java/com/mapbox/maps/testapp/examples/GesturesActivity.kt index dfece1ba2f..03db90ab56 100644 --- a/app/src/main/java/com/mapbox/maps/testapp/examples/GesturesActivity.kt +++ b/app/src/main/java/com/mapbox/maps/testapp/examples/GesturesActivity.kt @@ -1,6 +1,7 @@ package com.mapbox.maps.testapp.examples import android.annotation.SuppressLint +import android.graphics.BitmapFactory import android.os.Bundle import android.os.Handler import android.view.* @@ -18,7 +19,11 @@ import com.mapbox.geojson.Point import com.mapbox.maps.CameraOptions import com.mapbox.maps.MapboxMap import com.mapbox.maps.Style -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode +import com.mapbox.maps.plugin.annotation.annotations +import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager +import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions +import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager import com.mapbox.maps.plugin.gestures.* import com.mapbox.maps.testapp.R import com.mapbox.maps.testapp.databinding.ActivityGesturesBinding @@ -34,6 +39,7 @@ class GesturesActivity : AppCompatActivity() { private lateinit var gesturesManager: AndroidGesturesManager private lateinit var gestureAlertsAdapter: GestureAlertsAdapter private var focalPointLatLng: Point? = null + private var pointAnnotationManager: PointAnnotationManager? = null private lateinit var binding: ActivityGesturesBinding override fun onCreate(savedInstanceState: Bundle?) { @@ -47,7 +53,9 @@ class GesturesActivity : AppCompatActivity() { .zoom(15.0) .build() ) - mapboxMap.loadStyleUri(Style.MAPBOX_STREETS) + mapboxMap.loadStyleUri(Style.MAPBOX_STREETS) { + it.addImage(MARKER_IMAGE_ID, BitmapFactory.decodeResource(resources, R.drawable.red_marker)) + } binding.mapView.waitForLayout { initializeMap() @@ -178,15 +186,15 @@ class GesturesActivity : AppCompatActivity() { item.isChecked = focalPointLatLng == null } R.id.menu_gesture_animation -> { - gesturesPlugin.scaleVelocityAnimationEnabled = - !gesturesPlugin.scaleVelocityAnimationEnabled - gesturesPlugin.rotateVelocityAnimationEnabled = - !gesturesPlugin.rotateVelocityAnimationEnabled - gesturesPlugin.flingVelocityAnimationEnabled = - !gesturesPlugin.flingVelocityAnimationEnabled - item.isChecked = gesturesPlugin.scaleVelocityAnimationEnabled && - gesturesPlugin.rotateVelocityAnimationEnabled && - gesturesPlugin.flingVelocityAnimationEnabled + gesturesPlugin.pinchToZoomDecelerationEnabled = + !gesturesPlugin.pinchToZoomDecelerationEnabled + gesturesPlugin.rotateDecelerationEnabled = + !gesturesPlugin.rotateDecelerationEnabled + gesturesPlugin.scrollDecelerationEnabled = + !gesturesPlugin.scrollDecelerationEnabled + item.isChecked = gesturesPlugin.pinchToZoomDecelerationEnabled && + gesturesPlugin.rotateDecelerationEnabled && + gesturesPlugin.scrollDecelerationEnabled } R.id.menu_gesture_rotate -> { gesturesPlugin.rotateEnabled = !gesturesPlugin.rotateEnabled @@ -197,16 +205,20 @@ class GesturesActivity : AppCompatActivity() { item.isChecked = gesturesPlugin.pitchEnabled } R.id.menu_gesture_zoom -> { - gesturesPlugin.zoomEnabled = !gesturesPlugin.zoomEnabled - item.isChecked = gesturesPlugin.zoomEnabled + gesturesPlugin.pinchToZoomEnabled = !gesturesPlugin.pinchToZoomEnabled + item.isChecked = gesturesPlugin.pinchToZoomEnabled } R.id.menu_gesture_scroll -> { gesturesPlugin.scrollEnabled = !gesturesPlugin.scrollEnabled item.isChecked = gesturesPlugin.scrollEnabled } R.id.menu_gesture_double_tap -> { - gesturesPlugin.doubleTapToZoomEnabled = !gesturesPlugin.doubleTapToZoomEnabled - item.isChecked = gesturesPlugin.doubleTapToZoomEnabled + gesturesPlugin.doubleTapToZoomInEnabled = !gesturesPlugin.doubleTapToZoomInEnabled + item.isChecked = gesturesPlugin.doubleTapToZoomInEnabled + } + R.id.menu_gesture_double_touch -> { + gesturesPlugin.doubleTouchToZoomOutEnabled = !gesturesPlugin.doubleTouchToZoomOutEnabled + item.isChecked = gesturesPlugin.doubleTouchToZoomOutEnabled } R.id.menu_gesture_quick_zoom -> { gesturesPlugin.quickZoomEnabled = !gesturesPlugin.quickZoomEnabled @@ -214,18 +226,21 @@ class GesturesActivity : AppCompatActivity() { } R.id.menu_gesture_pan_scroll_horizontal_vertical -> { binding.mapView.gestures.updateSettings { - panScrollMode = PanScrollMode.HORIZONTAL_AND_VERTICAL + scrollMode = ScrollMode.HORIZONTAL_AND_VERTICAL } + item.isChecked = true } R.id.menu_gesture_pan_scroll_horizontal -> { binding.mapView.gestures.updateSettings { - panScrollMode = PanScrollMode.HORIZONTAL + scrollMode = ScrollMode.HORIZONTAL } + item.isChecked = true } R.id.menu_gesture_pan_scroll_vertical -> { binding.mapView.gestures.updateSettings { - panScrollMode = PanScrollMode.VERTICAL + scrollMode = ScrollMode.VERTICAL } + item.isChecked = true } } return true @@ -234,17 +249,22 @@ class GesturesActivity : AppCompatActivity() { private fun fixedFocalPointEnabled(enabled: Boolean) { if (enabled) { - focalPointLatLng = Point.fromLngLat(-0.12968, 51.50325) - // TODO add marker - // marker = mapboxMap.addMarker(MarkerOptions().position(focalPointLatLng)) + focalPointLatLng = FOCAL_POINT + pointAnnotationManager = + binding.mapView.annotations.createPointAnnotationManager(binding.mapView).apply { + create( + PointAnnotationOptions() + .withPoint(FOCAL_POINT) + .withIconImage(MARKER_IMAGE_ID) + ) + } mapboxMap.setCamera(CameraOptions.Builder().center(focalPointLatLng).zoom(16.0).build()) recalculateFocalPoint() } else { - // TODO add marker - // if (marker != null) { - // mapboxMap.removeMarker(marker) - // marker = null - // } + pointAnnotationManager?.let { + binding.mapView.annotations.removeAnnotationManager(it) + } + pointAnnotationManager = null focalPointLatLng = null gesturesPlugin.focalPoint = null } @@ -376,6 +396,8 @@ class GesturesActivity : AppCompatActivity() { companion object { private const val MAX_NUMBER_OF_ALERTS = 30 + private const val MARKER_IMAGE_ID = "MARKER_IMAGE_ID" + private val FOCAL_POINT = Point.fromLngLat(-0.12968, 51.50325) } } diff --git a/app/src/main/java/com/mapbox/maps/testapp/examples/InsetMapActivity.kt b/app/src/main/java/com/mapbox/maps/testapp/examples/InsetMapActivity.kt index a32731609f..d14d07fe14 100644 --- a/app/src/main/java/com/mapbox/maps/testapp/examples/InsetMapActivity.kt +++ b/app/src/main/java/com/mapbox/maps/testapp/examples/InsetMapActivity.kt @@ -81,7 +81,7 @@ class InsetMapActivity : AppCompatActivity(), OnCameraChangeListener { gestures.updateSettings { scrollEnabled = false - zoomEnabled = false + pinchToZoomEnabled = false } } } diff --git a/app/src/main/java/com/mapbox/maps/testapp/examples/terrain3D/SantaCatalinaActivity.kt b/app/src/main/java/com/mapbox/maps/testapp/examples/terrain3D/SantaCatalinaActivity.kt index f1201aae75..e1a7e0d644 100644 --- a/app/src/main/java/com/mapbox/maps/testapp/examples/terrain3D/SantaCatalinaActivity.kt +++ b/app/src/main/java/com/mapbox/maps/testapp/examples/terrain3D/SantaCatalinaActivity.kt @@ -270,6 +270,8 @@ fun MapView.disablePlugins() { gestures.pitchEnabled = false gestures.rotateEnabled = false - gestures.zoomEnabled = false + gestures.pinchToZoomEnabled = false + gestures.doubleTouchToZoomOutEnabled = false + gestures.doubleTapToZoomInEnabled = false gestures.scrollEnabled = false } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_style_switch.xml b/app/src/main/res/layout/activity_style_switch.xml index e65907a843..558450f313 100644 --- a/app/src/main/res/layout/activity_style_switch.xml +++ b/app/src/main/res/layout/activity_style_switch.xml @@ -40,7 +40,7 @@ app:mapbox_compassMarginLeft="32dp" app:mapbox_compassMarginRight="32dp" app:mapbox_compassMarginTop="32dp" - app:mapbox_gesturesDoubleTapToZoomEnabled="false" + app:mapbox_gesturesDoubleTapToZoomInEnabled="false" app:mapbox_logoEnabled="true" app:mapbox_logoGravity="bottom|right" app:mapbox_logoMarginBottom="32dp" @@ -51,7 +51,7 @@ app:mapbox_gesturesRotateEnabled="true" app:mapbox_gesturesScrollEnabled="false" app:mapbox_gesturesPitchEnabled="false" - app:mapbox_gesturesZoomEnabled="false" /> + app:mapbox_gesturesPinchToZoomEnabled="false" />