Skip to content

Commit

Permalink
Release 0.0.5S
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xSAVIKx committed Aug 21, 2015
1 parent 5c053e6 commit 0ee7361
Show file tree
Hide file tree
Showing 26 changed files with 556 additions and 422 deletions.
23 changes: 21 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>AndroidScreencast</groupId>
<artifactId>AndroidScreencast</artifactId>
<version>0.0.4S</version>
<version>0.0.5S</version>
<name>Android Screencast</name>
<properties>
<spring-version>4.2.0.RELEASE</spring-version>
Expand Down Expand Up @@ -50,7 +50,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
Expand Down Expand Up @@ -92,4 +92,23 @@
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
<url>http://xsavikx.github.io/AndroidScreencast</url>
<ciManagement>
<url>https://drone.io/github.com/xSAVIKx/AndroidScreencast</url>
<system>DroneIO</system>
</ciManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/xSAVIKx/AndroidScreencast/issues</url>
</issueManagement>
<description>AndroidScreencast - View and control your android device on PC.

This project gives you opportunity to use your phone even with broken screen.

Features:
No client needed
Support for Tap and Swipe gestures
Write messages using PC keyboard
Support for landscape mode
Browse your phone files on PC</description>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public List<FileInfo> list(String path) {
if (data.length < 4)
continue;
/*
* for(int j=0; j<data.length; j++) { System.out.println(j+" = "
* +data[j]); }
* for(int j=0; j<data.length; j++) { System.out.println(j+" = " +data[j]); }
*/
String attribs = data[0];
boolean directory = attribs.startsWith("d");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package com.github.xsavikx.android.screencast.api.command;

import com.github.xsavikx.android.screencast.api.injector.InputKeyEvent;

public class KeyCommand extends InputCommand {
private static final String COMMAND_FORMAT = INPUT + WHITESPACE + "keyevent %d";
private int keyCode;
private int code;

public KeyCommand(int keyCode) {
this.keyCode = keyCode;
this.code = keyCode;
}

public KeyCommand(InputKeyEvent inputKeyEvent) {
code = inputKeyEvent.getCode();
}

@Override
public String getFormatedCommand() {
return String.format(COMMAND_FORMAT, keyCode);
return String.format(COMMAND_FORMAT, code);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.xsavikx.android.screencast.api.command.KeyCommand;
import com.github.xsavikx.android.screencast.api.command.SwipeCommand;
import com.github.xsavikx.android.screencast.api.command.TapCommand;
import com.github.xsavikx.android.screencast.api.injector.InputKeyEvent;

@Service
public final class AdbInputCommandFactory {
Expand All @@ -22,6 +23,14 @@ public static KeyCommand getKeyCommand(int keyCode) {
return returnKeyCommand;
}

public static KeyCommand getKeyCommand(InputKeyEvent inputKeyEvent) {
LOGGER.debug("getKeyCommand(InputKeyEvent inputKeyEvent=" + inputKeyEvent + ") - start");

KeyCommand returnKeyCommand = new KeyCommand(inputKeyEvent);
LOGGER.debug("getKeyCommand(InputKeyEvent inputKeyEvent=" + inputKeyEvent + ") - end");
return returnKeyCommand;
}

public static SwipeCommand getSwipeCommand(int x1, int y1, int x2, int y2) {
LOGGER.debug("getSwipeCommand(int x1=" + x1 + ", int y1=" + y1 + ", int x2=" + x2 + ", int y2=" + y2 + ") - start");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,5 @@ private static Set<InputKeyEvent> fillEventsWithKeyCodes(){
return eventsWithKeyCodes;
}


}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.xsavikx.android.screencast.api.injector;

import org.apache.log4j.Logger;

import java.awt.event.KeyEvent;

import org.apache.log4j.Logger;

public class KeyCodeConverter {
private static final Logger LOGGER = Logger.getLogger(KeyCodeConverter.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.xsavikx.android.screencast.api.injector;

import org.apache.log4j.Logger;

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
Expand All @@ -10,6 +8,7 @@

import javax.swing.SwingUtilities;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -43,7 +42,6 @@ public ScreenCaptureThread() {
}

public void display(RawImage rawImage) {

int width2 = landscape ? rawImage.height : rawImage.width;
int height2 = landscape ? rawImage.width : rawImage.height;
if (image == null) {
Expand Down Expand Up @@ -78,13 +76,9 @@ public void display(RawImage rawImage) {

if (listener != null) {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {

listener.handleNewImage(size, image, landscape);
// jp.handleNewImage(size, image, landscape);

}
});
}
Expand All @@ -103,8 +97,6 @@ private boolean fetchImage() throws IOException {
}
return true;
}

// System.out.println("Getting initial screenshot through ADB");
RawImage rawImage = null;
synchronized (device) {
try {
Expand All @@ -114,13 +106,12 @@ private boolean fetchImage() throws IOException {
}
}
if (rawImage != null) {
// System.out.println("screenshot through ADB ok");
display(rawImage);
} else {
LOGGER.info("failed getting screenshot through ADB ok");
}
try {
Thread.sleep(10);
Thread.sleep(5);
} catch (InterruptedException e) {
LOGGER.error("fetchImage()", e);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class DataAtomOutputStream extends FilterOutputStream {

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

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

/**
* Increases the written counter by the specified value until it reaches
* Long.MAX_VALUE.
* Increases the written counter by the specified value until it reaches Long.MAX_VALUE.
*/
protected void incCount(int value) {
long temp = written + value;
Expand All @@ -34,8 +32,7 @@ protected void incCount(int value) {
}

/**
* 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
* 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
* overflows, it will be wrapped to Integer.MAX_VALUE.
*
* @return the value of the <code>written</code> field.
Expand All @@ -46,10 +43,8 @@ public final long size() {
}

/**
* Writes <code>len</code> bytes from the specified byte array starting at
* offset <code>off</code> to the underlying output stream. If no exception is
* thrown, the counter <code>written</code> is incremented by <code>len</code>
* .
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to the underlying output stream. If no exception
* is thrown, the counter <code>written</code> is incremented by <code>len</code> .
*
* @param b
* the data.
Expand All @@ -68,9 +63,8 @@ public synchronized void write(byte b[], int off, int len) throws IOException {
}

/**
* 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 counter <code>written</code> is incremented by <code>1</code> .
* 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
* counter <code>written</code> is incremented by <code>1</code> .
* <p>
* Implements the <code>write</code> method of <code>OutputStream</code>.
*
Expand Down Expand Up @@ -116,8 +110,7 @@ public void writeBCD4(int v) throws IOException {
}

/**
* 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
* 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
* incremented by <code>1</code>.
*
* @param v
Expand Down Expand Up @@ -198,8 +191,7 @@ public void writeFixed8D8(float f) throws IOException {
}

/**
* Writes an <code>int</code> to the underlying output stream as four bytes,
* high byte first. If no exception is thrown, the counter
* Writes an <code>int</code> to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>4</code>.
*
* @param v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ public FilterImageOutputStream(ImageOutputStream iOut) {
}

/**
* Closes this output stream and releases any system resources associated with
* the stream.
* Closes this output stream and releases any system resources associated with the stream.
* <p>
* The <code>close</code> method of <code>FilterOutputStream</code> calls its
* <code>flush</code> method, and then calls the <code>close</code> method of
* its underlying output stream.
* The <code>close</code> method of <code>FilterOutputStream</code> calls its <code>flush</code> method, and then calls the <code>close</code>
* method of its underlying output stream.
*
* @exception IOException
* if an I/O error occurs.
Expand All @@ -33,11 +31,9 @@ public void close() throws IOException {
}

/**
* Flushes this output stream and forces any buffered output bytes to be
* written out to the stream.
* Flushes this output stream and forces any buffered output bytes to be written out to the stream.
* <p>
* The <code>flush</code> method of <code>FilterOutputStream</code> calls the
* <code>flush</code> method of its underlying output stream.
* The <code>flush</code> method of <code>FilterOutputStream</code> calls the <code>flush</code> method of its underlying output stream.
*
* @exception IOException
* if an I/O error occurs.
Expand All @@ -50,17 +46,13 @@ public void flush() {
}

/**
* Writes <code>len</code> bytes from the specified <code>byte</code> array
* starting at offset <code>off</code> to this output stream.
* Writes <code>len</code> bytes from the specified <code>byte</code> array starting at offset <code>off</code> to this output stream.
* <p>
* The <code>write</code> method of <code>FilterOutputStream</code> calls the
* <code>write</code> method of one argument on each <code>byte</code> to
* The <code>write</code> method of <code>FilterOutputStream</code> calls the <code>write</code> method of one argument on each <code>byte</code> to
* output.
* <p>
* Note that this method does not call the <code>write</code> method of its
* underlying input stream with the same arguments. Subclasses of
* <code>FilterOutputStream</code> should provide a more efficient
* implementation of this method.
* Note that this method does not call the <code>write</code> method of its underlying input stream with the same arguments. Subclasses of
* <code>FilterOutputStream</code> should provide a more efficient implementation of this method.
*
* @param b
* the data.
Expand All @@ -80,8 +72,7 @@ public void write(byte b[], int off, int len) throws IOException {
/**
* Writes the specified <code>byte</code> to this output stream.
* <p>
* The <code>write</code> method of <code>FilterOutputStream</code> calls the
* <code>write</code> method of its underlying output stream, that is, it
* The <code>write</code> method of <code>FilterOutputStream</code> calls the <code>write</code> method of its underlying output stream, that is, it
* performs <tt>out.write(b)</tt>.
* <p>
* Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>.
Expand Down
Loading

0 comments on commit 0ee7361

Please sign in to comment.