Search in sources :

Example 1 with GestureDescription

use of android.accessibilityservice.GestureDescription in project Auto.js by hyb1996.

the class GlobalActionAutomator method gesturesWithoutHandler.

@RequiresApi(api = Build.VERSION_CODES.N)
private boolean gesturesWithoutHandler(GestureDescription description) {
    prepareLooperIfNeeded();
    final VolatileBox<Boolean> result = new VolatileBox<>(false);
    Handler handler = new Handler(Looper.myLooper());
    mService.dispatchGesture(description, new AccessibilityService.GestureResultCallback() {

        @Override
        public void onCompleted(GestureDescription gestureDescription) {
            result.set(true);
            quitLoop();
        }

        @Override
        public void onCancelled(GestureDescription gestureDescription) {
            result.set(false);
            quitLoop();
        }
    }, handler);
    Looper.loop();
    return result.get();
}
Also used : AccessibilityService(android.accessibilityservice.AccessibilityService) VolatileBox(com.stardust.concurrent.VolatileBox) Handler(android.os.Handler) GestureDescription(android.accessibilityservice.GestureDescription) RequiresApi(android.support.annotation.RequiresApi)

Example 2 with GestureDescription

use of android.accessibilityservice.GestureDescription in project kdeconnect-android by KDE.

the class MouseReceiverService method createClick.

@RequiresApi(api = Build.VERSION_CODES.N)
private static GestureDescription createClick(float x, float y, int duration) {
    Path clickPath = new Path();
    clickPath.moveTo(x, y);
    GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, duration);
    GestureDescription.Builder clickBuilder = new GestureDescription.Builder();
    clickBuilder.addStroke(clickStroke);
    return clickBuilder.build();
}
Also used : Path(android.graphics.Path) GestureDescription(android.accessibilityservice.GestureDescription) RequiresApi(androidx.annotation.RequiresApi)

Example 3 with GestureDescription

use of android.accessibilityservice.GestureDescription in project WeChatLuckyMoney by geeeeeeeeek.

the class HongbaoService method openPacket.

private void openPacket() {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float dpi = metrics.densityDpi;
    Log.d(TAG, "openPacket!" + dpi);
    if (android.os.Build.VERSION.SDK_INT <= 23) {
        mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    } else {
        if (android.os.Build.VERSION.SDK_INT > 23) {
            Path path = new Path();
            if (640 == dpi) {
                // 1440
                path.moveTo(720, 1575);
            } else if (320 == dpi) {
                // 720p
                path.moveTo(355, 780);
            } else if (480 == dpi) {
                // 1080p
                path.moveTo(533, 1115);
            }
            GestureDescription.Builder builder = new GestureDescription.Builder();
            GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 450, 50)).build();
            dispatchGesture(gestureDescription, new GestureResultCallback() {

                @Override
                public void onCompleted(GestureDescription gestureDescription) {
                    Log.d(TAG, "onCompleted");
                    mMutex = false;
                    super.onCompleted(gestureDescription);
                }

                @Override
                public void onCancelled(GestureDescription gestureDescription) {
                    Log.d(TAG, "onCancelled");
                    mMutex = false;
                    super.onCancelled(gestureDescription);
                }
            }, null);
        }
    }
}
Also used : Path(android.graphics.Path) GestureDescription(android.accessibilityservice.GestureDescription) DisplayMetrics(android.util.DisplayMetrics)

Example 4 with GestureDescription

use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.

the class ShadowAccessibilityServiceTest method getGesturesDispatched_returnsFirstGestureResultCallback.

@Test
@Config(minSdk = N)
public void getGesturesDispatched_returnsFirstGestureResultCallback() {
    GestureDescription gestureDescription = createTestGesture();
    GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
    service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
    null);
    assertThat(shadow.getGesturesDispatched().get(0).callback()).isSameInstanceAs(gestureResultCallback);
}
Also used : GestureDescription(android.accessibilityservice.GestureDescription) GestureResultCallback(android.accessibilityservice.AccessibilityService.GestureResultCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 5 with GestureDescription

use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.

the class ShadowAccessibilityServiceTest method setCanDispatchGestures_true_causesDispatchGestureToReturnTrue.

@Test
@Config(minSdk = N)
public void setCanDispatchGestures_true_causesDispatchGestureToReturnTrue() {
    GestureDescription gestureDescription = createTestGesture();
    GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
    shadow.setCanDispatchGestures(false);
    shadow.setCanDispatchGestures(true);
    assertThat(service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
    null)).isTrue();
}
Also used : GestureDescription(android.accessibilityservice.GestureDescription) GestureResultCallback(android.accessibilityservice.AccessibilityService.GestureResultCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

GestureDescription (android.accessibilityservice.GestureDescription)8 GestureResultCallback (android.accessibilityservice.AccessibilityService.GestureResultCallback)5 Test (org.junit.Test)5 Config (org.robolectric.annotation.Config)5 Path (android.graphics.Path)2 AccessibilityService (android.accessibilityservice.AccessibilityService)1 Handler (android.os.Handler)1 RequiresApi (android.support.annotation.RequiresApi)1 DisplayMetrics (android.util.DisplayMetrics)1 RequiresApi (androidx.annotation.RequiresApi)1 VolatileBox (com.stardust.concurrent.VolatileBox)1