From 73831a0837e7180237f9b63848110bbc588567dd Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 31 Jan 2018 19:42:08 +0100 Subject: [PATCH] Use the Point class from the framework Replace our custom Point class by android.graphics.Point. --- .../java/com/genymobile/scrcpy/Device.java | 5 ++- .../genymobile/scrcpy/EventController.java | 5 ++- .../java/com/genymobile/scrcpy/Point.java | 43 ------------------- .../java/com/genymobile/scrcpy/Position.java | 2 + 4 files changed, 8 insertions(+), 47 deletions(-) delete mode 100644 server/src/main/java/com/genymobile/scrcpy/Point.java diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index 9e6b568f..4348127e 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -1,5 +1,6 @@ package com.genymobile.scrcpy; +import android.graphics.Point; import android.os.Build; import android.os.RemoteException; import android.view.IRotationWatcher; @@ -86,8 +87,8 @@ public final class Device { int contentWidth = videoSize.getWidth() - xPadding; int contentHeight = videoSize.getHeight() - yPadding; Point point = position.getPoint(); - int x = point.getX() - xPadding / 2; - int y = point.getY() - yPadding / 2; + int x = point.x - xPadding / 2; + int y = point.y - yPadding / 2; if (x < 0 || x >= contentWidth || y < 0 || y >= contentHeight) { // out of screen return null; diff --git a/server/src/main/java/com/genymobile/scrcpy/EventController.java b/server/src/main/java/com/genymobile/scrcpy/EventController.java index fd594dc4..efa8b559 100644 --- a/server/src/main/java/com/genymobile/scrcpy/EventController.java +++ b/server/src/main/java/com/genymobile/scrcpy/EventController.java @@ -1,5 +1,6 @@ package com.genymobile.scrcpy; +import android.graphics.Point; import android.os.SystemClock; import android.view.InputDevice; import android.view.InputEvent; @@ -47,8 +48,8 @@ public class EventController { private void setPointerCoords(Point point) { MotionEvent.PointerCoords coords = pointerCoords[0]; - coords.x = point.getX(); - coords.y = point.getY(); + coords.x = point.x; + coords.y = point.y; } private void setScroll(int hScroll, int vScroll) { diff --git a/server/src/main/java/com/genymobile/scrcpy/Point.java b/server/src/main/java/com/genymobile/scrcpy/Point.java deleted file mode 100644 index f02b22a0..00000000 --- a/server/src/main/java/com/genymobile/scrcpy/Point.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.genymobile.scrcpy; - -import java.util.Objects; - -public class Point { - private int x; - private int y; - - public Point(int x, int y) { - this.x = x; - this.y = y; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Point point = (Point) o; - return x == point.x && - y == point.y; - } - - @Override - public int hashCode() { - return Objects.hash(x, y); - } - - @Override - public String toString() { - return "Point{" + - "x=" + x + - ", y=" + y + - '}'; - } -} diff --git a/server/src/main/java/com/genymobile/scrcpy/Position.java b/server/src/main/java/com/genymobile/scrcpy/Position.java index 3e7f814a..2e67b4f0 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Position.java +++ b/server/src/main/java/com/genymobile/scrcpy/Position.java @@ -1,5 +1,7 @@ package com.genymobile.scrcpy; +import android.graphics.Point; + import java.util.Objects; public class Position {