[android] bring back scale delta span threshold when rotation is started first

This commit is contained in:
Łukasz Paczos
2019-08-14 13:22:35 +02:00
committed by Łukasz Paczos
parent acc6079b08
commit eab3fbf5bf
4 changed files with 41 additions and 6 deletions

View File

@@ -73,6 +73,14 @@ public class MapboxConstants {
*/
public static final long VELOCITY_THRESHOLD_IGNORE_FLING = 1000;
/**
* Value by which the default rotation threshold will be increased when scaling
*
* @deprecated unused, see {@link com.mapbox.mapboxsdk.maps.UiSettings#setDisableRotateWhenScaling(boolean)}
*/
@Deprecated
public static final float ROTATION_THRESHOLD_INCREASE_WHEN_SCALING = 25f;
/**
* Maximum absolute zoom change for multi-pointer scale velocity animation
*/
@@ -83,6 +91,14 @@ public class MapboxConstants {
*/
public static final double SCALE_VELOCITY_ANIMATION_DURATION_MULTIPLIER = 150;
/**
* Minimum angular velocity for rotation animation
*
* @deprecated unused, see {@link #ROTATE_VELOCITY_RATIO_THRESHOLD}
*/
@Deprecated
public static final float MINIMUM_ANGULAR_VELOCITY = 1.5f;
/**
* Last scale span delta to XY velocity ratio required to execute scale velocity animation.
*/

View File

@@ -123,9 +123,12 @@ final class MapGestureDetector {
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_density_constant),
context.getResources().getDimension(R.dimen.mapbox_angular_velocity_multiplier),
context.getResources().getDimension(R.dimen.mapbox_minimum_angular_velocity));
context.getResources().getDimension(R.dimen.mapbox_minimum_angular_velocity),
context.getResources().getDimension(
com.mapbox.android.gestures.R.dimen.mapbox_defaultScaleSpanSinceStartThreshold));
ShoveGestureListener shoveGestureListener = new ShoveGestureListener();
TapGestureListener tapGestureListener = new TapGestureListener();
@@ -641,14 +644,19 @@ final class MapGestureDetector {
}
private final class RotateGestureListener extends RotateGestureDetector.SimpleOnRotateGestureListener {
private final float minimumScaleSpanWhenRotating;
private final float angularVelocityMultiplier;
private final float minimumAngularVelocity;
private final double rotateVelocityRatioThreshold;
private final float defaultSpanSinceStartThreshold;
RotateGestureListener(double densityMultiplier, float angularVelocityMultiplier, float minimumAngularVelocity) {
RotateGestureListener(float minimumScaleSpanWhenRotating, double densityMultiplier, float angularVelocityMultiplier,
float minimumAngularVelocity, float defaultSpanSinceStartThreshold) {
this.minimumScaleSpanWhenRotating = minimumScaleSpanWhenRotating;
this.angularVelocityMultiplier = angularVelocityMultiplier;
this.minimumAngularVelocity = minimumAngularVelocity;
this.rotateVelocityRatioThreshold = ROTATE_VELOCITY_RATIO_THRESHOLD * densityMultiplier;
this.defaultSpanSinceStartThreshold = defaultSpanSinceStartThreshold;
}
@Override
@@ -675,6 +683,13 @@ final class MapGestureDetector {
return false;
}
if (uiSettings.isIncreaseScaleThresholdWhenRotating()) {
// when rotation starts, interrupting scale and increasing the threshold
// to make rotation without scaling easier
gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(minimumScaleSpanWhenRotating);
gesturesManager.getStandardScaleGestureDetector().interrupt();
}
cancelTransitionsIfRequired();
notifyOnRotateBeginListeners(detector);
@@ -703,6 +718,11 @@ final class MapGestureDetector {
@Override
public void onRotateEnd(@NonNull RotateGestureDetector detector, float velocityX,
float velocityY, float angularVelocity) {
if (uiSettings.isIncreaseScaleThresholdWhenRotating()) {
// resetting default scale threshold values
gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(defaultSpanSinceStartThreshold);
}
notifyOnRotateEndListeners(detector);
angularVelocity = angularVelocity * angularVelocityMultiplier;

View File

@@ -962,9 +962,7 @@ public final class UiSettings {
* Returns whether scale threshold should be increase whenever rotation is detected.
*
* @return If true, scale threshold will be increased.
* @deprecated unused
*/
@Deprecated
public boolean isIncreaseScaleThresholdWhenRotating() {
return increaseScaleThresholdWhenRotating;
}
@@ -973,9 +971,7 @@ public final class UiSettings {
* set whether scale threshold should be increase whenever rotation is detected.
*
* @param increaseScaleThresholdWhenRotating If true, scale threshold will be increased.
* @deprecated unused
*/
@Deprecated
public void setIncreaseScaleThresholdWhenRotating(boolean increaseScaleThresholdWhenRotating) {
this.increaseScaleThresholdWhenRotating = increaseScaleThresholdWhenRotating;
}

View File

@@ -12,6 +12,9 @@
<!--Minimum scale velocity required to start animation-->
<dimen name="mapbox_minimum_scale_velocity">225dp</dimen>
<!--Minimum scale span delta required to execute scale gesture when rotating-->
<dimen name="mapbox_minimum_scale_span_when_rotating">75dp</dimen>
<!--Minimum angular velocity required to start rotation animation-->
<dimen name="mapbox_minimum_angular_velocity">0.10dp</dimen>