diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..9dc59d6 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index e9969a1..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,7 +14,6 @@ - diff --git a/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java b/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java index 2e738db..3ed7e47 100644 --- a/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java +++ b/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java @@ -19,7 +19,6 @@ import android.view.InputEvent; import android.view.KeyEvent; import android.view.MotionEvent; -import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityWindowInfo; import android.view.inputmethod.InputMethodManager; @@ -28,9 +27,6 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -42,7 +38,6 @@ import java.util.Set; import java.util.concurrent.ArrayBlockingQueue; -import io.github.virresh.matvt.helper.Helper; import io.github.virresh.matvt.services.MouseEventService; import io.github.virresh.matvt.view.MouseCursorView; import io.github.virresh.matvt.view.OverlayView; @@ -56,6 +51,10 @@ public class MouseEmulationEngine { CountDownTimer disappearTimer; + CountDownTimer swipeGestureCoolDown; + + private boolean isQueueEmpty = true; + private boolean isInScrollMode = false; // service which started this engine @@ -185,7 +184,7 @@ public void run() { mPointerControl.reappear(); // mService.dispatchGesture(createSwipe(originPoint, direction, 20 + momentumStack), null, null); createSwipe(originPoint, direction, 20 + momentumStack); - momentumStack += 1; + //momentumStack += 1; timerHandler.postDelayed(this, 30); } }; @@ -202,7 +201,7 @@ public void run() { mPointerControl.reappear(); // mService.dispatchGesture(createSwipe(originPoint, direction, 20 + momentumStack), null, null); createSwipe(originPoint, direction, 20 + momentumStack); - momentumStack += 1; + //momentumStack += 1; timerHandler.postDelayed(this, 30); } }; @@ -246,20 +245,38 @@ private static GestureDescription createClick (PointF clickPoint, long duration) return clickBuilder.build(); } - private GestureDescription createSwipe (PointF originPoint, int direction, int momentum) { - final int DURATION = scrollSpeed + 20; - Path clickPath = new Path(); - PointF lineDirection = new PointF(originPoint.x + (momentum + 75) * PointerControl.dirX[direction], originPoint.y + (momentum + 75) * PointerControl.dirY[direction]); + private void createSwipe (PointF originPoint, int direction, int momentum) { + + if(!isQueueEmpty) return; + isQueueEmpty = false; + + final int DURATION = 300 - scrollSpeed*10; + Path clickPath = new Path(); + PointF lineDirection = new PointF(originPoint.x + (75 + momentum) * PointerControl.dirX[direction], originPoint.y + (75+momentum) * PointerControl.dirY[direction]); mService.shellSwipe((int) originPoint.x, (int) originPoint.y, (int) lineDirection.x, (int) lineDirection.y, DURATION); - clickPath.moveTo(originPoint.x, originPoint.y); - clickPath.lineTo(lineDirection.x, lineDirection.y); - GestureDescription.StrokeDescription clickStroke = - new GestureDescription.StrokeDescription(clickPath, 0, DURATION); - GestureDescription.Builder clickBuilder = new GestureDescription.Builder(); - clickBuilder.addStroke(clickStroke); - return clickBuilder.build(); + swipeGestureCoolDown = new CountDownTimer(DURATION+200,100) { + @Override + public void onTick(long millisUntilFinished) {} + @Override + public void onFinish() { + isQueueEmpty = true; + } + }; + + swipeGestureCoolDown.start(); + + momentumStack += 1; + + /* + try { + Thread.sleep(DURATION + 200); + } catch (InterruptedException e) { + Log.e(LOG_TAG, "Thread interrupted: ",e); + } + */ + } public boolean perform (KeyEvent keyEvent) { diff --git a/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java b/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java index fdeee7e..c59d5d8 100644 --- a/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java +++ b/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java @@ -69,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) { // don't like to advertise in the product, but need to mention here // need to increase visibility of the open source version - gui_about.setText("MATVT v" + BuildConfig.VERSION_NAME + "\nThis is an open source project. It's available for free and will always be. If you find issues / would like to help in improving this project, please contribute at \nhttps://github.com/virresh/matvt"); + gui_about.setText("MATVT v" + BuildConfig.VERSION_NAME + "\n\nThis is an open source project. It's available for free and will always be. If you find issues / would like to help in improving this project, please contribute at \nhttps://github.com/virresh/matvt"); // render icon style dropdown IconStyleSpinnerAdapter iconStyleSpinnerAdapter = new IconStyleSpinnerAdapter(this, R.layout.spinner_icon_text_gui, R.id.textView, IconStyleSpinnerAdapter.getResourceList()); diff --git a/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java b/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java index 44faa07..5e8176e 100644 --- a/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java +++ b/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java @@ -189,7 +189,7 @@ public void shellSwipe(Integer x1, Integer y1, Integer x2, Integer y2, Integer d // Log.i(TAG_NAME, "Succeeded ? ===> " + response.isSuccessful()); // } // }); - sendShellInput("swipe " + x1.toString() + " " + y1.toString() + " " + x2.toString() + " " + y2.toString()); + sendShellInput("swipe " + x1.toString() + " " + y1.toString() + " " + x2.toString() + " " + y2.toString() + " " + duration.toString()); } public void shellTap(Integer x, Integer y) {