Skip to content

Commit 0ee7361

Browse files
committed
Release 0.0.5S
Added new functionality to send any possible keyEvent returned functionality to toggle orientation using "third mouse button" temporally disabled some un-useful or buggy features. code refactored.
1 parent 5c053e6 commit 0ee7361

26 files changed

+556
-422
lines changed

pom.xml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>AndroidScreencast</groupId>
55
<artifactId>AndroidScreencast</artifactId>
6-
<version>0.0.4S</version>
6+
<version>0.0.5S</version>
77
<name>Android Screencast</name>
88
<properties>
99
<spring-version>4.2.0.RELEASE</spring-version>
@@ -50,7 +50,7 @@
5050
<plugins>
5151
<plugin>
5252
<artifactId>maven-compiler-plugin</artifactId>
53-
<version>3.1</version>
53+
<version>3.3</version>
5454
<configuration>
5555
<source>1.7</source>
5656
<target>1.7</target>
@@ -92,4 +92,23 @@
9292
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
9393
</pluginRepository>
9494
</pluginRepositories>
95+
<url>http://xsavikx.github.io/AndroidScreencast</url>
96+
<ciManagement>
97+
<url>https://drone.io/github.com/xSAVIKx/AndroidScreencast</url>
98+
<system>DroneIO</system>
99+
</ciManagement>
100+
<issueManagement>
101+
<system>GitHub</system>
102+
<url>https://github.com/xSAVIKx/AndroidScreencast/issues</url>
103+
</issueManagement>
104+
<description>AndroidScreencast - View and control your android device on PC.
105+
106+
This project gives you opportunity to use your phone even with broken screen.
107+
108+
Features:
109+
No client needed
110+
Support for Tap and Swipe gestures
111+
Write messages using PC keyboard
112+
Support for landscape mode
113+
Browse your phone files on PC</description>
95114
</project>

