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

Commit c4e68d46 authored by Gus Prevas's avatar Gus Prevas
Browse files

Applies friction to non-dismiss drag only after the snap point.

This change modifies SwipeHelper such that the friction applied to a
constrained gesture (i.e. one that won't dismiss the swiped object) is
only applied once the object has been dragged past a threshold defined
by the callback object.  The callback provided by
NotificationStackScrollLayout is modified to set this threshold at the
snap point of the active menu row.

Change-Id: Ide9261682963d3cfaeb470e08393c182d6fa06c6
Fixes: 123021652
Test: atest SystemUITests, manual
parent c6223792
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -604,8 +604,14 @@ public class SwipeHelper implements Gefingerpoken {
                        if (absDelta >= size) {
                            delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
                        } else {
                            delta = maxScrollDistance * (float) Math.sin(
                                    (delta / size) * (Math.PI / 2));
                            int startPosition = mCallback.getConstrainSwipeStartPosition();
                            if (absDelta > startPosition) {
                                int signedStartPosition =
                                        (int) (startPosition * Math.signum(delta));
                                delta = signedStartPosition
                                        + maxScrollDistance * (float) Math.sin(
                                        ((delta - signedStartPosition) / size) * (Math.PI / 2));
                            }
                        }
                    }

@@ -741,6 +747,14 @@ public class SwipeHelper implements Gefingerpoken {
         */
        float getFalsingThresholdFactor();

        /**
         * @return The position, in pixels, at which a constrained swipe should start being
         * constrained.
         */
        default int getConstrainSwipeStartPosition() {
            return 0;
        }

        /**
         * @return If true, the given view is draggable.
         */
+9 −0
Original line number Diff line number Diff line
@@ -5823,6 +5823,15 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
        }

        @Override
        public int getConstrainSwipeStartPosition() {
            NotificationMenuRowPlugin menuRow = mSwipeHelper.getCurrentMenuRow();
            if (menuRow != null) {
                return Math.abs(menuRow.getMenuSnapTarget());
            }
            return 0;
        }

                @Override
        public boolean canChildBeDismissed(View v) {
            return NotificationStackScrollLayout.this.canChildBeDismissed(v);