diff --git a/core/api/current.txt b/core/api/current.txt index 9a6e76bafbafe..6396715818857 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -50560,6 +50560,7 @@ package android.view { field public static final int AXIS_GENERIC_7 = 38; // 0x26 field public static final int AXIS_GENERIC_8 = 39; // 0x27 field public static final int AXIS_GENERIC_9 = 40; // 0x28 + field public static final int AXIS_GESTURE_PINCH_SCALE_FACTOR = 52; // 0x34 field public static final int AXIS_GESTURE_SCROLL_X_DISTANCE = 50; // 0x32 field public static final int AXIS_GESTURE_SCROLL_Y_DISTANCE = 51; // 0x33 field public static final int AXIS_GESTURE_X_OFFSET = 48; // 0x30 @@ -50600,6 +50601,7 @@ package android.view { field public static final int CLASSIFICATION_AMBIGUOUS_GESTURE = 1; // 0x1 field public static final int CLASSIFICATION_DEEP_PRESS = 2; // 0x2 field public static final int CLASSIFICATION_NONE = 0; // 0x0 + field public static final int CLASSIFICATION_PINCH = 5; // 0x5 field public static final int CLASSIFICATION_TWO_FINGER_SWIPE = 3; // 0x3 field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int EDGE_BOTTOM = 2; // 0x2 diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index b91019c016108..84bbdd1266d0b 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1283,6 +1283,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { * swipe gesture starts at X = 500 then moves to X = 400, this axis would have a value of * -0.1. * + * These values are relative to the state from the last event, not accumulated, so developers + * should make sure to process this axis value for all batched historical events. */ public static final int AXIS_GESTURE_X_OFFSET = 48; @@ -1300,6 +1302,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { *
  • For a touch pad, reports the distance that should be scrolled in the X axis as a result * of the user's two-finger scroll gesture, in display pixels. * + * These values are relative to the state from the last event, not accumulated, so developers + * should make sure to process this axis value for all batched historical events. */ public static final int AXIS_GESTURE_SCROLL_X_DISTANCE = 50; @@ -1310,6 +1314,19 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int AXIS_GESTURE_SCROLL_Y_DISTANCE = 51; + /** + * Axis constant: pinch scale factor of a motion event. + *

    + *

    + * These values are relative to the state from the last event, not accumulated, so developers + * should make sure to process this axis value for all batched historical events. + */ + public static final int AXIS_GESTURE_PINCH_SCALE_FACTOR = 52; + // NOTE: If you add a new axis here you must also add it to: // frameworks/native/include/android/input.h // frameworks/native/libs/input/InputEventLabels.cpp @@ -1369,6 +1386,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { names.append(AXIS_GESTURE_Y_OFFSET, "AXIS_GESTURE_Y_OFFSET"); names.append(AXIS_GESTURE_SCROLL_X_DISTANCE, "AXIS_GESTURE_SCROLL_X_DISTANCE"); names.append(AXIS_GESTURE_SCROLL_Y_DISTANCE, "AXIS_GESTURE_SCROLL_Y_DISTANCE"); + names.append(AXIS_GESTURE_PINCH_SCALE_FACTOR, "AXIS_GESTURE_PINCH_SCALE_FACTOR"); } /** @@ -1522,11 +1540,22 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int CLASSIFICATION_MULTI_FINGER_SWIPE = 4; + /** + * Classification constant: touchpad pinch. + * + * The current event stream represents the user pinching with two fingers on a touchpad. The + * gesture is centered around the current cursor position. + * + * @see #getClassification + */ + public static final int CLASSIFICATION_PINCH = 5; + /** @hide */ @Retention(SOURCE) @IntDef(prefix = { "CLASSIFICATION" }, value = { CLASSIFICATION_NONE, CLASSIFICATION_AMBIGUOUS_GESTURE, CLASSIFICATION_DEEP_PRESS, - CLASSIFICATION_TWO_FINGER_SWIPE, CLASSIFICATION_MULTI_FINGER_SWIPE}) + CLASSIFICATION_TWO_FINGER_SWIPE, CLASSIFICATION_MULTI_FINGER_SWIPE, + CLASSIFICATION_PINCH}) public @interface Classification {}; /** diff --git a/native/android/input.cpp b/native/android/input.cpp index 5e5ebed78e619..f1c30889c4db9 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -299,6 +299,8 @@ int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) { return AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE; case android::MotionClassification::MULTI_FINGER_SWIPE: return AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE; + case android::MotionClassification::PINCH: + return AMOTION_EVENT_CLASSIFICATION_PINCH; } }