diff --git a/.gitignore b/.gitignore index bcddc15..d4fad2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ -.DS* \ No newline at end of file +.DS* +/wiigee-lib/nbproject/private/ +/wiigee-plugin-android/nbproject/private/ +/wiigee-lib/build/ +/wiigee-lib/dist/ +/wiigee-plugin-android/build/ +/wiigee-plugin-android/dist/ \ No newline at end of file diff --git a/wiigee-gui-android/.gitignore b/wiigee-gui-android/.gitignore new file mode 100644 index 0000000..9c4de58 --- /dev/null +++ b/wiigee-gui-android/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/wiigee-gui-android/GesturePoc.iml b/wiigee-gui-android/GesturePoc.iml new file mode 100644 index 0000000..046f82e --- /dev/null +++ b/wiigee-gui-android/GesturePoc.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wiigee-gui-android/README b/wiigee-gui-android/README new file mode 100644 index 0000000..668c90b --- /dev/null +++ b/wiigee-gui-android/README @@ -0,0 +1,3 @@ +This Android application uses the Gradle build system. This is not yet integrated with the Ant-based build system that the rest of wiigee uses. + +The Android GUI relies on having the most recent wiigee-lib and wiigee-plugin-android JARs in the app/libs directory. If you'd like to enhance these libraries and see them updated in the Android UI project, copy the JARs to app/libs after running "ant jar" in wiigee-lib and wiigee-plugin-android. diff --git a/wiigee-gui-android/README~ b/wiigee-gui-android/README~ new file mode 100644 index 0000000..e69de29 diff --git a/wiigee-gui-android/app/.gitignore b/wiigee-gui-android/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/wiigee-gui-android/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/wiigee-gui-android/app/app.iml b/wiigee-gui-android/app/app.iml new file mode 100644 index 0000000..8f460e0 --- /dev/null +++ b/wiigee-gui-android/app/app.iml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wiigee-gui-android/app/build.gradle b/wiigee-gui-android/app/build.gradle new file mode 100644 index 0000000..44a712d --- /dev/null +++ b/wiigee-gui-android/app/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "org.wiigee.android" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:23.0.0' +} diff --git a/wiigee-gui-android/app/libs/wiigee-lib.jar b/wiigee-gui-android/app/libs/wiigee-lib.jar new file mode 100644 index 0000000..b7454cb Binary files /dev/null and b/wiigee-gui-android/app/libs/wiigee-lib.jar differ diff --git a/wiigee-gui-android/app/libs/wiigee-plugin-android.jar b/wiigee-gui-android/app/libs/wiigee-plugin-android.jar new file mode 100644 index 0000000..cc41f01 Binary files /dev/null and b/wiigee-gui-android/app/libs/wiigee-plugin-android.jar differ diff --git a/wiigee-gui-android/app/proguard-rules.pro b/wiigee-gui-android/app/proguard-rules.pro new file mode 100644 index 0000000..ff7412e --- /dev/null +++ b/wiigee-gui-android/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/katie/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/wiigee-gui-android/app/src/main/AndroidManifest.xml b/wiigee-gui-android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..70f02bd --- /dev/null +++ b/wiigee-gui-android/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/wiigee-gui-android/app/src/main/java/org/wiigee/android/MainActivity.java b/wiigee-gui-android/app/src/main/java/org/wiigee/android/MainActivity.java new file mode 100644 index 0000000..f42e8bd --- /dev/null +++ b/wiigee-gui-android/app/src/main/java/org/wiigee/android/MainActivity.java @@ -0,0 +1,85 @@ +package org.wiigee.android; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import org.wiigee.control.AndroidWiigee; +import org.wiigee.event.GestureEvent; +import org.wiigee.event.GestureListener; +import org.wiigee.filter.HighPassFilter; + +import java.io.File; +import java.io.FilenameFilter; + +public class MainActivity extends AppCompatActivity { + + private AndroidWiigee androidWiigee; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + androidWiigee = new AndroidWiigee(this); + androidWiigee.setTrainButton((Button) findViewById(R.id.buttonTrain)); + androidWiigee.setRecognitionButton((Button) findViewById(R.id.buttonRecognize)); + androidWiigee.setCloseGestureButton((Button) findViewById(R.id.buttonClose)); + + androidWiigee.addGestureListener(new GestureListener() { + @Override + public void gestureReceived(GestureEvent gestureEvent) { + Toast.makeText(MainActivity.this, "Gesture Detected! " + gestureEvent.getId() + + ", prob: " + gestureEvent.getProbability(), Toast.LENGTH_SHORT).show(); + } + }); + + findViewById(R.id.buttonSave).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int modelNumber = Integer.parseInt(( + (EditText) findViewById(R.id.editTextModelNumber)).getText().toString()); + String modelName = ((EditText) findViewById(R.id.editTextFileName)) + .getText().toString(); + String modelFilePath = getExternalFilesDir(null).getAbsolutePath() + "/" + modelName; + androidWiigee.getDevice().saveGesture(modelNumber, modelFilePath); + Toast.makeText(MainActivity.this, "Gesture saved to " + modelName, + Toast.LENGTH_SHORT).show(); + } + }); + + findViewById(R.id.buttonLoad).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); + final String[] files = getExternalFilesDir(null).list(new FilenameFilter() { + @Override + public boolean accept(File dir, String filename) { + return filename.endsWith(".txt"); + } + }); + builder.setTitle("Pick a Model").setItems(files, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + String modelFilePath = files[which]; + // Wiigee appends .txt to model file paths, so strip it out here. + modelFilePath = getExternalFilesDir(null) + "/" + modelFilePath.substring(0, modelFilePath.length() - 4); + androidWiigee.getDevice().loadGesture(modelFilePath); + Toast.makeText(MainActivity.this, + "Gesture loaded: " + modelFilePath, + Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + } + }); + builder.create().show(); + } + }); + } + + ; +} diff --git a/wiigee-gui-android/app/src/main/res/layout/activity_main.xml b/wiigee-gui-android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..3b7ad36 --- /dev/null +++ b/wiigee-gui-android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,81 @@ + + +