summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Juan Sebastian Martinez <juansmartinez@google.com> 2025-03-11 09:09:52 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-11 09:09:52 -0700
commitbb18df333e6de2926e75ea16fe8ae1985348417b (patch)
tree036348605e533034fa35439a787d89fa8627021e
parent0791a627a3f415471e16ce613904b837059e0bf5 (diff)
parent14ab8dc317a500d37ff353c38d23b37ec018ea98 (diff)
Merge changes from topic "revert-32206328-MAGNETIC_REATTACH-ZWQICZGUQH" into main
* changes: Revert "Consolidating magnetic detachment with dismissibility." Revert "Implementing magnetic attachment using springs."
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java3
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt47
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManager.kt20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt53
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticRowListener.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java6
11 files changed, 30 insertions, 196 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
index af52c31b1c53..9fdfca14a5b2 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.platform.test.annotations.DisableFlags;
import android.provider.Settings;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
@@ -39,7 +38,6 @@ import android.view.ViewGroup;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import com.android.systemui.Flags;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -415,7 +413,6 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
assertTrue("when alpha is .5, menu is visible", row.isMenuVisible());
}
- @DisableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
@Test
public void testOnTouchMove() {
NotificationMenuRow row = Mockito.spy(
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt
index 6c6ba933c03a..ccc8be7de038 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt
@@ -130,9 +130,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
kosmos.testScope.runTest {
// GIVEN a threshold of 100 px
val threshold = 100f
- underTest.onDensityChange(
- threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- )
+ underTest.setSwipeThresholdPx(threshold)
// GIVEN that targets are set and the rows are being pulled
setTargets()
@@ -152,9 +150,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
kosmos.testScope.runTest {
// GIVEN a threshold of 100 px
val threshold = 100f
- underTest.onDensityChange(
- threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- )
+ underTest.setSwipeThresholdPx(threshold)
// GIVEN that targets are set and the rows are being pulled
canRowBeDismissed = false
@@ -176,9 +172,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
kosmos.testScope.runTest {
// GIVEN a threshold of 100 px
val threshold = 100f
- underTest.onDensityChange(
- threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- )
+ underTest.setSwipeThresholdPx(threshold)
// GIVEN that targets are set and the rows are being pulled
setTargets()
@@ -198,9 +192,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
kosmos.testScope.runTest {
// GIVEN a threshold of 100 px
val threshold = 100f
- underTest.onDensityChange(
- threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- )
+ underTest.setSwipeThresholdPx(threshold)
// GIVEN that targets are set and the rows are being pulled
canRowBeDismissed = false
@@ -302,29 +294,6 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
assertThat(underTest.isSwipedViewRoundableSet).isFalse()
}
- @Test
- fun isMagneticRowDismissible_isDismissibleWhenDetached() =
- kosmos.testScope.runTest {
- setDetachedState()
-
- val isDismissible = underTest.isMagneticRowSwipeDetached(swipedRow)
- assertThat(isDismissible).isTrue()
- }
-
- @Test
- fun setMagneticRowTranslation_whenDetached_belowAttachThreshold_reattaches() =
- kosmos.testScope.runTest {
- // GIVEN that the swiped view has been detached
- setDetachedState()
-
- // WHEN setting a new translation above the attach threshold
- val translation = 50f
- underTest.setMagneticRowTranslation(swipedRow, translation)
-
- // THEN the swiped view reattaches magnetically and the state becomes PULLING
- assertThat(underTest.currentState).isEqualTo(State.PULLING)
- }
-
@After
fun tearDown() {
// We reset the manager so that all MagneticRowListener can cancel all animations
@@ -333,9 +302,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
private fun setDetachedState() {
val threshold = 100f
- underTest.onDensityChange(
- threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- )
+ underTest.setSwipeThresholdPx(threshold)
// Set the pulling state
setTargets()
@@ -360,8 +327,8 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
private fun MagneticRowListener.asTestableListener(rowIndex: Int): MagneticRowListener {
val delegate = this
return object : MagneticRowListener {
- override fun setMagneticTranslation(translation: Float, trackEagerly: Boolean) {
- delegate.setMagneticTranslation(translation, trackEagerly)
+ override fun setMagneticTranslation(translation: Float) {
+ delegate.setMagneticTranslation(translation)
}
override fun triggerMagneticForce(
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
index de48f4018989..789701f5e4b0 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
@@ -49,7 +49,6 @@ import android.view.ViewConfiguration;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.flags.FakeFeatureFlags;
@@ -363,7 +362,6 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
verify(mSwipeHelper, times(1)).isFalseGesture();
}
- @DisableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
@Test
public void testIsDismissGesture_farEnough() {
doReturn(false).when(mSwipeHelper).isFalseGesture();
@@ -376,20 +374,6 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
verify(mSwipeHelper, times(1)).isFalseGesture();
}
- @EnableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
- @Test
- public void testIsDismissGesture_magneticSwipeIsDismissible() {
- doReturn(false).when(mSwipeHelper).isFalseGesture();
- doReturn(false).when(mSwipeHelper).swipedFarEnough();
- doReturn(false).when(mSwipeHelper).swipedFastEnough();
- doReturn(true).when(mCallback).isMagneticViewDetached(any());
- when(mCallback.canChildBeDismissedInDirection(any(), anyBoolean())).thenReturn(true);
- when(mEvent.getActionMasked()).thenReturn(MotionEvent.ACTION_UP);
-
- assertTrue("Should be a dismissal", mSwipeHelper.isDismissGesture(mEvent));
- verify(mSwipeHelper, times(1)).isFalseGesture();
- }
-
@Test
public void testIsDismissGesture_notFarOrFastEnough() {
doReturn(false).when(mSwipeHelper).isFalseGesture();
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index e3afe2e190e9..c78f75a334fd 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -778,26 +778,18 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
protected boolean swipedFarEnough() {
float translation = getTranslation(mTouchedView);
- return Math.abs(translation) > SWIPED_FAR_ENOUGH_SIZE_FRACTION * getSize(mTouchedView);
+ return Math.abs(translation) > SWIPED_FAR_ENOUGH_SIZE_FRACTION * getSize(
+ mTouchedView);
}
public boolean isDismissGesture(MotionEvent ev) {
float translation = getTranslation(mTouchedView);
return ev.getActionMasked() == MotionEvent.ACTION_UP
&& !mFalsingManager.isUnlockingDisabled()
- && !isFalseGesture() && isSwipeDismissible()
+ && !isFalseGesture() && (swipedFastEnough() || swipedFarEnough())
&& mCallback.canChildBeDismissedInDirection(mTouchedView, translation > 0);
}
- /** Can the swipe gesture on the touched view be considered as a dismiss intention */
- public boolean isSwipeDismissible() {
- if (magneticNotificationSwipes()) {
- return mCallback.isMagneticViewDetached(mTouchedView) || swipedFastEnough();
- } else {
- return swipedFastEnough() || swipedFarEnough();
- }
- }
-
/** Returns true if the gesture should be rejected. */
public boolean isFalseGesture() {
boolean falsingDetected = mCallback.isAntiFalsingNeeded();
@@ -978,13 +970,6 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
void onMagneticInteractionEnd(View view, float velocity);
/**
- * Determine if a view managed by magnetic interactions is magnetically detached
- * @param view The magnetic view
- * @return if the view is detached according to its magnetic state.
- */
- boolean isMagneticViewDetached(View view);
-
- /**
* Called when the child is long pressed and available to start drag and drop.
*
* @param v the view that was long pressed.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
index f36a0cf51b97..292f74a65554 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
@@ -19,8 +19,6 @@ package com.android.systemui.statusbar.notification.row;
import static com.android.systemui.Flags.notificationColorUpdateLogger;
import static com.android.systemui.Flags.physicalNotificationMovement;
-import static java.lang.Math.abs;
-
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
@@ -31,7 +29,6 @@ import android.util.FloatProperty;
import android.util.IndentingPrintWriter;
import android.util.Log;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
@@ -113,27 +110,14 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
protected SpringAnimation mMagneticAnimator = new SpringAnimation(
this /* object */, DynamicAnimation.TRANSLATION_X);
- private int mTouchSlop;
-
protected MagneticRowListener mMagneticRowListener = new MagneticRowListener() {
@Override
- public void setMagneticTranslation(float translation, boolean trackEagerly) {
- if (!mMagneticAnimator.isRunning()) {
- setTranslation(translation);
- return;
- }
-
- if (trackEagerly) {
- float delta = abs(getTranslation() - translation);
- if (delta > mTouchSlop) {
- mMagneticAnimator.animateToFinalPosition(translation);
- } else {
- mMagneticAnimator.cancel();
- setTranslation(translation);
- }
- } else {
+ public void setMagneticTranslation(float translation) {
+ if (mMagneticAnimator.isRunning()) {
mMagneticAnimator.animateToFinalPosition(translation);
+ } else {
+ setTranslation(translation);
}
}
@@ -199,7 +183,6 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
private void initDimens() {
mContentShift = getResources().getDimensionPixelSize(
R.dimen.shelf_transform_content_shift);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
index 286f07b7413d..e89a76fd5a69 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
@@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
+import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.View;
@@ -357,9 +358,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
final float dismissThreshold = getDismissThreshold();
final boolean snappingToDismiss = delta < -dismissThreshold || delta > dismissThreshold;
if (mSnappingToDismiss != snappingToDismiss) {
- if (!Flags.magneticNotificationSwipes()) {
- getMenuView().performHapticFeedback(CLOCK_TICK);
- }
+ getMenuView().performHapticFeedback(CLOCK_TICK);
}
mSnappingToDismiss = snappingToDismiss;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManager.kt
index 48cff7497e3c..aa6951715755 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManager.kt
@@ -33,12 +33,12 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
interface MagneticNotificationRowManager {
/**
- * Notifies a change in the device density. The density can be used to compute the values of
- * thresholds in pixels.
+ * Set the swipe threshold in pixels. After crossing the threshold, the magnetic target detaches
+ * and the magnetic neighbors snap back.
*
- * @param[density] The device density.
+ * @param[threshold] Swipe threshold in pixels.
*/
- fun onDensityChange(density: Float)
+ fun setSwipeThresholdPx(thresholdPx: Float)
/**
* Set the magnetic and roundable targets of a magnetic swipe interaction.
@@ -87,9 +87,6 @@ interface MagneticNotificationRowManager {
*/
fun onMagneticInteractionEnd(row: ExpandableNotificationRow, velocity: Float? = null)
- /** Determine if the given [ExpandableNotificationRow] has been magnetically detached. */
- fun isMagneticRowSwipeDetached(row: ExpandableNotificationRow): Boolean
-
/* Reset any roundness that magnetic targets may have */
fun resetRoundness()
@@ -107,15 +104,12 @@ interface MagneticNotificationRowManager {
/** Detaching threshold in dp */
const val MAGNETIC_DETACH_THRESHOLD_DP = 56
- /** Re-attaching threshold in dp */
- const val MAGNETIC_ATTACH_THRESHOLD_DP = 40
-
/* An empty implementation of a manager */
@JvmStatic
val Empty: MagneticNotificationRowManager
get() =
object : MagneticNotificationRowManager {
- override fun onDensityChange(density: Float) {}
+ override fun setSwipeThresholdPx(thresholdPx: Float) {}
override fun setMagneticAndRoundableTargets(
swipingRow: ExpandableNotificationRow,
@@ -133,10 +127,6 @@ interface MagneticNotificationRowManager {
velocity: Float?,
) {}
- override fun isMagneticRowSwipeDetached(
- row: ExpandableNotificationRow
- ): Boolean = false
-
override fun resetRoundness() {}
override fun reset() {}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt
index 3f05cef6a0c6..9bd5a5bd903f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt
@@ -47,7 +47,6 @@ constructor(
private set
private var magneticDetachThreshold = Float.POSITIVE_INFINITY
- private var magneticAttachThreshold = 0f
// Has the roundable target been set for the magnetic view that is being swiped.
val isSwipedViewRoundableSet: Boolean
@@ -58,18 +57,13 @@ constructor(
SpringForce().setStiffness(DETACH_STIFFNESS).setDampingRatio(DETACH_DAMPING_RATIO)
private val snapForce =
SpringForce().setStiffness(SNAP_BACK_STIFFNESS).setDampingRatio(SNAP_BACK_DAMPING_RATIO)
- private val attachForce =
- SpringForce().setStiffness(ATTACH_STIFFNESS).setDampingRatio(ATTACH_DAMPING_RATIO)
// Multiplier applied to the translation of a row while swiped
val swipedRowMultiplier =
MAGNETIC_TRANSLATION_MULTIPLIERS[MAGNETIC_TRANSLATION_MULTIPLIERS.size / 2]
- override fun onDensityChange(density: Float) {
- magneticDetachThreshold =
- density * MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
- magneticAttachThreshold =
- density * MagneticNotificationRowManager.MAGNETIC_ATTACH_THRESHOLD_DP
+ override fun setSwipeThresholdPx(thresholdPx: Float) {
+ magneticDetachThreshold = thresholdPx
}
override fun setMagneticAndRoundableTargets(
@@ -145,7 +139,8 @@ constructor(
}
}
State.DETACHED -> {
- translateDetachedRow(translation)
+ val swiped = currentMagneticListeners.swipedListener()
+ swiped?.setMagneticTranslation(translation)
}
}
return true
@@ -237,41 +232,6 @@ constructor(
)
}
- private fun translateDetachedRow(translation: Float) {
- val targetTranslation = swipedRowMultiplier * translation
- val crossedThreshold = abs(targetTranslation) <= magneticAttachThreshold
- if (crossedThreshold) {
- attachNeighbors(translation)
- updateRoundness(translation)
- currentMagneticListeners.swipedListener()?.let { attach(it, translation) }
- currentState = State.PULLING
- } else {
- val swiped = currentMagneticListeners.swipedListener()
- swiped?.setMagneticTranslation(translation, trackEagerly = false)
- }
- }
-
- private fun attachNeighbors(translation: Float) {
- currentMagneticListeners.forEachIndexed { i, target ->
- target?.let {
- if (i != currentMagneticListeners.size / 2) {
- val multiplier = MAGNETIC_TRANSLATION_MULTIPLIERS[i]
- target.cancelMagneticAnimations()
- target.triggerMagneticForce(
- endTranslation = translation * multiplier,
- attachForce,
- )
- }
- }
- }
- }
-
- private fun attach(listener: MagneticRowListener, toPosition: Float) {
- listener.cancelMagneticAnimations()
- listener.triggerMagneticForce(toPosition, attachForce)
- msdlPlayer.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR)
- }
-
override fun onMagneticInteractionEnd(row: ExpandableNotificationRow, velocity: Float?) {
if (row.isSwipedTarget()) {
when (currentState) {
@@ -294,9 +254,6 @@ constructor(
}
}
- override fun isMagneticRowSwipeDetached(row: ExpandableNotificationRow): Boolean =
- row.isSwipedTarget() && currentState == State.DETACHED
-
override fun resetRoundness() = notificationRoundnessManager.clear()
override fun reset() {
@@ -343,8 +300,6 @@ constructor(
private const val DETACH_DAMPING_RATIO = 0.95f
private const val SNAP_BACK_STIFFNESS = 550f
private const val SNAP_BACK_DAMPING_RATIO = 0.6f
- private const val ATTACH_STIFFNESS = 800f
- private const val ATTACH_DAMPING_RATIO = 0.95f
// Maximum value of corner roundness that gets applied during the pre-detach dragging
private const val MAX_PRE_DETACH_ROUNDNESS = 0.8f
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticRowListener.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticRowListener.kt
index c3b9024ad9b1..5959ef1e093b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticRowListener.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticRowListener.kt
@@ -21,21 +21,8 @@ import androidx.dynamicanimation.animation.SpringForce
/** A listener that responds to magnetic forces applied to an [ExpandableNotificationRow] */
interface MagneticRowListener {
- /**
- * Set a translation due to a magnetic attachment.
- *
- * The request to set a View's translation may occur while a magnetic animation is running. In
- * such a case, the [trackEagerly] argument will determine if we decide to eagerly track the
- * incoming translation or not. If true, the ongoing animation will update its target position
- * and continue to animate only if the incoming translation produces a delta higher than a touch
- * slop threshold. Otherwise, the animation will be cancelled and the View translation will be
- * set directly. If [trackEagerly] is false, we respect the animation and only update the
- * animated target.
- *
- * @param[translation] Incoming gesture translation.
- * @param[trackEagerly] Whether we eagerly track the incoming translation directly or not.
- */
- fun setMagneticTranslation(translation: Float, trackEagerly: Boolean = true)
+ /** Set a translation due to a magnetic attachment. */
+ fun setMagneticTranslation(translation: Float)
/**
* Trigger the magnetic behavior when the row detaches or snaps back from its magnetic
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index 2d0a1c069c5c..bb3abc1fba38 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -486,22 +486,15 @@ public class NotificationStackScrollLayoutController implements Dumpable {
}
@Override
- public boolean isMagneticViewDetached(View view) {
- if (view instanceof ExpandableNotificationRow row) {
- return mMagneticNotificationRowManager.isMagneticRowSwipeDetached(row);
- } else {
- return false;
- }
- }
-
- @Override
public float getTotalTranslationLength(View animView) {
return mView.getTotalTranslationLength(animView);
}
@Override
public void onDensityScaleChange(float density) {
- mMagneticNotificationRowManager.onDensityChange(density);
+ mMagneticNotificationRowManager.setSwipeThresholdPx(
+ density * MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
+ );
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
index 33b94783b24a..c5a846e1da05 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
@@ -33,7 +33,6 @@ import android.view.ViewConfiguration;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
-import com.android.systemui.Flags;
import com.android.systemui.SwipeHelper;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
@@ -192,11 +191,6 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
@Override
public boolean handleUpEvent(MotionEvent ev, View animView, float velocity,
float translation) {
- if (Flags.magneticNotificationSwipes()
- && (mCallback.isMagneticViewDetached(animView) || swipedFastEnough())) {
- dismiss(animView, velocity);
- return true;
- }
NotificationMenuRowPlugin menuRow = getCurrentMenuRow();
if (menuRow != null) {
menuRow.onTouchEnd();