Search in sources :

Example 51 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_packages_apps_Trebuchet by LineageOS.

the class TouchEventGenerator method getFingerState.

/**
 * Returns the description of the fingers' state expected by MotionEvent.
 */
private Pair<PointerProperties[], PointerCoords[]> getFingerState() {
    int nFingers = mFingers.size();
    PointerProperties[] properties = new PointerProperties[nFingers];
    PointerCoords[] coordinates = new PointerCoords[nFingers];
    int index = 0;
    for (Map.Entry<Integer, Point> entry : mFingers.entrySet()) {
        int id = entry.getKey();
        Point location = entry.getValue();
        PointerProperties property = new PointerProperties();
        property.id = id;
        property.toolType = MotionEvent.TOOL_TYPE_FINGER;
        properties[index] = property;
        PointerCoords coordinate = new PointerCoords();
        coordinate.x = location.x;
        coordinate.y = location.y;
        coordinate.pressure = 1.0f;
        coordinates[index] = coordinate;
        index++;
    }
    return new Pair<MotionEvent.PointerProperties[], MotionEvent.PointerCoords[]>(properties, coordinates);
}
Also used : PointerCoords(android.view.MotionEvent.PointerCoords) PointerProperties(android.view.MotionEvent.PointerProperties) Point(android.graphics.Point) Map(java.util.Map) HashMap(java.util.HashMap) Point(android.graphics.Point) Pair(android.util.Pair)

Example 52 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_packages_apps_Launcher3 by ArrowOS.

the class TouchEventGenerator method getFingerState.

/**
 * Returns the description of the fingers' state expected by MotionEvent.
 */
private Pair<PointerProperties[], PointerCoords[]> getFingerState() {
    int nFingers = mFingers.size();
    PointerProperties[] properties = new PointerProperties[nFingers];
    PointerCoords[] coordinates = new PointerCoords[nFingers];
    int index = 0;
    for (Map.Entry<Integer, Point> entry : mFingers.entrySet()) {
        int id = entry.getKey();
        Point location = entry.getValue();
        PointerProperties property = new PointerProperties();
        property.id = id;
        property.toolType = MotionEvent.TOOL_TYPE_FINGER;
        properties[index] = property;
        PointerCoords coordinate = new PointerCoords();
        coordinate.x = location.x;
        coordinate.y = location.y;
        coordinate.pressure = 1.0f;
        coordinates[index] = coordinate;
        index++;
    }
    return new Pair<MotionEvent.PointerProperties[], MotionEvent.PointerCoords[]>(properties, coordinates);
}
Also used : PointerCoords(android.view.MotionEvent.PointerCoords) PointerProperties(android.view.MotionEvent.PointerProperties) Point(android.graphics.Point) Map(java.util.Map) HashMap(java.util.HashMap) Point(android.graphics.Point) Pair(android.util.Pair)

Example 53 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android-test by android.

the class MotionEventBuilder method setPointer.

/**
 * Simple mechanism to add a pointer to the MotionEvent.
 *
 * <p>Can be called multiple times to add multiple pointers to the event.
 */
public MotionEventBuilder setPointer(float x, float y) {
    PointerProperties pointerProperties = new PointerProperties();
    pointerProperties.id = pointerPropertiesList.size();
    PointerCoords pointerCoords = new PointerCoords();
    pointerCoords.x = x;
    pointerCoords.y = y;
    return setPointer(pointerProperties, pointerCoords);
}
Also used : PointerCoords(android.view.MotionEvent.PointerCoords) PointerProperties(android.view.MotionEvent.PointerProperties)

Example 54 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android-test by android.

the class PointerPropertiesBuilder method build.

public PointerProperties build() {
    final PointerProperties pointerProperties = new PointerProperties();
    pointerProperties.id = id;
    pointerProperties.toolType = toolType;
    return pointerProperties;
}
Also used : PointerProperties(android.view.MotionEvent.PointerProperties)

Example 55 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android-test by android.

the class MotionEventSubject method pointerProperties.

public PointerPropertiesSubject pointerProperties(int pointerIndex) {
    PointerProperties outPointerProps = new PointerProperties();
    actual.getPointerProperties(pointerIndex, outPointerProps);
    return check("getPointerProperties(%s)", pointerIndex).about(PointerPropertiesSubject.pointerProperties()).that(outPointerProps);
}
Also used : PointerProperties(android.view.MotionEvent.PointerProperties)

Aggregations

PointerProperties (android.view.MotionEvent.PointerProperties)55 PointerCoords (android.view.MotionEvent.PointerCoords)38 Point (android.graphics.Point)22 MotionEvent (android.view.MotionEvent)19 Pair (android.util.Pair)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Test (org.junit.Test)7 Rect (android.graphics.Rect)5 DeviceProfile (com.android.launcher3.DeviceProfile)2 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)2 GesturePoint (android.gesture.GesturePoint)1 HiddenApi (org.robolectric.annotation.HiddenApi)1 Implementation (org.robolectric.annotation.Implementation)1