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

Commit 25dcf2de authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add util method to check if MotionEvent is synthesized touchpad gesture" into main

parents f3474e60 6aced6ea
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -2530,6 +2530,29 @@ public final class MotionEvent extends InputEvent implements Parcelable {
                || getActionMasked() == ACTION_HOVER_MOVE;
    }

    /**
     * Returns {@code true} if this motion event is a synthesized touchpad gesture.
     *
     * <p>Before using this method, consider whether you truly need to apply special treatment to
     * all synthesized touchpad gestures (including ones which may be added in future), or whether a
     * check for a specific classification (e.g. {@link #CLASSIFICATION_TWO_FINGER_SWIPE}) would
     * suffice instead.
     *
     * @see #CLASSIFICATION_TWO_FINGER_SWIPE
     * @see #CLASSIFICATION_PINCH
     * @see #CLASSIFICATION_MULTI_FINGER_SWIPE
     *
     * @hide
     */
    public boolean isSynthesizedTouchpadGesture() {
        int classification = getClassification();
        return isFromSource(InputDevice.SOURCE_MOUSE) && getToolType(0)
                == MotionEvent.TOOL_TYPE_FINGER && (
                classification == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE
                        || classification == MotionEvent.CLASSIFICATION_PINCH
                        || classification == MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE);
    }

    /**
     * Gets the motion event flags.
     *