diff --git a/app-android/.gitignore b/app-android/.gitignore new file mode 100644 index 0000000..4078853 --- /dev/null +++ b/app-android/.gitignore @@ -0,0 +1,90 @@ +# Created by https://www.gitignore.io + +### Android ### +# Built application files +*.apk +*.ap_ + +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### Gradle ### +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + + +### external libs ### +.svn diff --git a/app-android/IDEAS b/app-android/IDEAS deleted file mode 100644 index ddc1c3c..0000000 --- a/app-android/IDEAS +++ /dev/null @@ -1,5 +0,0 @@ - -Issues URL: https://github.com/rfc2822/GfxTablet/issues/ - -Possible improvements: - * allow more than one network host in settings [issue #13] diff --git a/app-android/app/build.gradle b/app-android/app/build.gradle new file mode 100644 index 0000000..4e0897f --- /dev/null +++ b/app-android/app/build.gradle @@ -0,0 +1,23 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "at.bitfire.gfxtablet" + minSdkVersion 14 + targetSdkVersion 14 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + compile "com.android.support:appcompat-v7:21.0.0" +} diff --git a/app-android/AndroidManifest.xml b/app-android/app/src/main/AndroidManifest.xml similarity index 85% rename from app-android/AndroidManifest.xml rename to app-android/app/src/main/AndroidManifest.xml index d502b46..b7ad3a2 100644 --- a/app-android/AndroidManifest.xml +++ b/app-android/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="4" + android:versionName="1.3" > - + android:label="@string/menu_settings" + android:parentActivityName=".CanvasActivity"> diff --git a/app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasActivity.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasActivity.java new file mode 100644 index 0000000..6045925 --- /dev/null +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasActivity.java @@ -0,0 +1,78 @@ +package at.bitfire.gfxtablet; + +import android.content.Intent; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v7.app.ActionBarActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +public class CanvasActivity extends ActionBarActivity { + NetworkClient netClient; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + netClient = new NetworkClient(PreferenceManager.getDefaultSharedPreferences(this)); + } + + @Override + protected void onResume() { + super.onResume(); + + new ConfigureNetworkingTask().execute(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + netClient.getQueue().add(new NetEvent(NetEvent.Type.TYPE_DISCONNECT)); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.activity_canvas, menu); + return true; + } + + public void showAbout(MenuItem item) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(("https://rfc2822.github.io/GfxTablet/")))); + } + + public void showSettings(MenuItem item) { + startActivityForResult(new Intent(this, SettingsActivity.class), 0); + } + + public void switchFullScreen(MenuItem item) { + final View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar + View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar + View.SYSTEM_UI_FLAG_IMMERSIVE + ); + } + + + private class ConfigureNetworkingTask extends AsyncTask { + @Override + protected Boolean doInBackground(Void... params) { + return netClient.configureNetworking(); + } + + protected void onPostExecute(Boolean success) { + if (success) { + setContentView(new CanvasView(CanvasActivity.this, netClient)); + new Thread(netClient).start(); + } else + setContentView(R.layout.activity_no_host); + } + } + +} diff --git a/app-android/src/at/bitfire/gfxtablet/CanvasView.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasView.java similarity index 52% rename from app-android/src/at/bitfire/gfxtablet/CanvasView.java rename to app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasView.java index 52cb10d..e4d8823 100644 --- a/app-android/src/at/bitfire/gfxtablet/CanvasView.java +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/CanvasView.java @@ -2,63 +2,47 @@ package at.bitfire.gfxtablet; import android.annotation.SuppressLint; import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.os.AsyncTask; +import android.graphics.Color; import android.preference.PreferenceManager; +import android.util.Log; import android.view.MotionEvent; import android.view.View; -import android.widget.Toast; + import at.bitfire.gfxtablet.NetEvent.Type; @SuppressLint("ViewConstructor") -public class CanvasView extends View implements OnSharedPreferenceChangeListener { - NetworkClient netClient; - SharedPreferences settings; +public class CanvasView extends View { + private static final String TAG = "GfxTablet.CanvasView"; + + final SharedPreferences settings; + final NetworkClient netClient; boolean acceptStylusOnly; int maxX, maxY; - - public CanvasView(Context context, NetworkClient netClient) { - super(context); - - // disable until networking has been configured - setEnabled(false); - setBackgroundColor(0xFFD0D0D0); - settings = PreferenceManager.getDefaultSharedPreferences(context); - settings.registerOnSharedPreferenceChangeListener(this); - reconfigureAcceptedInputDevices(); - - this.netClient = netClient; - new ConfigureNetworkingTask().execute(); + public CanvasView(Context context, NetworkClient networkClient) { + super(context); + + netClient = networkClient; + + // process preferences + settings = PreferenceManager.getDefaultSharedPreferences(context); + acceptStylusOnly = settings.getBoolean(SettingsActivity.KEY_PREF_STYLUS_ONLY, false); + setBackgroundColor(settings.getBoolean(SettingsActivity.KEY_DARK_CANVAS, false) ? Color.BLACK : Color.WHITE); } @Override - public void onSharedPreferenceChanged(SharedPreferences pref, String key) { - if (key.equals(SettingsActivity.KEY_PREF_HOST)) - new ConfigureNetworkingTask().execute(); - else if (key.equals(SettingsActivity.KEY_PREF_STYLUS_ONLY)) - reconfigureAcceptedInputDevices(); - } - - void reconfigureAcceptedInputDevices() { - acceptStylusOnly = settings.getBoolean(SettingsActivity.KEY_PREF_STYLUS_ONLY, false); - } - - @Override - protected void onSizeChanged (int w, int h, int oldw, int oldh) { + protected void onSizeChanged(int w, int h, int oldw, int oldh) { maxX = w; maxY = h; } - @Override public boolean onGenericMotionEvent(MotionEvent event) { if (isEnabled()) { for (int ptr = 0; ptr < event.getPointerCount(); ptr++) if (!acceptStylusOnly || (event.getToolType(ptr) == MotionEvent.TOOL_TYPE_STYLUS)) { - //Log.i("XorgTablet", String.format("Generic motion event logged: %f|%f, pressure %f", event.getX(ptr), event.getY(ptr), event.getPressure(ptr))); + Log.v(TAG, String.format("Generic motion event logged: %f|%f, pressure %f", event.getX(ptr), event.getY(ptr), event.getPressure(ptr))); if (event.getActionMasked() == MotionEvent.ACTION_HOVER_MOVE) netClient.getQueue().add(new NetEvent(Type.TYPE_MOTION, normalizeX(event.getX(ptr)), @@ -79,7 +63,7 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener short nx = normalizeX(event.getX(ptr)), ny = normalizeY(event.getY(ptr)), npressure = normalizePressure(event.getPressure(ptr)); - //Log.i("XorgTablet", String.format("Touch event logged: %f|%f, pressure %f", event.getX(ptr), event.getY(ptr), event.getPressure(ptr))); + Log.v(TAG, String.format("Touch event logged: %f|%f, pressure %f", event.getX(ptr), event.getY(ptr), event.getPressure(ptr))); switch (event.getActionMasked()) { case MotionEvent.ACTION_MOVE: netClient.getQueue().add(new NetEvent(Type.TYPE_MOTION, nx, ny, npressure)); @@ -111,22 +95,4 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener short normalizePressure(float x) { return (short)(Math.min(Math.max(0, x), 2.0) * Short.MAX_VALUE/2.0); } - - - private class ConfigureNetworkingTask extends AsyncTask { - @Override - protected Boolean doInBackground(Void... params) { - return netClient.configureNetworking(); - } - - protected void onPostExecute(Boolean success) { - if (success) - setEnabled(true); - else { - setEnabled(false); - Toast.makeText(getContext(), "Unknown host name, please configure", Toast.LENGTH_LONG).show(); - getContext().startActivity(new Intent(getContext(), SettingsActivity.class)); - } - } - } } diff --git a/app-android/src/at/bitfire/gfxtablet/NetEvent.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/NetEvent.java similarity index 91% rename from app-android/src/at/bitfire/gfxtablet/NetEvent.java rename to app-android/app/src/main/java/at/bitfire/gfxtablet/NetEvent.java index 971067f..e8efa59 100644 --- a/app-android/src/at/bitfire/gfxtablet/NetEvent.java +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/NetEvent.java @@ -1,5 +1,7 @@ package at.bitfire.gfxtablet; +import android.util.Log; + import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -11,18 +13,14 @@ public class NetEvent { // not specified in protocol, only needed to shut down network thread TYPE_DISCONNECT - }; + } static final String signature = "GfxTablet"; static final short protocol_version = 1; - Type type; + final Type type; short x, y, pressure; byte button, button_down; - - public short getX() { return x; } - public short getY() { return y; } - public short getPressure() { return pressure; } - + public NetEvent(Type type) { this.type = type; @@ -71,6 +69,7 @@ public class NetEvent { dos.writeByte(button_down); } } catch(IOException e) { + Log.wtf(signature, "Couldn't generate network packet"); } return baos.toByteArray(); diff --git a/app-android/src/at/bitfire/gfxtablet/NetworkClient.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/NetworkClient.java similarity index 98% rename from app-android/src/at/bitfire/gfxtablet/NetworkClient.java rename to app-android/app/src/main/java/at/bitfire/gfxtablet/NetworkClient.java index 69d5a4c..ad7e04d 100644 --- a/app-android/src/at/bitfire/gfxtablet/NetworkClient.java +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/NetworkClient.java @@ -1,20 +1,21 @@ package at.bitfire.gfxtablet; +import android.content.SharedPreferences; +import android.util.Log; + import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.concurrent.LinkedBlockingQueue; -import android.content.SharedPreferences; -import android.util.Log; import at.bitfire.gfxtablet.NetEvent.Type; public class NetworkClient implements Runnable { static int GFXTABLET_PORT = 40118; - LinkedBlockingQueue motionQueue = new LinkedBlockingQueue(); + LinkedBlockingQueue motionQueue = new LinkedBlockingQueue<>(); LinkedBlockingQueue getQueue() { return motionQueue; } InetAddress destAddress; diff --git a/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsActivity.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsActivity.java new file mode 100644 index 0000000..adffec3 --- /dev/null +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsActivity.java @@ -0,0 +1,21 @@ +package at.bitfire.gfxtablet; + +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; + +public class SettingsActivity extends ActionBarActivity { + public static final String + KEY_PREF_HOST = "host_preference", + KEY_PREF_STYLUS_ONLY = "stylus_only_preference", + KEY_DARK_CANVAS = "dark_canvas_preference"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + setContentView(R.layout.activity_settings); + } + +} diff --git a/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsFragment.java b/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsFragment.java new file mode 100644 index 0000000..aa306cb --- /dev/null +++ b/app-android/app/src/main/java/at/bitfire/gfxtablet/SettingsFragment.java @@ -0,0 +1,12 @@ +package at.bitfire.gfxtablet; + +import android.os.Bundle; +import android.preference.PreferenceFragment; + +public class SettingsFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + } +} diff --git a/app-android/res/drawable-hdpi/ic_launcher.png b/app-android/app/src/main/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from app-android/res/drawable-hdpi/ic_launcher.png rename to app-android/app/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/app-android/res/drawable-mdpi/ic_launcher.png b/app-android/app/src/main/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from app-android/res/drawable-mdpi/ic_launcher.png rename to app-android/app/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/app-android/res/drawable-xhdpi/ic_launcher.png b/app-android/app/src/main/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from app-android/res/drawable-xhdpi/ic_launcher.png rename to app-android/app/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/app-android/app/src/main/res/layout/activity_no_host.xml b/app-android/app/src/main/res/layout/activity_no_host.xml new file mode 100644 index 0000000..88f43b7 --- /dev/null +++ b/app-android/app/src/main/res/layout/activity_no_host.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app-android/app/src/main/res/layout/activity_settings.xml b/app-android/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..d4023ec --- /dev/null +++ b/app-android/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app-android/app/src/main/res/menu/activity_canvas.xml b/app-android/app/src/main/res/menu/activity_canvas.xml new file mode 100644 index 0000000..a92ace6 --- /dev/null +++ b/app-android/app/src/main/res/menu/activity_canvas.xml @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/app-android/app/src/main/res/values/strings.xml b/app-android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..80b6065 --- /dev/null +++ b/app-android/app/src/main/res/values/strings.xml @@ -0,0 +1,20 @@ + + + + GfxTablet + Settings + About / Help + + No valid recipient host defined. Please configure in \"Settings / Recipient host\". + + Recipient host + Host name or IP address where touch input is sent to + Sense stylus only + Only stylus input will be processed + Finger and stylus input will be processed + + Use dark canvas + Black canvas will be used + White canvas will be used + + diff --git a/app-android/app/src/main/res/values/styles.xml b/app-android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..7d0903b --- /dev/null +++ b/app-android/app/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app-android/app/src/main/res/xml/preferences.xml b/app-android/app/src/main/res/xml/preferences.xml new file mode 100644 index 0000000..8fe0534 --- /dev/null +++ b/app-android/app/src/main/res/xml/preferences.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/app-android/build.gradle b/app-android/build.gradle new file mode 100644 index 0000000..5271038 --- /dev/null +++ b/app-android/build.gradle @@ -0,0 +1,15 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.1.0' + } +} +allprojects { + repositories { + jcenter() + } +} + diff --git a/app-android/build.xml b/app-android/build.xml deleted file mode 100644 index beaa4f3..0000000 --- a/app-android/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app-android/gradle/wrapper/gradle-wrapper.jar b/app-android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/app-android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/app-android/gradle/wrapper/gradle-wrapper.properties b/app-android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c71e76 --- /dev/null +++ b/app-android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/app-android/gradlew b/app-android/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/app-android/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/app-android/gradlew.bat b/app-android/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/app-android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/app-android/import-summary.txt b/app-android/import-summary.txt new file mode 100644 index 0000000..5f413b5 --- /dev/null +++ b/app-android/import-summary.txt @@ -0,0 +1,36 @@ +ECLIPSE ANDROID PROJECT IMPORT SUMMARY +====================================== + +Ignored Files: +-------------- +The following files were *not* copied into the new Gradle project; you +should evaluate whether these are still needed in your project and if +so manually move them: + +* IDEAS +* build.xml +* proguard-project.txt + +Moved Files: +------------ +Android Gradle projects use a different directory structure than ADT +Eclipse projects. Here's how the projects were restructured: + +* AndroidManifest.xml => app/src/main/AndroidManifest.xml +* res/ => app/src/main/res/ +* src/ => app/src/main/java/ + +Next Steps: +----------- +You can now build the project. The Gradle project needs network +connectivity to download dependencies. + +Bugs: +----- +If for some reason your project does not build, and you determine that +it is due to a bug or limitation of the Eclipse to Gradle importer, +please file a bug at http://b.android.com with category +Component-Tools. + +(This import summary is for your information only, and can be deleted +after import once you are satisfied with the results.) diff --git a/app-android/proguard-project.txt b/app-android/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/app-android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# 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/app-android/project.properties b/app-android/project.properties deleted file mode 100644 index a3ee5ab..0000000 --- a/app-android/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-17 diff --git a/app-android/res/layout/activity_canvas.xml b/app-android/res/layout/activity_canvas.xml deleted file mode 100644 index 6fd299c..0000000 --- a/app-android/res/layout/activity_canvas.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app-android/res/menu/activity_canvas.xml b/app-android/res/menu/activity_canvas.xml deleted file mode 100644 index 6aa78a8..0000000 --- a/app-android/res/menu/activity_canvas.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app-android/res/values-v11/styles.xml b/app-android/res/values-v11/styles.xml deleted file mode 100644 index 541752f..0000000 --- a/app-android/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app-android/res/values-v14/styles.xml b/app-android/res/values-v14/styles.xml deleted file mode 100644 index f20e015..0000000 --- a/app-android/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app-android/res/values/strings.xml b/app-android/res/values/strings.xml deleted file mode 100644 index 8e01210..0000000 --- a/app-android/res/values/strings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - GfxTablet - Settings - Network host - Sense stylus only - Fullscreen - About / Help - Title bar will only be hidden when hardware menu button is present - Ignores touch events from fingers - - diff --git a/app-android/res/values/strings_activity_settings.xml b/app-android/res/values/strings_activity_settings.xml deleted file mode 100644 index dfc25ca..0000000 --- a/app-android/res/values/strings_activity_settings.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Settings - - - - - - - - - - - \ No newline at end of file diff --git a/app-android/res/values/styles.xml b/app-android/res/values/styles.xml deleted file mode 100644 index 4a10ca4..0000000 --- a/app-android/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app-android/res/xml/drawing_preferences.xml b/app-android/res/xml/drawing_preferences.xml deleted file mode 100644 index aeac1bc..0000000 --- a/app-android/res/xml/drawing_preferences.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/app-android/res/xml/network_preferences.xml b/app-android/res/xml/network_preferences.xml deleted file mode 100644 index 306ae20..0000000 --- a/app-android/res/xml/network_preferences.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/app-android/res/xml/preference_headers.xml b/app-android/res/xml/preference_headers.xml deleted file mode 100644 index 3b9039a..0000000 --- a/app-android/res/xml/preference_headers.xml +++ /dev/null @@ -1,9 +0,0 @@ - - -
-
- - diff --git a/app-android/settings.gradle b/app-android/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/app-android/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/app-android/src/at/bitfire/gfxtablet/CanvasActivity.java b/app-android/src/at/bitfire/gfxtablet/CanvasActivity.java deleted file mode 100644 index ea128e2..0000000 --- a/app-android/src/at/bitfire/gfxtablet/CanvasActivity.java +++ /dev/null @@ -1,78 +0,0 @@ -package at.bitfire.gfxtablet; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.view.Menu; -import android.view.MenuItem; -import android.view.ViewConfiguration; -import android.view.Window; -import android.view.WindowManager; -import android.widget.LinearLayout; -import android.widget.Toast; - -public class CanvasActivity extends Activity { - CanvasView canvas; - SharedPreferences settings; - NetworkClient netClient; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - PreferenceManager.setDefaultValues(this, R.xml.network_preferences, false); - PreferenceManager.setDefaultValues(this, R.xml.drawing_preferences, false); - - settings = PreferenceManager.getDefaultSharedPreferences(this); - if (settings.getBoolean(SettingsActivity.KEY_PREF_FULLSCREEN, false)) { - if (ViewConfiguration.get(this).hasPermanentMenuKey()) - requestWindowFeature(Window.FEATURE_NO_TITLE); - else - Toast.makeText(this, "Limited full-screen due to missing hardware menu button", Toast.LENGTH_LONG).show(); - - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - - setContentView(R.layout.activity_canvas); - LinearLayout layout = (LinearLayout)findViewById(R.id.canvas_layout); - - new Thread(netClient = new NetworkClient(PreferenceManager.getDefaultSharedPreferences(this))).start(); - - canvas = new CanvasView(this, netClient); - layout.addView(canvas); - } - - @Override - protected void onDestroy() { - netClient.getQueue().add(new NetEvent(NetEvent.Type.TYPE_DISCONNECT)); - super.onDestroy(); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.activity_canvas, menu); - return true; - } - - public void showAbout(MenuItem item) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(("http://rfc2822.github.io/GfxTablet/")))); - } - - public void showSettings(MenuItem item) { - startActivityForResult(new Intent(this, SettingsActivity.class), 0); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (resultCode == SettingsActivity.RESULT_RESTART) { - finish(); - Intent i = new Intent(this, CanvasActivity.class); - i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(i); - } - } -} diff --git a/app-android/src/at/bitfire/gfxtablet/SettingsActivity.java b/app-android/src/at/bitfire/gfxtablet/SettingsActivity.java deleted file mode 100644 index aa8d76a..0000000 --- a/app-android/src/at/bitfire/gfxtablet/SettingsActivity.java +++ /dev/null @@ -1,67 +0,0 @@ -package at.bitfire.gfxtablet; - -import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.os.Bundle; -import android.preference.PreferenceActivity; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; -import android.view.MenuItem; - -import java.util.List; - -import at.bitfire.gfxtablet.R; - -public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { - public static final int RESULT_RESTART = RESULT_FIRST_USER; - - public static final String - KEY_PREF_HOST = "host_preference", - KEY_PREF_STYLUS_ONLY = "stylus_only_preference", - KEY_PREF_FULLSCREEN = "fullscreen_preference"; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - getActionBar().setDisplayHomeAsUpEnabled(true); - - PreferenceManager.getDefaultSharedPreferences(this) - .registerOnSharedPreferenceChangeListener(this); - } - - @Override - public void onBuildHeaders(List
target) { - loadHeadersFromResource(R.xml.preference_headers, target); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) - finish(); - return false; - } - - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if (key.equals(SettingsActivity.KEY_PREF_FULLSCREEN)) - setResult(RESULT_RESTART); - } - - - public static class NetworkPrefsFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.network_preferences); - } - } - - public static class DrawingPrefsFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.drawing_preferences); - } - } -}