diff options
author | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-03-20 13:03:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 13:03:06 +0100 |
commit | a2250098f5dc39a4486555e35823d634a8d0b786 (patch) | |
tree | 34776b9a3645f5e34260fb0932654ef5978f5bb3 | |
parent | ef1dcc0d5b5ae23b303ca736168f1452ea36ae77 (diff) | |
download | qtlocation-mapboxgl-a2250098f5dc39a4486555e35823d634a8d0b786.tar.gz |
[android] bumped gestures library version to 0.1.0 (#11483)
5 files changed, 44 insertions, 51 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 849719a1a2..36f6d512f6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -12,6 +12,7 @@ import android.view.MotionEvent; import android.view.animation.DecelerateInterpolator; import com.mapbox.android.gestures.AndroidGesturesManager; +import com.mapbox.android.gestures.Constants; import com.mapbox.android.gestures.MoveGestureDetector; import com.mapbox.android.gestures.MultiFingerTapGestureDetector; import com.mapbox.android.gestures.RotateGestureDetector; @@ -77,13 +78,6 @@ final class MapGestureDetector { private final CopyOnWriteArrayList<MapboxMap.OnShoveListener> onShoveListenerList = new CopyOnWriteArrayList<>(); - private StandardGestureListener standardGestureListener; - private MoveGestureListener moveGestureListener; - private ScaleGestureListener scaleGestureListener; - private RotateGestureListener rotateGestureListener; - private ShoveGestureListener shoveGestureListener; - private TapGestureListener tapGestureListener; - /** * User-set focal point. */ @@ -112,29 +106,39 @@ final class MapGestureDetector { // Checking for context != null for testing purposes if (context != null) { - // Initialize gesture listeners - initializeGestureListeners(context); - // Initialize gestures manager AndroidGesturesManager androidGesturesManager = new AndroidGesturesManager(context); - initializeGesturesManager(androidGesturesManager, true, true); + initializeGesturesManager(androidGesturesManager, true); + + // Initialize gesture listeners + initializeGestureListeners(context, true); } } - private void initializeGestureListeners(Context context) { - standardGestureListener = new StandardGestureListener(); - moveGestureListener = new MoveGestureListener(); - scaleGestureListener = new ScaleGestureListener( - context.getResources().getDimension(R.dimen.mapbox_minimum_scale_velocity)); - rotateGestureListener = new RotateGestureListener( - context.getResources().getDimension(R.dimen.mapbox_minimum_scale_span_when_rotating), - context.getResources().getDimension(R.dimen.mapbox_minimum_angular_velocity)); - shoveGestureListener = new ShoveGestureListener(); - tapGestureListener = new TapGestureListener(); + private void initializeGestureListeners(Context context, boolean attachDefaultListeners) { + if (attachDefaultListeners) { + StandardGestureListener standardGestureListener = new StandardGestureListener(); + MoveGestureListener moveGestureListener = new MoveGestureListener(); + ScaleGestureListener scaleGestureListener = new ScaleGestureListener( + context.getResources().getDimension(R.dimen.mapbox_minimum_scale_velocity)); + RotateGestureListener rotateGestureListener = new RotateGestureListener( + context.getResources().getDimension(R.dimen.mapbox_minimum_scale_span_when_rotating), + context.getResources().getDimension(R.dimen.mapbox_minimum_angular_velocity), + context.getResources().getDimension(R.dimen.mapbox_defaultScaleSpanSinceStartThreshold)); + ShoveGestureListener shoveGestureListener = new ShoveGestureListener(); + TapGestureListener tapGestureListener = new TapGestureListener(); + + gesturesManager.setStandardGestureListener(standardGestureListener); + gesturesManager.setMoveGestureListener(moveGestureListener); + gesturesManager.setStandardScaleGestureListener(scaleGestureListener); + gesturesManager.setRotateGestureListener(rotateGestureListener); + gesturesManager.setShoveGestureListener(shoveGestureListener); + gesturesManager.setMultiFingerTapGestureListener(tapGestureListener); + } } private void initializeGesturesManager(AndroidGesturesManager androidGesturesManager, - boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives) { + boolean setDefaultMutuallyExclusives) { if (setDefaultMutuallyExclusives) { Set<Integer> shoveScaleSet = new HashSet<>(); shoveScaleSet.add(AndroidGesturesManager.GESTURE_TYPE_SHOVE); @@ -151,15 +155,6 @@ final class MapGestureDetector { androidGesturesManager.setMutuallyExclusiveGestures(shoveScaleSet, shoveRotateSet, ScaleLongPressSet); } - if (attachDefaultListeners) { - androidGesturesManager.setStandardGestureListener(standardGestureListener); - androidGesturesManager.setMoveGestureListener(moveGestureListener); - androidGesturesManager.setStandardScaleGestureListener(scaleGestureListener); - androidGesturesManager.setRotateGestureListener(rotateGestureListener); - androidGesturesManager.setShoveGestureListener(shoveGestureListener); - androidGesturesManager.setMultiFingerTapGestureListener(tapGestureListener); - } - gesturesManager = androidGesturesManager; } @@ -501,7 +496,7 @@ final class MapGestureDetector { if (uiSettings.isIncreaseRotateThresholdWhenScaling()) { // increase rotate angle threshold when scale is detected first gesturesManager.getRotateGestureDetector().setAngleThreshold( - gesturesManager.getRotateGestureDetector().getDefaultAngleThreshold() + Constants.DEFAULT_ROTATE_ANGLE_THRESHOLD + MapboxConstants.ROTATION_THRESHOLD_INCREASE_WHEN_SCALING ); } @@ -544,7 +539,7 @@ final class MapGestureDetector { if (uiSettings.isIncreaseRotateThresholdWhenScaling()) { // resetting default angle threshold gesturesManager.getRotateGestureDetector().setAngleThreshold( - gesturesManager.getRotateGestureDetector().getDefaultAngleThreshold() + Constants.DEFAULT_ROTATE_ANGLE_THRESHOLD ); } @@ -603,10 +598,13 @@ final class MapGestureDetector { private PointF rotateFocalPoint; private final float minimumScaleSpanWhenRotating; private final float minimumAngularVelocity; + private final float defaultSpanSinceStartThreshold; - RotateGestureListener(float minimumScaleSpanWhenRotating, float minimumAngularVelocity) { + public RotateGestureListener(float minimumScaleSpanWhenRotating, float minimumAngularVelocity, + float defaultSpanSinceStartThreshold) { this.minimumScaleSpanWhenRotating = minimumScaleSpanWhenRotating; this.minimumAngularVelocity = minimumAngularVelocity; + this.defaultSpanSinceStartThreshold = defaultSpanSinceStartThreshold; } @Override @@ -660,8 +658,7 @@ final class MapGestureDetector { if (uiSettings.isIncreaseScaleThresholdWhenRotating()) { // resetting default scale threshold values - gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold( - gesturesManager.getStandardScaleGestureDetector().getDefaultSpanSinceStartThreshold()); + gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(defaultSpanSinceStartThreshold); } notifyOnRotateEndListeners(detector); @@ -1109,8 +1106,9 @@ final class MapGestureDetector { return gesturesManager; } - void setGesturesManager(AndroidGesturesManager gesturesManager, boolean attachDefaultListeners, + void setGesturesManager(Context context, AndroidGesturesManager gesturesManager, boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives) { - initializeGesturesManager(gesturesManager, attachDefaultListeners, setDefaultMutuallyExclusives); + initializeGesturesManager(gesturesManager, setDefaultMutuallyExclusives); + initializeGestureListeners(context, attachDefaultListeners); } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 9c8ed7de2b..6bef8e06b3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -1026,7 +1026,8 @@ public class MapView extends FrameLayout { @Override public void setGesturesManager(AndroidGesturesManager gesturesManager, boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives) { - mapGestureDetector.setGesturesManager(gesturesManager, attachDefaultListeners, setDefaultMutuallyExclusives); + mapGestureDetector.setGesturesManager( + getContext(), gesturesManager, attachDefaultListeners, setDefaultMutuallyExclusives); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/GestureDetectorActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/GestureDetectorActivity.java index 2b79e2691d..c1698e20ab 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/GestureDetectorActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/GestureDetectorActivity.java @@ -58,7 +58,6 @@ public class GestureDetectorActivity extends AppCompatActivity { private Marker marker; @Nullable private LatLng focalPointLatLng; - private boolean animationsEnabled = true; @Override protected void onCreate(Bundle savedInstanceState) { @@ -198,9 +197,7 @@ public class GestureDetectorActivity extends AppCompatActivity { if (focalPointLatLng != null) { gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_OTHER, "REVERTING MOVE THRESHOLD")); - gesturesManager.getMoveGestureDetector().setMoveThreshold( - gesturesManager.getMoveGestureDetector().getDefaultMoveThreshold() - ); + gesturesManager.getMoveGestureDetector().setMoveThreshold(0f); } } }); @@ -242,8 +239,7 @@ public class GestureDetectorActivity extends AppCompatActivity { mapboxMap.getUiSettings().setFocalPoint(mapboxMap.getProjection().toScreenLocation(focalPointLatLng)); return true; case R.id.menu_gesture_animation: - animationsEnabled = !animationsEnabled; - mapboxMap.getUiSettings().setAllVelocityAnimationsEnabled(animationsEnabled); + mapboxMap.getUiSettings().setAllVelocityAnimationsEnabled(false); } return super.onOptionsItemSelected(item); } @@ -251,10 +247,8 @@ public class GestureDetectorActivity extends AppCompatActivity { private void resetModes() { focalPointLatLng = null; mapboxMap.getUiSettings().setFocalPoint(null); - - gesturesManager.getMoveGestureDetector().setMoveThreshold( - gesturesManager.getMoveGestureDetector().getDefaultMoveThreshold() - ); + gesturesManager.getMoveGestureDetector().setMoveThreshold(0f); + mapboxMap.getUiSettings().setAllVelocityAnimationsEnabled(true); if (marker != null) { mapboxMap.removeMarker(marker); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_gestures.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_gestures.xml index 3f96188da4..8b3a540ffa 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_gestures.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_gestures.xml @@ -8,5 +8,5 @@ android:title="Focus on a point" /> <item android:id="@+id/menu_gesture_animation" - android:title="Toggle velocity animations" /> + android:title="Turn off velocity animations" /> </menu>
\ No newline at end of file diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle index bad6c48380..c875569830 100644 --- a/platform/android/gradle/dependencies.gradle +++ b/platform/android/gradle/dependencies.gradle @@ -10,7 +10,7 @@ ext { versions = [ mapboxServices : '3.0.0-beta.4', mapboxTelemetry: '3.0.0-beta.2', - mapboxGestures : '0.1.0-20180228.152340-13', + mapboxGestures : '0.1.0', supportLib : '25.4.0', espresso : '3.0.1', testRunner : '1.0.1', |