src/com/github/xsavikx/android/screencast/api/AndroidDeviceImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public List<FileInfo> list(String path) {
6969
if (data.length < 4)
7070
continue;
7171
/*
72-
* for(int j=0; j<data.length; j++) { System.out.println(j+" = "
73-
* +data[j]); }
72+
* for(int j=0; j<data.length; j++) { System.out.println(j+" = " +data[j]); }
7473
*/
7574
String attribs = data[0];
7675
boolean directory = attribs.startsWith("d");
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
package com.github.xsavikx.android.screencast.api.command;
22

3+
import com.github.xsavikx.android.screencast.api.injector.InputKeyEvent;
4+
35
public class KeyCommand extends InputCommand {
46
private static final String COMMAND_FORMAT = INPUT + WHITESPACE + "keyevent %d";
5-
private int keyCode;
7+
private int code;
68

79
public KeyCommand(int keyCode) {
8-
this.keyCode = keyCode;
10+
this.code = keyCode;
11+
}
12+
13+
public KeyCommand(InputKeyEvent inputKeyEvent) {
14+
code = inputKeyEvent.getCode();
915
}
1016

1117
@Override
1218
public String getFormatedCommand() {
13-
return String.format(COMMAND_FORMAT, keyCode);
19+
return String.format(COMMAND_FORMAT, code);
1420
}
1521

1622
}

src/com/github/xsavikx/android/screencast/api/command/factory/AdbInputCommandFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.github.xsavikx.android.screencast.api.command.KeyCommand;
77
import com.github.xsavikx.android.screencast.api.command.SwipeCommand;
88
import com.github.xsavikx.android.screencast.api.command.TapCommand;
9+
import com.github.xsavikx.android.screencast.api.injector.InputKeyEvent;
910

1011
@Service
1112
public final class AdbInputCommandFactory {
@@ -22,6 +23,14 @@ public static KeyCommand getKeyCommand(int keyCode) {
2223
return returnKeyCommand;
2324
}
2425

26+
public static KeyCommand getKeyCommand(InputKeyEvent inputKeyEvent) {
27+
LOGGER.debug("getKeyCommand(InputKeyEvent inputKeyEvent=" + inputKeyEvent + ") - start");
28+
29+
KeyCommand returnKeyCommand = new KeyCommand(inputKeyEvent);
30+
LOGGER.debug("getKeyCommand(InputKeyEvent inputKeyEvent=" + inputKeyEvent + ") - end");
31+
return returnKeyCommand;
32+
}
33+
2534
public static SwipeCommand getSwipeCommand(int x1, int y1, int x2, int y2) {
2635
LOGGER.debug("getSwipeCommand(int x1=" + x1 + ", int y1=" + y1 + ", int x2=" + x2 + ", int y2=" + y2 + ") - start");
2736

src/com/github/xsavikx/android/screencast/api/injector/InputKeyEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,5 @@ private static Set<InputKeyEvent> fillEventsWithKeyCodes(){
351351
return eventsWithKeyCodes;
352352
}
353353

354+
354355
}

src/com/github/xsavikx/android/screencast/api/injector/KeyCodeConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.xsavikx.android.screencast.api.injector;
22

3-
import org.apache.log4j.Logger;
4-
53
import java.awt.event.KeyEvent;
64

5+
import org.apache.log4j.Logger;
6+
77
public class KeyCodeConverter {
88
private static final Logger LOGGER = Logger.getLogger(KeyCodeConverter.class);
99

src/com/github/xsavikx/android/screencast/api/injector/ScreenCaptureThread.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.github.xsavikx.android.screencast.api.injector;
22

3-
import org.apache.log4j.Logger;
4-
53
import java.awt.Dimension;
64
import java.awt.image.BufferedImage;
75
import java.io.File;
@@ -10,6 +8,7 @@
108

119
import javax.swing.SwingUtilities;
1210

11+
import org.apache.log4j.Logger;
1312
import org.springframework.beans.factory.annotation.Autowired;
1413
import org.springframework.stereotype.Component;
1514

@@ -43,7 +42,6 @@ public ScreenCaptureThread() {
4342
}
4443

4544
public void display(RawImage rawImage) {
46-
4745
int width2 = landscape ? rawImage.height : rawImage.width;
4846
int height2 = landscape ? rawImage.width : rawImage.height;
4947
if (image == null) {
@@ -78,13 +76,9 @@ public void display(RawImage rawImage) {
7876

7977
if (listener != null) {
8078
SwingUtilities.invokeLater(new Runnable() {
81-
8279
@Override
8380
public void run() {
84-
8581
listener.handleNewImage(size, image, landscape);
86-
// jp.handleNewImage(size, image, landscape);
87-
8882
}
8983
});
9084
}
@@ -103,8 +97,6 @@ private boolean fetchImage() throws IOException {
10397
}
10498
return true;
10599
}
106-
107-
// System.out.println("Getting initial screenshot through ADB");
108100
RawImage rawImage = null;
109101
synchronized (device) {
110102
try {
@@ -114,13 +106,12 @@ private boolean fetchImage() throws IOException {
114106
}
115107
}
116108
if (rawImage != null) {
117-
// System.out.println("screenshot through ADB ok");
118109
display(rawImage);
119110
} else {
120111
LOGGER.info("failed getting screenshot through ADB ok");
121112
}
122113
try {
123-
Thread.sleep(10);
114+
Thread.sleep(5);
124115
} catch (InterruptedException e) {
125116
LOGGER.error("fetchImage()", e);
126117
return false;

src/com/github/xsavikx/android/screencast/api/recording/DataAtomOutputStream.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public class DataAtomOutputStream extends FilterOutputStream {
1212

1313
protected static final long MAC_TIMESTAMP_EPOCH = new GregorianCalendar(1904, Calendar.JANUARY, 1).getTimeInMillis();
1414
/**
15-
* The number of bytes written to the data output stream so far. If this
16-
* counter overflows, it will be wrapped to Integer.MAX_VALUE.
15+
* The number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE.
1716
*/
1817
protected long written;
1918

@@ -22,8 +21,7 @@ public DataAtomOutputStream(OutputStream out) {
2221
}
2322

2423
/**
25-
* Increases the written counter by the specified value until it reaches
26-
* Long.MAX_VALUE.
24+
* Increases the written counter by the specified value until it reaches Long.MAX_VALUE.
2725
*/
2826
protected void incCount(int value) {
2927
long temp = written + value;
@@ -34,8 +32,7 @@ protected void incCount(int value) {
3432
}
3533

3634
/**
37-
* Returns the current value of the counter <code>written</code>, the number
38-
* of bytes written to this data output stream so far. If the counter
35+
* Returns the current value of the counter <code>written</code>, the number of bytes written to this data output stream so far. If the counter
3936
* overflows, it will be wrapped to Integer.MAX_VALUE.
4037
*
4138
* @return the value of the <code>written</code> field.
@@ -46,10 +43,8 @@ public final long size() {
4643
}
4744

4845
/**
49-
* Writes <code>len</code> bytes from the specified byte array starting at
50-
* offset <code>off</code> to the underlying output stream. If no exception is
51-
* thrown, the counter <code>written</code> is incremented by <code>len</code>
52-
* .
46+
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to the underlying output stream. If no exception
47+
* is thrown, the counter <code>written</code> is incremented by <code>len</code> .
5348
*
5449
* @param b
5550
* the data.
@@ -68,9 +63,8 @@ public synchronized void write(byte b[], int off, int len) throws IOException {
6863
}
6964

7065
/**
71-
* Writes the specified byte (the low eight bits of the argument
72-
* <code>b</code>) to the underlying output stream. If no exception is thrown,
73-
* the counter <code>written</code> is incremented by <code>1</code> .
66+
* Writes the specified byte (the low eight bits of the argument <code>b</code>) to the underlying output stream. If no exception is thrown, the
67+
* counter <code>written</code> is incremented by <code>1</code> .
7468
* <p>
7569
* Implements the <code>write</code> method of <code>OutputStream</code>.
7670
*
@@ -116,8 +110,7 @@ public void writeBCD4(int v) throws IOException {
116110
}
117111

118112
/**
119-
* Writes out a <code>byte</code> to the underlying output stream as a 1-byte
120-
* value. If no exception is thrown, the counter <code>written</code> is
113+
* Writes out a <code>byte</code> to the underlying output stream as a 1-byte value. If no exception is thrown, the counter <code>written</code> is
121114
* incremented by <code>1</code>.
122115
*
123116
* @param v
@@ -198,8 +191,7 @@ public void writeFixed8D8(float f) throws IOException {
198191
}
199192

200193
/**
201-
* Writes an <code>int</code> to the underlying output stream as four bytes,
202-
* high byte first. If no exception is thrown, the counter
194+
* Writes an <code>int</code> to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter
203195
* <code>written</code> is incremented by <code>4</code>.
204196
*
205197
* @param v

src/com/github/xsavikx/android/screencast/api/recording/FilterImageOutputStream.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ public FilterImageOutputStream(ImageOutputStream iOut) {
1414
}
1515

1616
/**
17-
* Closes this output stream and releases any system resources associated with
18-
* the stream.
17+
* Closes this output stream and releases any system resources associated with the stream.
1918
* <p>
20-
* The <code>close</code> method of <code>FilterOutputStream</code> calls its
21-
* <code>flush</code> method, and then calls the <code>close</code> method of
22-
* its underlying output stream.
19+
* The <code>close</code> method of <code>FilterOutputStream</code> calls its <code>flush</code> method, and then calls the <code>close</code>
20+
* method of its underlying output stream.
2321
*
2422
* @exception IOException
2523
* if an I/O error occurs.
@@ -33,11 +31,9 @@ public void close() throws IOException {
3331
}
3432

3533
/**
36-
* Flushes this output stream and forces any buffered output bytes to be
37-
* written out to the stream.
34+
* Flushes this output stream and forces any buffered output bytes to be written out to the stream.
3835
* <p>
39-
* The <code>flush</code> method of <code>FilterOutputStream</code> calls the
40-
* <code>flush</code> method of its underlying output stream.
36+
* The <code>flush</code> method of <code>FilterOutputStream</code> calls the <code>flush</code> method of its underlying output stream.
4137
*
4238
* @exception IOException
4339
* if an I/O error occurs.
@@ -50,17 +46,13 @@ public void flush() {
5046
}
5147

5248
/**
53-
* Writes <code>len</code> bytes from the specified <code>byte</code> array
54-
* starting at offset <code>off</code> to this output stream.
49+
* Writes <code>len</code> bytes from the specified <code>byte</code> array starting at offset <code>off</code> to this output stream.
5550
* <p>
56-
* The <code>write</code> method of <code>FilterOutputStream</code> calls the
57-
* <code>write</code> method of one argument on each <code>byte</code> to
51+
* The <code>write</code> method of <code>FilterOutputStream</code> calls the <code>write</code> method of one argument on each <code>byte</code> to
5852
* output.
5953
* <p>
60-
* Note that this method does not call the <code>write</code> method of its
61-
* underlying input stream with the same arguments. Subclasses of
62-
* <code>FilterOutputStream</code> should provide a more efficient
63-
* implementation of this method.
54+
* Note that this method does not call the <code>write</code> method of its underlying input stream with the same arguments. Subclasses of
55+
* <code>FilterOutputStream</code> should provide a more efficient implementation of this method.
6456
*
6557
* @param b
6658
* the data.
@@ -80,8 +72,7 @@ public void write(byte b[], int off, int len) throws IOException {
8072
/**
8173
* Writes the specified <code>byte</code> to this output stream.
8274
* <p>
83-
* The <code>write</code> method of <code>FilterOutputStream</code> calls the
84-
* <code>write</code> method of its underlying output stream, that is, it
75+
* The <code>write</code> method of <code>FilterOutputStream</code> calls the <code>write</code> method of its underlying output stream, that is, it
8576
* performs <tt>out.write(b)</tt>.
8677
* <p>
8778
* Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>.

0 commit comments

Comments
 (0)