I'm working in a remote assistence software to android smartphones and i wish draw the password (similar to
Team View for mobile) using the mouse and
onmousemove event (or other event) of a
Image component (that is where the remote screen is showed).
I'm using this Delphi code below but happens a detour on trajetory and draw a wrong password.
The image in attachment and video (following link) show how this is in pratice.
DEMOSTRATION IN VIDEO
Someone have some idea how solve this trouble?
Delphi-Quellcode:
TForm2 = class(TForm)
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
PO,LP: TPoint;
draw: boolean;
public
{ Public declarations }
end;
procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
PO.X:= X;
PO.Y:= Y;
LP.X:= X;
LP.Y:= Y;
draw:= true;
// Canvas.Pen.Mode:= pmNotXor;
end;
procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if draw then
begin
if (LP.X <> PO.X) or (LP.Y <> PO.Y) then
begin
{ Canvas.MoveTo(PO.X,PO.Y);
Canvas.LineTo(LP.X,LP.Y); }
end;
LP.X:= X;
LP.Y:= Y;
{ Canvas.MoveTo(PO.X,PO.Y);
Canvas.LineTo(LP.X,LP.Y); }
end;
end;
procedure TForm2.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
// Sending throught Socket: PO.X, PO.Y, LP.X, LP.Y
if draw then draw:= false;
end;
SocketBackgroungService class:
Code:
if (xline.contains("swipescreen")) {
String coordenates = xline.replace("swipescreen", "");
String[] tokens = coordenates.split(Pattern.quote("<|>"));
float x1 = parseFloat(tokens[0]);
float y1 = parseFloat(tokens[1]);
float x2 = parseFloat(tokens[2]);
float y2 = parseFloat(tokens[3]);
MyAccessibility.instance.Swipte((int) x1, (int) y1, (int) x2, (int) y2, 50);
}
MyAccessibility class (
Swipte() routine):
Code:
public void Swipte(int x1,int y1,int x2,int y2,int time){
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
System.out.println(" ======= Swipte =======");
GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
Path path = new Path();
path.moveTo(x1,y1);
path.lineTo(x2,y2);
gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, time));
dispatchGesture(gestureBuilder.build(), new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
System.out.println("SWIPTE Gesture Completed :D");
super.onCompleted(gestureDescription);
}
}, null);
}
}