Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f170a6a8 authored by Joshua Tsuji's avatar Joshua Tsuji
Browse files

Only check X velocity for max stick-to-target velocity.

This was designed so you can drag objects through the dismiss target from left to right (or vv) without them sticking. Checking the hypot of velocity only results in false negatives when dragging down to the target.

Test: manual
Bug: 157180669
Change-Id: I21e3c048c00202fc0660aaec0c22f7825bf26f46
parent b1215125
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
+5 −4
Original line number Diff line number Diff line
@@ -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
            }