Merge "Only check X velocity for max stick-to-target velocity." into rvc-dev am: 6275fcfbd9 am: 013e31e78e am: f9d5a1732b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11811824 Change-Id: I14a5141517fe615ae61e7b57d57dc6b8941aa8e5
This commit is contained in:
@@ -1034,13 +1034,13 @@ public class StackAnimationController extends
|
||||
mMagnetizedStack.getFlingToTargetMinVelocity() /* default */);
|
||||
final float maxVelocity = Settings.Secure.getFloat(contentResolver,
|
||||
"bubble_dismiss_stick_max_velocity",
|
||||
mMagnetizedStack.getStickToTargetMaxVelocity() /* default */);
|
||||
mMagnetizedStack.getStickToTargetMaxXVelocity() /* default */);
|
||||
final float targetWidth = Settings.Secure.getFloat(contentResolver,
|
||||
"bubble_dismiss_target_width_percent",
|
||||
mMagnetizedStack.getFlingToTargetWidthPercent() /* default */);
|
||||
|
||||
mMagnetizedStack.setFlingToTargetMinVelocity(minVelocity);
|
||||
mMagnetizedStack.setStickToTargetMaxVelocity(maxVelocity);
|
||||
mMagnetizedStack.setStickToTargetMaxXVelocity(maxVelocity);
|
||||
mMagnetizedStack.setFlingToTargetWidthPercent(targetWidth);
|
||||
|
||||
return mMagnetizedStack;
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.dynamicanimation.animation.DynamicAnimation
|
||||
import androidx.dynamicanimation.animation.FloatPropertyCompat
|
||||
import androidx.dynamicanimation.animation.SpringForce
|
||||
import com.android.systemui.util.animation.PhysicsAnimator
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.hypot
|
||||
|
||||
/**
|
||||
@@ -231,11 +232,11 @@ abstract class MagnetizedObject<T : Any>(
|
||||
var flingUnstuckFromTargetMinVelocity = 1000f
|
||||
|
||||
/**
|
||||
* Sets the maximum velocity above which the object will not stick to the target. Even if the
|
||||
* Sets the maximum X velocity above which the object will not stick to the target. Even if the
|
||||
* object is dragged through the magnetic field, it will not stick to the target until the
|
||||
* velocity is below this value.
|
||||
* horizontal velocity is below this value.
|
||||
*/
|
||||
var stickToTargetMaxVelocity = 2000f
|
||||
var stickToTargetMaxXVelocity = 2000f
|
||||
|
||||
/**
|
||||
* Enable or disable haptic vibration effects when the object interacts with the magnetic field.
|
||||
@@ -363,7 +364,7 @@ abstract class MagnetizedObject<T : Any>(
|
||||
// If the object is moving too quickly within the magnetic field, do not stick it. This
|
||||
// only applies to objects newly stuck to a target. If the object is moved into a new
|
||||
// target, it wasn't moving at all (since it was stuck to the previous one).
|
||||
if (objectNewlyStuckToTarget && hypot(velX, velY) > stickToTargetMaxVelocity) {
|
||||
if (objectNewlyStuckToTarget && abs(velX) > stickToTargetMaxXVelocity) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user