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

Commit cc210219 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disables dismissing notification on leftward swipe."

parents 05ac00c6 37d67e20
Loading
Loading
Loading
Loading
+18 −4
Original line number Original line Diff line number Diff line
@@ -33,10 +33,11 @@ import android.view.VelocityTracker;
import android.view.View;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;

import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;


public class SwipeHelper implements Gefingerpoken {
public class SwipeHelper implements Gefingerpoken {
    static final String TAG = "com.android.systemui.SwipeHelper";
    static final String TAG = "com.android.systemui.SwipeHelper";
@@ -604,13 +605,15 @@ public class SwipeHelper implements Gefingerpoken {
                    }
                    }
                    // don't let items that can't be dismissed be dragged more than
                    // don't let items that can't be dismissed be dragged more than
                    // maxScrollDistance
                    // maxScrollDistance
                    if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissed(mCurrView)) {
                    if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissedInDirection(mCurrView,
                            delta > 0)) {
                        float size = getSize(mCurrView);
                        float size = getSize(mCurrView);
                        float maxScrollDistance = MAX_SCROLL_SIZE_FRACTION * size;
                        float maxScrollDistance = MAX_SCROLL_SIZE_FRACTION * size;
                        if (absDelta >= size) {
                        if (absDelta >= size) {
                            delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
                            delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
                        } else {
                        } else {
                            delta = maxScrollDistance * (float) Math.sin((delta/size)*(Math.PI/2));
                            delta = maxScrollDistance * (float) Math.sin(
                                    (delta / size) * (Math.PI / 2));
                        }
                        }
                    }
                    }


@@ -674,9 +677,10 @@ public class SwipeHelper implements Gefingerpoken {
    }
    }


    public boolean isDismissGesture(MotionEvent ev) {
    public boolean isDismissGesture(MotionEvent ev) {
        float translation = getTranslation(mCurrView);
        return ev.getActionMasked() == MotionEvent.ACTION_UP
        return ev.getActionMasked() == MotionEvent.ACTION_UP
                && !isFalseGesture(ev) && (swipedFastEnough() || swipedFarEnough())
                && !isFalseGesture(ev) && (swipedFastEnough() || swipedFarEnough())
                && mCallback.canChildBeDismissed(mCurrView);
                && mCallback.canChildBeDismissedInDirection(mCurrView, translation > 0);
    }
    }


    public boolean isFalseGesture(MotionEvent ev) {
    public boolean isFalseGesture(MotionEvent ev) {
@@ -707,6 +711,16 @@ public class SwipeHelper implements Gefingerpoken {


        boolean canChildBeDismissed(View v);
        boolean canChildBeDismissed(View v);


        /**
         * Returns true if the provided child can be dismissed by a swipe in the given direction.
         *
         * @param isRightOrDown {@code true} if the swipe direction is right or down,
         *                      {@code false} if it is left or up.
         */
        default boolean canChildBeDismissedInDirection(View v, boolean isRightOrDown) {
            return canChildBeDismissed(v);
        }

        boolean isAntiFalsingNeeded();
        boolean isAntiFalsingNeeded();


        void onBeginDrag(View v);
        void onBeginDrag(View v);
+5 −0
Original line number Original line Diff line number Diff line
@@ -5643,6 +5643,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        public boolean canChildBeDismissed(View v) {
        public boolean canChildBeDismissed(View v) {
            return NotificationStackScrollLayout.this.canChildBeDismissed(v);
            return NotificationStackScrollLayout.this.canChildBeDismissed(v);
        }
        }

        @Override
        public boolean canChildBeDismissedInDirection(View v, boolean isRightOrDown) {
            return (isLayoutRtl() ? !isRightOrDown : isRightOrDown) && canChildBeDismissed(v);
        }
    };
    };


    // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------
    // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------