From 0baf65c2ee4492abf8b3f537c60c64b9ce23cdd1 Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Fri, 24 Sep 2021 13:27:14 +0300 Subject: [PATCH 01/12] [gestures] Refactor gestures naming to be aligned better across platforms. --- ...GesturesAttributeParserDefaultValueTest.kt | 55 ++++----- .../generated/GesturesAttributeParserTest.kt | 55 ++++----- .../res/layout/generated_test_gestures.xml | 21 ++-- .../generated/GesturesAttributeParser.kt | 23 ++-- .../src/main/res-public/values/public.xml | 55 ++++----- plugin-gestures/src/main/res/values/attrs.xml | 58 +++++---- .../generated/GesturesAttributeParserTest.kt | 94 +++++++------- .../mapbox/maps/plugin/ConfigProperties.kt | 10 +- .../gestures/generated/GesturesSettings.kt | 61 +++++---- .../generated/GesturesSettingsBase.kt | 116 ++++++++---------- .../generated/GesturesSettingsInterface.kt | 61 +++++---- 11 files changed, 285 insertions(+), 324 deletions(-) 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..3b2bc343e5 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..", + "doubleTapToZoomAmount test failed..", 1f, - mapView.gestures.getSettings().zoomRate - ) - assertEquals( - "pixelRatio test failed..", - pixelRatio, - mapView.gestures.getSettings().pixelRatio + mapView.gestures.getSettings().doubleTapToZoomAmount ) } } 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..e2d3aaf5bf 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..", + "doubleTapToZoomAmount test failed..", 0.9f, - mapView.gestures.getSettings().pixelRatio + mapView.gestures.getSettings().doubleTapToZoomAmount ) } } diff --git a/app/src/main/res/layout/generated_test_gestures.xml b/app/src/main/res/layout/generated_test_gestures.xml index 508f9f16a7..15bf42182e 100644 --- a/app/src/main/res/layout/generated_test_gestures.xml +++ b/app/src/main/res/layout/generated_test_gestures.xml @@ -4,22 +4,21 @@ xmlns:mapbox="http://schemas.android.com/apk/res-auto" android:id="@+id/mapView" mapbox:mapbox_gesturesRotateEnabled = "false" - mapbox:mapbox_gesturesZoomEnabled = "false" + mapbox:mapbox_gesturesPinchToZoomEnabled = "false" mapbox:mapbox_gesturesScrollEnabled = "false" mapbox:mapbox_gesturesPitchEnabled = "false" - mapbox:mapbox_gesturesPanScrollMode = "horizontal_and_vertical" - mapbox:mapbox_gesturesDoubleTapToZoomEnabled = "false" + mapbox:mapbox_gesturesScrollMode = "horizontal_and_vertical" + mapbox:mapbox_gesturesDoubleTapToZoomInEnabled = "false" + mapbox:mapbox_gesturesDoubleTouchToZoomOutEnabled = "false" mapbox:mapbox_gesturesQuickZoomEnabled = "false" mapbox:mapbox_gesturesFocalPointX = "10.0" mapbox:mapbox_gesturesFocalPointY = "20.0" - mapbox:mapbox_gesturesScaleVelocityAnimationEnabled = "false" - mapbox:mapbox_gesturesRotateVelocityAnimationEnabled = "false" - mapbox:mapbox_gesturesFlingVelocityAnimationEnabled = "false" - mapbox:mapbox_gesturesIncreaseRotateThresholdWhenScaling = "false" - mapbox:mapbox_gesturesDisableRotateWhenScaling = "false" - mapbox:mapbox_gesturesIncreaseScaleThresholdWhenRotating = "false" - mapbox:mapbox_gesturesZoomRate = "0.9" - mapbox:mapbox_gesturesPixelRatio = "0.9" + mapbox:mapbox_gesturesPinchToZoomDecelerationEnabled = "false" + mapbox:mapbox_gesturesRotateDecelerationEnabled = "false" + mapbox:mapbox_gesturesScrollDecelerationEnabled = "false" + mapbox:mapbox_gesturesIncreaseRotateThresholdWhenPinchingToZoom = "false" + mapbox:mapbox_gesturesIncreasePinchToZoomThresholdWhenRotating = "false" + mapbox:mapbox_gesturesDoubleTapToZoomAmount = "0.9" android:layout_width="match_parent" android:layout_height="match_parent" /> \ No newline at end of file diff --git a/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt b/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt index 496d03381f..e38ee7a90e 100644 --- a/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt +++ b/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt @@ -5,7 +5,7 @@ package com.mapbox.maps.plugin.gestures.generated import android.content.Context import android.util.AttributeSet import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode import com.mapbox.maps.plugin.gestures.R /** @@ -23,11 +23,12 @@ internal object GesturesAttributeParser { try { return GesturesSettings( rotateEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesRotateEnabled, true), - zoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesZoomEnabled, true), + pinchToZoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesPinchToZoomEnabled, true), scrollEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesScrollEnabled, true), pitchEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesPitchEnabled, true), - panScrollMode = PanScrollMode.values()[typedArray.getInt(R.styleable.mapbox_MapView_mapbox_gesturesPanScrollMode, PanScrollMode.HORIZONTAL_AND_VERTICAL.ordinal)], - doubleTapToZoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTapToZoomEnabled, true), + scrollMode = ScrollMode.values()[typedArray.getInt(R.styleable.mapbox_MapView_mapbox_gesturesScrollMode, 0)], + doubleTapToZoomInEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTapToZoomInEnabled, true), + doubleTouchToZoomOutEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTouchToZoomOutEnabled, true), quickZoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesQuickZoomEnabled, true), focalPoint = if (typedArray.hasValue(R.styleable.mapbox_MapView_mapbox_gesturesFocalPointX) && typedArray.hasValue(R.styleable.mapbox_MapView_mapbox_gesturesFocalPointY)) { ScreenCoordinate( @@ -37,14 +38,12 @@ internal object GesturesAttributeParser { } else { null }, - scaleVelocityAnimationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesScaleVelocityAnimationEnabled, true), - rotateVelocityAnimationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesRotateVelocityAnimationEnabled, true), - flingVelocityAnimationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesFlingVelocityAnimationEnabled, true), - increaseRotateThresholdWhenScaling = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesIncreaseRotateThresholdWhenScaling, true), - disableRotateWhenScaling = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDisableRotateWhenScaling, true), - increaseScaleThresholdWhenRotating = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesIncreaseScaleThresholdWhenRotating, true), - zoomRate = typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_gesturesZoomRate, 1f), - pixelRatio = typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_gesturesPixelRatio, pixelRatio), + pinchToZoomDecelerationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesPinchToZoomDecelerationEnabled, true), + rotateDecelerationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesRotateDecelerationEnabled, true), + scrollDecelerationEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesScrollDecelerationEnabled, true), + increaseRotateThresholdWhenPinchingToZoom = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesIncreaseRotateThresholdWhenPinchingToZoom, true), + increasePinchToZoomThresholdWhenRotating = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesIncreasePinchToZoomThresholdWhenRotating, true), + doubleTapToZoomAmount = typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTapToZoomAmount, 1f), ) } finally { typedArray.recycle() diff --git a/plugin-gestures/src/main/res-public/values/public.xml b/plugin-gestures/src/main/res-public/values/public.xml index e65e93e875..c2946d76f2 100644 --- a/plugin-gestures/src/main/res-public/values/public.xml +++ b/plugin-gestures/src/main/res-public/values/public.xml @@ -2,54 +2,51 @@ - + - - + + - + - + - - + + - - + + - + + + + - + - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + \ No newline at end of file diff --git a/plugin-gestures/src/main/res/values/attrs.xml b/plugin-gestures/src/main/res/values/attrs.xml index 6a2ee192c9..99f6abf1ad 100644 --- a/plugin-gestures/src/main/res/values/attrs.xml +++ b/plugin-gestures/src/main/res/values/attrs.xml @@ -2,46 +2,44 @@ - + - - - + + + - + - - - + + + - + - + - - - + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin-gestures/src/test/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParserTest.kt b/plugin-gestures/src/test/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParserTest.kt index 0c6a0653a2..7c689aadd1 100644 --- a/plugin-gestures/src/test/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParserTest.kt +++ b/plugin-gestures/src/test/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParserTest.kt @@ -8,7 +8,7 @@ import android.graphics.Color import android.graphics.drawable.Drawable import android.util.AttributeSet import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode import io.mockk.every import io.mockk.mockk import io.mockk.mockkObject @@ -64,17 +64,17 @@ class GesturesAttributeParserTest { } @Test - fun zoomEnabledTestTrue() { + fun pinchToZoomEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.zoomEnabled) + assertEquals(true, settings.pinchToZoomEnabled) } @Test - fun zoomEnabledTestFalse() { + fun pinchToZoomEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.zoomEnabled) + assertEquals(false, settings.pinchToZoomEnabled) } @Test @@ -105,136 +105,136 @@ class GesturesAttributeParserTest { assertEquals(false, settings.pitchEnabled) } @Test - fun panScrollModeTest() { - every { typedArray.getInt(any(), any()) } returns PanScrollMode.HORIZONTAL_AND_VERTICAL.ordinal + fun scrollModeTest() { + every { typedArray.getInt(any(), any()) } returns ScrollMode.HORIZONTAL_AND_VERTICAL.ordinal val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(PanScrollMode.HORIZONTAL_AND_VERTICAL, settings.panScrollMode) + assertEquals(ScrollMode.HORIZONTAL_AND_VERTICAL, settings.scrollMode) } @Test - fun doubleTapToZoomEnabledTestTrue() { + fun doubleTapToZoomInEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.doubleTapToZoomEnabled) + assertEquals(true, settings.doubleTapToZoomInEnabled) } @Test - fun doubleTapToZoomEnabledTestFalse() { + fun doubleTapToZoomInEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.doubleTapToZoomEnabled) + assertEquals(false, settings.doubleTapToZoomInEnabled) } @Test - fun quickZoomEnabledTestTrue() { + fun doubleTouchToZoomOutEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.quickZoomEnabled) + assertEquals(true, settings.doubleTouchToZoomOutEnabled) } @Test - fun quickZoomEnabledTestFalse() { + fun doubleTouchToZoomOutEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.quickZoomEnabled) + assertEquals(false, settings.doubleTouchToZoomOutEnabled) } @Test - fun focalPointTest() { - every { typedArray.getDimension(any(), any()) } returns 10.0f + fun quickZoomEnabledTestTrue() { + every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(ScreenCoordinate(10.0, 10.0), settings.focalPoint) + assertEquals(true, settings.quickZoomEnabled) } @Test - fun scaleVelocityAnimationEnabledTestTrue() { - every { typedArray.getBoolean(any(), any()) } returns true + fun quickZoomEnabledTestFalse() { + every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.scaleVelocityAnimationEnabled) + assertEquals(false, settings.quickZoomEnabled) } @Test - fun scaleVelocityAnimationEnabledTestFalse() { - every { typedArray.getBoolean(any(), any()) } returns false + fun focalPointTest() { + every { typedArray.getDimension(any(), any()) } returns 10.0f val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.scaleVelocityAnimationEnabled) + assertEquals(ScreenCoordinate(10.0, 10.0), settings.focalPoint) } @Test - fun rotateVelocityAnimationEnabledTestTrue() { + fun pinchToZoomDecelerationEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.rotateVelocityAnimationEnabled) + assertEquals(true, settings.pinchToZoomDecelerationEnabled) } @Test - fun rotateVelocityAnimationEnabledTestFalse() { + fun pinchToZoomDecelerationEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.rotateVelocityAnimationEnabled) + assertEquals(false, settings.pinchToZoomDecelerationEnabled) } @Test - fun flingVelocityAnimationEnabledTestTrue() { + fun rotateDecelerationEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.flingVelocityAnimationEnabled) + assertEquals(true, settings.rotateDecelerationEnabled) } @Test - fun flingVelocityAnimationEnabledTestFalse() { + fun rotateDecelerationEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.flingVelocityAnimationEnabled) + assertEquals(false, settings.rotateDecelerationEnabled) } @Test - fun increaseRotateThresholdWhenScalingTestTrue() { + fun scrollDecelerationEnabledTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.increaseRotateThresholdWhenScaling) + assertEquals(true, settings.scrollDecelerationEnabled) } @Test - fun increaseRotateThresholdWhenScalingTestFalse() { + fun scrollDecelerationEnabledTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.increaseRotateThresholdWhenScaling) + assertEquals(false, settings.scrollDecelerationEnabled) } @Test - fun disableRotateWhenScalingTestTrue() { + fun increaseRotateThresholdWhenPinchingToZoomTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.disableRotateWhenScaling) + assertEquals(true, settings.increaseRotateThresholdWhenPinchingToZoom) } @Test - fun disableRotateWhenScalingTestFalse() { + fun increaseRotateThresholdWhenPinchingToZoomTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.disableRotateWhenScaling) + assertEquals(false, settings.increaseRotateThresholdWhenPinchingToZoom) } @Test - fun increaseScaleThresholdWhenRotatingTestTrue() { + fun increasePinchToZoomThresholdWhenRotatingTestTrue() { every { typedArray.getBoolean(any(), any()) } returns true val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(true, settings.increaseScaleThresholdWhenRotating) + assertEquals(true, settings.increasePinchToZoomThresholdWhenRotating) } @Test - fun increaseScaleThresholdWhenRotatingTestFalse() { + fun increasePinchToZoomThresholdWhenRotatingTestFalse() { every { typedArray.getBoolean(any(), any()) } returns false val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(false, settings.increaseScaleThresholdWhenRotating) + assertEquals(false, settings.increasePinchToZoomThresholdWhenRotating) } @Test - fun zoomRateTest() { + fun doubleTapToZoomAmountTest() { every { typedArray.getFloat(any(), any()) } returns 1f val settings = GesturesAttributeParser.parseGesturesSettings(context, attrs, 1.2f) - assertEquals(1f, settings.zoomRate) + assertEquals(1f, settings.doubleTapToZoomAmount) } } diff --git a/sdk-base/src/main/java/com/mapbox/maps/plugin/ConfigProperties.kt b/sdk-base/src/main/java/com/mapbox/maps/plugin/ConfigProperties.kt index d9c9e78b06..3f46f19578 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/plugin/ConfigProperties.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/plugin/ConfigProperties.kt @@ -5,21 +5,21 @@ package com.mapbox.maps.plugin import android.graphics.drawable.Drawable /** - * Whether the user is restricted in which direction the map is scrolled. + * Configures the directions in which the map is allowed to move during a scroll gesture. * * @param value String value of this property */ -enum class PanScrollMode(val value: String) { +enum class ScrollMode(val value: String) { /** - * The map allows the user to only scroll horizontally. + * The map may only move horizontally. */ HORIZONTAL("horizontal"), /** - * The map allows the user to only scroll vertically. + * The map may only move vertically. */ VERTICAL("vertical"), /** - * The map allows the user to scroll both horizontally and vertically. + * The map may move both horizontally and vertically. */ HORIZONTAL_AND_VERTICAL("horizontal-and-vertical"), } diff --git a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettings.kt b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettings.kt index b1d762169a..c7adbbb56a 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettings.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettings.kt @@ -3,91 +3,86 @@ package com.mapbox.maps.plugin.gestures.generated import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode /** * Gesture configuration allows to control the user touch interaction. */ data class GesturesSettings( /** - * Whether rotation gestures are enabled. + * Whether the rotate gesture is enabled. */ var rotateEnabled: Boolean = true, /** - * Whether zoom gestures are enabled. + * Whether the pinch to zoom gesture is enabled. */ - var zoomEnabled: Boolean = true, + var pinchToZoomEnabled: Boolean = true, /** - * Whether scroll gestures are enabled. + * Whether the single-touch scroll gesture is enabled. */ var scrollEnabled: Boolean = true, /** - * Whether pitch gestures are enabled. + * Whether the pitch gesture is enabled. */ var pitchEnabled: Boolean = true, /** - * Whether the user is restricted in which direction the map is scrolled. + * Configures the directions in which the map is allowed to move during a scroll gesture. */ - var panScrollMode: PanScrollMode = PanScrollMode.HORIZONTAL_AND_VERTICAL, + var scrollMode: ScrollMode = ScrollMode.HORIZONTAL_AND_VERTICAL, /** - * Whether double tapping the map results in a zoom gesture. + * Whether double tapping the map with one touch results in a zoom-in animation. */ - var doubleTapToZoomEnabled: Boolean = true, + var doubleTapToZoomInEnabled: Boolean = true, /** - * Whether quick zoom gesture is enabled. + * Whether single tapping the map with two touches results in a zoom-out animation. */ - var quickZoomEnabled: Boolean = true, + var doubleTouchToZoomOutEnabled: Boolean = true, /** - * Whether a gesture executes around a fixed focal point or the center of the gesture. + * Whether the quick zoom gesture is enabled. */ - var focalPoint: ScreenCoordinate? = null, - - /** - * Whether scale velocity animations are enabled, true by default. - */ - var scaleVelocityAnimationEnabled: Boolean = true, + var quickZoomEnabled: Boolean = true, /** - * Whether rotate velocity animations are enabled, true by default. + * By default, gestures rotate and zoom around the center of the gesture. Set this property to rotate and zoom around a fixed point instead. */ - var rotateVelocityAnimationEnabled: Boolean = true, + var focalPoint: ScreenCoordinate? = null, /** - * Whether fling velocity animations are enabled, true by default. + * Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default. */ - var flingVelocityAnimationEnabled: Boolean = true, + var pinchToZoomDecelerationEnabled: Boolean = true, /** - * Whether rotate threshold increases when scaling. true by default. + * Whether a deceleration animation following a rotate gesture is enabled. True by default. */ - var increaseRotateThresholdWhenScaling: Boolean = true, + var rotateDecelerationEnabled: Boolean = true, /** - * Whether rotate is disabled when scaling. true by default. + * Whether a deceleration animation following a scroll gesture is enabled. True by default. */ - var disableRotateWhenScaling: Boolean = true, + var scrollDecelerationEnabled: Boolean = true, /** - * Whether scale threshold increases when rotating. true by default. + * Whether rotate threshold increases when pinching to zoom. true by default. */ - var increaseScaleThresholdWhenRotating: Boolean = true, + var increaseRotateThresholdWhenPinchingToZoom: Boolean = true, /** - * The rate at which the zoom level increases. 1.0 by default + * Whether pinch to zoom threshold increases when rotating. true by default. */ - var zoomRate: Float = 1f, + var increasePinchToZoomThresholdWhenRotating: Boolean = true, /** - * The pixel ratio of the device that the gestures will take in account. + * The amount by which the zoom level increases or decreases. 1.0 by default. Must be positive. */ - var pixelRatio: Float = 1f, + var doubleTapToZoomAmount: Float = 1f, ) // End of generated file. \ No newline at end of file diff --git a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsBase.kt b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsBase.kt index f6f5c59948..e70fce9352 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsBase.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsBase.kt @@ -3,7 +3,7 @@ package com.mapbox.maps.plugin.gestures.generated import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode /** * Abstract settings class for GesturesPlugin. @@ -41,7 +41,7 @@ abstract class GesturesSettingsBase : GesturesSettingsInterface { } /** - * Whether rotation gestures are enabled. + * Whether the rotate gesture is enabled. */ override var rotateEnabled: Boolean get() { @@ -53,19 +53,19 @@ abstract class GesturesSettingsBase : GesturesSettingsInterface { } /** - * Whether zoom gestures are enabled. + * Whether the pinch to zoom gesture is enabled. */ - override var zoomEnabled: Boolean + override var pinchToZoomEnabled: Boolean get() { - return this.internalSettings.zoomEnabled + return this.internalSettings.pinchToZoomEnabled } set(value) { - this.internalSettings.zoomEnabled = value + this.internalSettings.pinchToZoomEnabled = value applySettings() } /** - * Whether scroll gestures are enabled. + * Whether the single-touch scroll gesture is enabled. */ override var scrollEnabled: Boolean get() { @@ -77,7 +77,7 @@ abstract class GesturesSettingsBase : GesturesSettingsInterface { } /** - * Whether pitch gestures are enabled. + * Whether the pitch gesture is enabled. */ override var pitchEnabled: Boolean get() { @@ -89,146 +89,134 @@ abstract class GesturesSettingsBase : GesturesSettingsInterface { } /** - * Whether the user is restricted in which direction the map is scrolled. + * Configures the directions in which the map is allowed to move during a scroll gesture. */ - override var panScrollMode: PanScrollMode + override var scrollMode: ScrollMode get() { - return this.internalSettings.panScrollMode + return this.internalSettings.scrollMode } set(value) { - this.internalSettings.panScrollMode = value + this.internalSettings.scrollMode = value applySettings() } /** - * Whether double tapping the map results in a zoom gesture. + * Whether double tapping the map with one touch results in a zoom-in animation. */ - override var doubleTapToZoomEnabled: Boolean + override var doubleTapToZoomInEnabled: Boolean get() { - return this.internalSettings.doubleTapToZoomEnabled + return this.internalSettings.doubleTapToZoomInEnabled } set(value) { - this.internalSettings.doubleTapToZoomEnabled = value + this.internalSettings.doubleTapToZoomInEnabled = value applySettings() } /** - * Whether quick zoom gesture is enabled. + * Whether single tapping the map with two touches results in a zoom-out animation. */ - override var quickZoomEnabled: Boolean - get() { - return this.internalSettings.quickZoomEnabled - } - set(value) { - this.internalSettings.quickZoomEnabled = value - applySettings() - } - - /** - * Whether a gesture executes around a fixed focal point or the center of the gesture. - */ - override var focalPoint: ScreenCoordinate? + override var doubleTouchToZoomOutEnabled: Boolean get() { - return this.internalSettings.focalPoint + return this.internalSettings.doubleTouchToZoomOutEnabled } set(value) { - this.internalSettings.focalPoint = value + this.internalSettings.doubleTouchToZoomOutEnabled = value applySettings() } /** - * Whether scale velocity animations are enabled, true by default. + * Whether the quick zoom gesture is enabled. */ - override var scaleVelocityAnimationEnabled: Boolean + override var quickZoomEnabled: Boolean get() { - return this.internalSettings.scaleVelocityAnimationEnabled + return this.internalSettings.quickZoomEnabled } set(value) { - this.internalSettings.scaleVelocityAnimationEnabled = value + this.internalSettings.quickZoomEnabled = value applySettings() } /** - * Whether rotate velocity animations are enabled, true by default. + * By default, gestures rotate and zoom around the center of the gesture. Set this property to rotate and zoom around a fixed point instead. */ - override var rotateVelocityAnimationEnabled: Boolean + override var focalPoint: ScreenCoordinate? get() { - return this.internalSettings.rotateVelocityAnimationEnabled + return this.internalSettings.focalPoint } set(value) { - this.internalSettings.rotateVelocityAnimationEnabled = value + this.internalSettings.focalPoint = value applySettings() } /** - * Whether fling velocity animations are enabled, true by default. + * Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default. */ - override var flingVelocityAnimationEnabled: Boolean + override var pinchToZoomDecelerationEnabled: Boolean get() { - return this.internalSettings.flingVelocityAnimationEnabled + return this.internalSettings.pinchToZoomDecelerationEnabled } set(value) { - this.internalSettings.flingVelocityAnimationEnabled = value + this.internalSettings.pinchToZoomDecelerationEnabled = value applySettings() } /** - * Whether rotate threshold increases when scaling. true by default. + * Whether a deceleration animation following a rotate gesture is enabled. True by default. */ - override var increaseRotateThresholdWhenScaling: Boolean + override var rotateDecelerationEnabled: Boolean get() { - return this.internalSettings.increaseRotateThresholdWhenScaling + return this.internalSettings.rotateDecelerationEnabled } set(value) { - this.internalSettings.increaseRotateThresholdWhenScaling = value + this.internalSettings.rotateDecelerationEnabled = value applySettings() } /** - * Whether rotate is disabled when scaling. true by default. + * Whether a deceleration animation following a scroll gesture is enabled. True by default. */ - override var disableRotateWhenScaling: Boolean + override var scrollDecelerationEnabled: Boolean get() { - return this.internalSettings.disableRotateWhenScaling + return this.internalSettings.scrollDecelerationEnabled } set(value) { - this.internalSettings.disableRotateWhenScaling = value + this.internalSettings.scrollDecelerationEnabled = value applySettings() } /** - * Whether scale threshold increases when rotating. true by default. + * Whether rotate threshold increases when pinching to zoom. true by default. */ - override var increaseScaleThresholdWhenRotating: Boolean + override var increaseRotateThresholdWhenPinchingToZoom: Boolean get() { - return this.internalSettings.increaseScaleThresholdWhenRotating + return this.internalSettings.increaseRotateThresholdWhenPinchingToZoom } set(value) { - this.internalSettings.increaseScaleThresholdWhenRotating = value + this.internalSettings.increaseRotateThresholdWhenPinchingToZoom = value applySettings() } /** - * The rate at which the zoom level increases. 1.0 by default + * Whether pinch to zoom threshold increases when rotating. true by default. */ - override var zoomRate: Float + override var increasePinchToZoomThresholdWhenRotating: Boolean get() { - return this.internalSettings.zoomRate + return this.internalSettings.increasePinchToZoomThresholdWhenRotating } set(value) { - this.internalSettings.zoomRate = value + this.internalSettings.increasePinchToZoomThresholdWhenRotating = value applySettings() } /** - * The pixel ratio of the device that the gestures will take in account. + * The amount by which the zoom level increases or decreases. 1.0 by default. Must be positive. */ - override var pixelRatio: Float + override var doubleTapToZoomAmount: Float get() { - return this.internalSettings.pixelRatio + return this.internalSettings.doubleTapToZoomAmount } set(value) { - this.internalSettings.pixelRatio = value + this.internalSettings.doubleTapToZoomAmount = value applySettings() } } diff --git a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsInterface.kt b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsInterface.kt index a591a44aa6..c3b83922ec 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsInterface.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesSettingsInterface.kt @@ -3,7 +3,7 @@ package com.mapbox.maps.plugin.gestures.generated import com.mapbox.maps.ScreenCoordinate -import com.mapbox.maps.plugin.PanScrollMode +import com.mapbox.maps.plugin.ScrollMode /** * Interface that defines the public settings interface for GesturesPlugin. @@ -24,84 +24,79 @@ interface GesturesSettingsInterface { fun updateSettings(block: GesturesSettings.() -> Unit) /** - * Whether rotation gestures are enabled. + * Whether the rotate gesture is enabled. */ var rotateEnabled: Boolean /** - * Whether zoom gestures are enabled. + * Whether the pinch to zoom gesture is enabled. */ - var zoomEnabled: Boolean + var pinchToZoomEnabled: Boolean /** - * Whether scroll gestures are enabled. + * Whether the single-touch scroll gesture is enabled. */ var scrollEnabled: Boolean /** - * Whether pitch gestures are enabled. + * Whether the pitch gesture is enabled. */ var pitchEnabled: Boolean /** - * Whether the user is restricted in which direction the map is scrolled. + * Configures the directions in which the map is allowed to move during a scroll gesture. */ - var panScrollMode: PanScrollMode + var scrollMode: ScrollMode /** - * Whether double tapping the map results in a zoom gesture. + * Whether double tapping the map with one touch results in a zoom-in animation. */ - var doubleTapToZoomEnabled: Boolean + var doubleTapToZoomInEnabled: Boolean /** - * Whether quick zoom gesture is enabled. + * Whether single tapping the map with two touches results in a zoom-out animation. */ - var quickZoomEnabled: Boolean + var doubleTouchToZoomOutEnabled: Boolean /** - * Whether a gesture executes around a fixed focal point or the center of the gesture. + * Whether the quick zoom gesture is enabled. */ - var focalPoint: ScreenCoordinate? - - /** - * Whether scale velocity animations are enabled, true by default. - */ - var scaleVelocityAnimationEnabled: Boolean + var quickZoomEnabled: Boolean /** - * Whether rotate velocity animations are enabled, true by default. + * By default, gestures rotate and zoom around the center of the gesture. Set this property to rotate and zoom around a fixed point instead. */ - var rotateVelocityAnimationEnabled: Boolean + var focalPoint: ScreenCoordinate? /** - * Whether fling velocity animations are enabled, true by default. + * Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default. */ - var flingVelocityAnimationEnabled: Boolean + var pinchToZoomDecelerationEnabled: Boolean /** - * Whether rotate threshold increases when scaling. true by default. + * Whether a deceleration animation following a rotate gesture is enabled. True by default. */ - var increaseRotateThresholdWhenScaling: Boolean + var rotateDecelerationEnabled: Boolean /** - * Whether rotate is disabled when scaling. true by default. + * Whether a deceleration animation following a scroll gesture is enabled. True by default. */ - var disableRotateWhenScaling: Boolean + var scrollDecelerationEnabled: Boolean /** - * Whether scale threshold increases when rotating. true by default. + * Whether rotate threshold increases when pinching to zoom. true by default. */ - var increaseScaleThresholdWhenRotating: Boolean + var increaseRotateThresholdWhenPinchingToZoom: Boolean /** - * The rate at which the zoom level increases. 1.0 by default + * Whether pinch to zoom threshold increases when rotating. true by default. */ - var zoomRate: Float + var increasePinchToZoomThresholdWhenRotating: Boolean /** - * The pixel ratio of the device that the gestures will take in account. + * The amount by which the zoom level increases or decreases. 1.0 by default. Must be positive. */ - var pixelRatio: Float + var doubleTapToZoomAmount: Float } // End of generated file. \ No newline at end of file From 95a5b13f4a9de9086e1731acee333b46044b3c6e Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Fri, 24 Sep 2021 17:13:31 +0300 Subject: [PATCH 02/12] Fix scroll mode default value. --- .../maps/plugin/gestures/generated/GesturesAttributeParser.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt b/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt index e38ee7a90e..cb2c2f1eec 100644 --- a/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt +++ b/plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/generated/GesturesAttributeParser.kt @@ -26,7 +26,7 @@ internal object GesturesAttributeParser { pinchToZoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesPinchToZoomEnabled, true), scrollEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesScrollEnabled, true), pitchEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesPitchEnabled, true), - scrollMode = ScrollMode.values()[typedArray.getInt(R.styleable.mapbox_MapView_mapbox_gesturesScrollMode, 0)], + scrollMode = ScrollMode.values()[typedArray.getInt(R.styleable.mapbox_MapView_mapbox_gesturesScrollMode, ScrollMode.HORIZONTAL_AND_VERTICAL.ordinal)], doubleTapToZoomInEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTapToZoomInEnabled, true), doubleTouchToZoomOutEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesDoubleTouchToZoomOutEnabled, true), quickZoomEnabled = typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_gesturesQuickZoomEnabled, true), From f5e9d124631b02d3d0a27e5e02504d549417b4f7 Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Fri, 24 Sep 2021 17:15:12 +0300 Subject: [PATCH 03/12] Adapt the updated gestures settings. --- .../maps/testapp/examples/GesturesActivity.kt | 41 +++++++++++-------- .../maps/testapp/examples/InsetMapActivity.kt | 2 +- .../terrain3D/SantaCatalinaActivity.kt | 4 +- .../main/res/layout/activity_style_switch.xml | 4 +- app/src/main/res/menu/menu_gestures.xml | 27 ++++++++---- app/src/main/res/values/strings.xml | 13 +++--- .../maps/plugin/gestures/GesturesExt.kt | 18 ++++---- .../plugin/gestures/GesturesPluginImpl.kt | 41 +++++++++---------- 8 files changed, 83 insertions(+), 67 deletions(-) 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..18ba7314d2 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 @@ -18,7 +18,7 @@ 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.gestures.* import com.mapbox.maps.testapp.R import com.mapbox.maps.testapp.databinding.ActivityGesturesBinding @@ -178,15 +178,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 +197,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 +218,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 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" />