feat: SystemInputUtils不再处理swipe动作
This commit is contained in:
@@ -79,6 +79,7 @@ public class InputCommandHandler {
|
||||
float relY = (float) command.getY();
|
||||
int x = (int) (relX * screenWidth);
|
||||
int y = (int) (relY * screenHeight);
|
||||
Log.d(TAG, "Motion event: " + action + " at: " + x + ", " + y);
|
||||
inputExecutor.injectMotionEvent(action, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,18 +54,18 @@ public class SystemInputUtils implements InputExecutor {
|
||||
|
||||
@Override
|
||||
public void injectSwipe(int x1, int y1, int x2, int y2, long duration) {
|
||||
long downTime = SystemClock.uptimeMillis();
|
||||
injectMotionEvent(downTime, downTime, MotionEvent.ACTION_DOWN, x1, y1);
|
||||
|
||||
int steps = 10;
|
||||
for (int i = 1; i <= steps; i++) {
|
||||
SystemClock.sleep(duration / steps);
|
||||
int x = x1 + (x2 - x1) * i / steps;
|
||||
int y = y1 + (y2 - y1) * i / steps;
|
||||
injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y);
|
||||
}
|
||||
|
||||
injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x2, y2);
|
||||
// long downTime = SystemClock.uptimeMillis();
|
||||
// injectMotionEvent(downTime, downTime, MotionEvent.ACTION_DOWN, x1, y1);
|
||||
//
|
||||
// int steps = 10;
|
||||
// for (int i = 1; i <= steps; i++) {
|
||||
// SystemClock.sleep(duration / steps);
|
||||
// int x = x1 + (x2 - x1) * i / steps;
|
||||
// int y = y1 + (y2 - y1) * i / steps;
|
||||
// injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y);
|
||||
// }
|
||||
//
|
||||
// injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x2, y2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -127,6 +127,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onSwipe(float relX1, float relY1, float relX2, float relY2, long duration) {
|
||||
// 已通过 onMotionEvent 处理
|
||||
sendSwipeCommand(relX1, relY1, relX2, relY2, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -589,7 +590,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
Object ms = stats.getMembers().get("messagesSent");
|
||||
if (ms instanceof Number) dcMessagesSent = ((Number) ms).longValue();
|
||||
Object mr = stats.getMembers().get("messagesReceived");
|
||||
if (mr instanceof Number) dcMessagesReceived = ((Number) mr).longValue();
|
||||
if (mr instanceof Number)
|
||||
dcMessagesReceived = ((Number) mr).longValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -650,8 +652,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
// 依据选定候选对的本地/远端候选类型,返回 P2P / TURN 中继描述。
|
||||
private String resolveConnectionType(org.webrtc.RTCStatsReport report,
|
||||
String localCandidateId,
|
||||
String remoteCandidateId) {
|
||||
String localCandidateId,
|
||||
String remoteCandidateId) {
|
||||
String local = candidateTypeOf(report, localCandidateId);
|
||||
String remote = candidateTypeOf(report, remoteCandidateId);
|
||||
boolean isRelay = "relay".equals(local) || "relay".equals(remote);
|
||||
|
||||
@@ -78,6 +78,7 @@ public class RemoteTouchView extends SurfaceView {
|
||||
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
|
||||
if (listener != null) {
|
||||
listener.onKeyEvent(keyCode, android.view.KeyEvent.ACTION_DOWN);
|
||||
Log.d(TAG, "KeyDown: " + keyCode);
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
@@ -87,6 +88,7 @@ public class RemoteTouchView extends SurfaceView {
|
||||
public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
|
||||
if (listener != null) {
|
||||
listener.onKeyEvent(keyCode, android.view.KeyEvent.ACTION_UP);
|
||||
Log.d(TAG, "KeyUp: " + keyCode);
|
||||
return true;
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
@@ -111,6 +113,7 @@ public class RemoteTouchView extends SurfaceView {
|
||||
|
||||
// 发送原始 MotionEvent 实现实时跟手
|
||||
listener.onMotionEvent(action, relX, relY);
|
||||
Log.d(TAG, "MotionEvent: " + action + ", " + relX + ", " + relY);
|
||||
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
@@ -134,8 +137,10 @@ public class RemoteTouchView extends SurfaceView {
|
||||
// 保留旧的回调以防万一,但 MainActivity 现在应该忽略它们
|
||||
if (duration < 200 && dx < 0.02 && dy < 0.02) {
|
||||
listener.onTouch(lastTouchX, lastTouchY);
|
||||
Log.d(TAG, "Touch at: " + lastTouchX + ", " + lastTouchY);
|
||||
} else {
|
||||
listener.onSwipe(lastTouchX, lastTouchY, relX, relY, duration);
|
||||
Log.d(TAG, "Swipe from: " + lastTouchX + ", " + lastTouchY + " to: " + relX + ", " + relY + " duration: " + duration);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user