Skip to content

Commit

Permalink
Merge branch 'release/0.1.0-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Baba committed Feb 29, 2016
2 parents c61413e + 15fbac7 commit fea2e3b
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target
tmp
.idea
*.iml
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ You can build the project source code though you can download the built binary f

Prior to building the project, you need to install the following software:

1. JDK 6 (Any JDK will be available)
1. JDK 6+ (Any JDK will be available)
1. [Apache Maven](http://maven.apache.org/) (Choose the latest one if possible)

Then run the following command under the root of the project:
Expand Down Expand Up @@ -130,6 +130,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

## Change History

0.1.0-alpha : February 29, 2016

* Processing 3 support and Processing 2 is no longer supported

0.0.2-alpha : June 20, 2013

* Fixes an [issue](https://github.com/inventit/processing-android-serial/issues/1) where [Arduino Due](http://arduino.cc/en/Main/arduinoBoardDue) cannot be detected by [usb-serial-for-android](https://code.google.com/p/usb-serial-for-android/) library. Now all Arduino devices are accepted (but not sure they all work properly. [Give us your feedback](https://github.com/inventit/processing-android-serial/issues))
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ paragraph = This library works on Android 3.1 or later.
# is used to compare different versions of the same library, and
# check if an update is available. You should think of it as a
# counter, counting the total number of releases you've had.
version = 1
version = 3

# The version as the user will see it. If blank, the version attribute will be used here
prettyVersion = 0.0.1-alpha
prettyVersion = 0.1.0-alpha
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>processing</groupId>
<artifactId>android-core</artifactId>
<version>android-mode-0246</version>
<url>https://github.com/processing/processing-android</url>
<name>Processing Android Core</name>
</project>
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourinventit.processing.android.serial</groupId>
<artifactId>processing-android-serial</artifactId>
<version>0.0.1-alpha</version>
<version>0.1.0-alpha</version>
<name>AndroidSerial</name>
<organization>
<name>Inventit Inc.</name>
Expand Down Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>processing</groupId>
<artifactId>android-core</artifactId>
<version>2.0</version>
<version>android-mode-0246</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -80,9 +80,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -151,6 +151,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ abstract class AbstractAndroidSerialCommunicator extends Serial implements
*/
public AbstractAndroidSerialCommunicator(PApplet parent) {
this.parent = parent;
final Context context = (Context) parent;
this.applicatoinContext = context.getApplicationContext();
this.applicatoinContext = parent.getActivity().getApplicationContext();
this.serialEventMethod = resolveSerialEventMethod(parent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

import processing.core.PApplet;
import processing.data.JSONObject;
import android.content.Context;
import android.os.Build;

/**
*
*
* @author dbaba@yourinventit.com
*
*
*/
public final class SerialCommunicatorFacory {

Expand Down Expand Up @@ -39,7 +38,7 @@ private SerialCommunicatorFacory() {

/**
* Configures the serial library.
*
*
* @param json
*/
public void configure(String json) {
Expand All @@ -48,7 +47,7 @@ public void configure(String json) {

/**
* Configures the serial library.
*
*
* @param jsonObject
*/
public void configure(JSONObject jsonObject) {
Expand All @@ -57,16 +56,12 @@ public void configure(JSONObject jsonObject) {

/**
* Returns a {@link SerialCommunicator} instance specified by the type.
*
*
* @param parent
* @param type
* @return
*/
public SerialCommunicator create(PApplet parent, String type) {
if (!(parent instanceof Context)) {
throw new IllegalArgumentException(
"This library works only on Android.");
}
if ("usb".equalsIgnoreCase(type)) {
return new UsbSerialCommunicator(parent);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private synchronized State getState() {
* NOTE(mikey): Uses inefficient read/write-with-timeout. TODO(mikey): Read
* asynchronously with {@link UsbRequest#queue(ByteBuffer, int)}
*/
@Override
public void run() {
synchronized (this) {
if (getState() != State.STOPPED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ protected void doStop() {
*
* @see com.yourinventit.processing.android.serial.SerialInputOutputManager.Listener#onNewData(byte[])
*/
@Override
public void onNewData(byte[] data) {
sendBuffer(data);
}
Expand All @@ -204,7 +203,6 @@ public void onNewData(byte[] data) {
*
* @see com.yourinventit.processing.android.serial.SerialInputOutputManager.Listener#onRunError(java.lang.Exception)
*/
@Override
public void onRunError(Exception e) {
LOGGER.warn("Exception detected. Restart SerialInputOutputManager.", e);
doStop();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import android.app.Activity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import processing.core.PApplet;
import android.content.Context;
import android.hardware.usb.UsbDevice;
Expand All @@ -21,27 +25,30 @@
import com.hoho.android.usbserial.driver.UsbId;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialProber;
import com.yourinventit.dmc.api.moat.android.MoatRobolectricTestRunner;

/**
*
* @author dbaba@yourinventit.com
*
*/
@RunWith(MoatRobolectricTestRunner.class)
@Config(manifest = "src/test/resources/robolectric/AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class UsbSerialCommunicatorTest {

private UsbSerialCommunicator communicator;

private final PApplet pApplet = mock(PApplet.class);
private final Activity activity = mock(Activity.class);
private final Context context = mock(Context.class);
private final UsbDevice usbDevice = mock(UsbDevice.class);
private final UsbManager usbManager = mock(UsbManager.class);
private final UsbDeviceConnection usbDeviceConnection = mock(UsbDeviceConnection.class);

@Before
public void setUp() throws Exception {
when(pApplet.getApplicationContext()).thenReturn(pApplet);
when(pApplet.getSystemService(Context.USB_SERVICE)).thenReturn(
when(pApplet.getActivity()).thenReturn(activity);
when(activity.getApplicationContext()).thenReturn(context);
when(context.getSystemService(Context.USB_SERVICE)).thenReturn(
usbManager);
communicator = new UsbSerialCommunicator(pApplet);
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/resources/robolectric/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
android:versionCode="1"
android:versionName="1.0">
<uses-feature android:name="android.hardware.usb.host" />
<uses-sdk android:minSdkVersion="10" />
<application android:label=""
android:icon="@drawable/icon">
<uses-sdk android:minSdkVersion="18" />
<application android:label="myapp">
<activity android:name="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down

0 comments on commit fea2e3b

Please sign in to comment.