From 4ca06c1e8e1a0680ebb2abddd6791b619103ca60 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Thu, 18 Jun 2020 11:32:37 -0400 Subject: [PATCH] Only take vertical, upward velocity into account for escaping the dismiss target. Fixes: 157180669 Test: manual Change-Id: I407ccc7d74906c83c65a93f2e12ad6423b161a32 --- .../systemui/util/magnetictarget/MagnetizedObject.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt b/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt index 5a2b064c53895..94451af434541 100644 --- a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt +++ b/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt @@ -229,7 +229,7 @@ abstract class MagnetizedObject( * to the target. If this velocity is reached, the object will be freed even if it wasn't moved * outside the magnetic field radius. */ - var flingUnstuckFromTargetMinVelocity = 1000f + var flingUnstuckFromTargetMinVelocity = 4000f /** * Sets the maximum X velocity above which the object will not stick to the target. Even if the @@ -402,9 +402,10 @@ abstract class MagnetizedObject( cancelAnimations() if (objectStuckToTarget) { - if (hypot(velX, velY) > flingUnstuckFromTargetMinVelocity) { - // If the object is stuck, but it was forcefully flung away from the target, - // tell the listener so the object can be animated out of the target. + if (-velY > flingUnstuckFromTargetMinVelocity) { + // If the object is stuck, but it was forcefully flung away from the target in + // the upward direction, tell the listener so the object can be animated out of + // the target. magnetListener.onUnstuckFromTarget( targetObjectIsStuckTo!!, velX, velY, wasFlungOut = true) } else {