1
0
Fork 0
mirror of https://github.com/rfc2822/GfxTablet synced 2025-10-03 17:49:17 +02:00

Major update

* use AndroidStudio/gradle instead of Eclipse/ant
* upgrade to SDK v22 and build tools v22
* manage network connection from CanvasActivity instead of CanvasView
* show a "No host configured" message instead of opening Settings automatically when no host is configured
* use Android 4.4 immersive full-screen (fixes #59)
* use Material design (using support library)
* add setting for dark canvas (closes #54, #73, closes #76)
This commit is contained in:
Ricki Hirner 2015-06-21 18:34:18 +02:00
parent ff865c297b
commit 29e84b8fd0
41 changed files with 675 additions and 462 deletions

90
app-android/.gitignore vendored Normal file
View file

@ -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

View file

@ -1,5 +0,0 @@
Issues URL: https://github.com/rfc2822/GfxTablet/issues/
Possible improvements:
* allow more than one network host in settings [issue #13]

View file

@ -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"
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.gfxtablet"
android:versionCode="3"
android:versionName="1.2" >
android:versionCode="4"
android:versionName="1.3" >
<uses-sdk
android:minSdkVersion="14"
@ -15,6 +15,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
<activity
android:name="at.bitfire.gfxtablet.CanvasActivity"
@ -22,13 +23,13 @@
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="at.bitfire.gfxtablet.SettingsActivity"
android:label="@string/title_activity_settings" >
android:label="@string/menu_settings"
android:parentActivityName=".CanvasActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="at.bitfire.gfxtablet.CanvasActivity" />

View file

@ -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<Void, Void, Boolean> {
@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);
}
}
}

View file

@ -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);
public CanvasView(Context context, NetworkClient networkClient) {
super(context);
// disable until networking has been configured
setEnabled(false);
setBackgroundColor(0xFFD0D0D0);
netClient = networkClient;
settings = PreferenceManager.getDefaultSharedPreferences(context);
settings.registerOnSharedPreferenceChangeListener(this);
reconfigureAcceptedInputDevices();
this.netClient = netClient;
new ConfigureNetworkingTask().execute();
// 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<Void, Void, Boolean> {
@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));
}
}
}
}

View file

@ -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();

View file

@ -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<NetEvent> motionQueue = new LinkedBlockingQueue<NetEvent>();
LinkedBlockingQueue<NetEvent> motionQueue = new LinkedBlockingQueue<>();
LinkedBlockingQueue<NetEvent> getQueue() { return motionQueue; }
InetAddress destAddress;

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/no_host_defined" />
</LinearLayout>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="at.bitfire.gfxtablet.SettingsFragment"
android:id="@+id/fragment"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>

View file

@ -0,0 +1,19 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:onClick="switchFullScreen"
android:title="Fullscreen"
app:showAsAction="always" />
<item
android:onClick="showSettings"
android:title="@string/menu_settings"
app:showAsAction="ifRoom" />
<item
android:onClick="showAbout"
android:title="@string/menu_about"
app:showAsAction="never" />
</menu>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GfxTablet</string>
<string name="menu_settings">Settings</string>
<string name="menu_about">About / Help</string>
<string name="no_host_defined">No valid recipient host defined. Please configure in \"Settings / Recipient host\".</string>
<string name="preferences_host">Recipient host</string>
<string name="preferences_host_summary">Host name or IP address where touch input is sent to</string>
<string name="preferences_stylus_only">Sense stylus only</string>
<string name="preferences_stylus_only_on">Only stylus input will be processed</string>
<string name="preferences_stylus_only_off">Finger and stylus input will be processed</string>
<string name="preferences_dark_canvas">Use dark canvas</string>
<string name="preferences_dark_canvas_on">Black canvas will be used</string>
<string name="preferences_dark_canvas_off">White canvas will be used</string>
</resources>

View file

@ -0,0 +1,10 @@
<resources>
<!-- Application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#4825d0</item>
<item name="colorPrimaryDark">#755a8e</item>
<item name="colorAccent">#f32eac</item>
</style>
</resources>

View file

@ -0,0 +1,28 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Network preferences">
<EditTextPreference
android:defaultValue="0.0.0.0"
android:key="host_preference"
android:singleLine="true"
android:inputType="textUri"
android:title="@string/preferences_host"
android:summary="@string/preferences_host_summary" />
</PreferenceCategory>
<PreferenceCategory android:title="Drawing preferences">
<CheckBoxPreference
android:defaultValue="false"
android:key="stylus_only_preference"
android:title="@string/preferences_stylus_only"
android:summaryOn="@string/preferences_stylus_only_on"
android:summaryOff="@string/preferences_stylus_only_off" />
<CheckBoxPreference
android:defaultValue="false"
android:key="dark_canvas_preference"
android:title="@string/preferences_dark_canvas"
android:summaryOn="@string/preferences_dark_canvas_on"
android:summaryOff="@string/preferences_dark_canvas_off" />
</PreferenceCategory>
</PreferenceScreen>

15
app-android/build.gradle Normal file
View file

@ -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()
}
}

View file

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="GfxTablet" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

Binary file not shown.

View file

@ -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

164
app-android/gradlew vendored Executable file
View file

@ -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 "$@"

90
app-android/gradlew.bat vendored Normal file
View file

@ -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

View file

@ -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.)

View file

@ -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 *;
#}

View file

@ -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

View file

@ -1,17 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CanvasActivity" >
<LinearLayout
android:id="@+id/canvas_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>

View file

@ -1,13 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/menu_settings" android:onClick="showSettings"/>
<item
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_about" android:onClick="showAbout"/>
</menu>

View file

@ -1,11 +0,0 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View file

@ -1,12 +0,0 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GfxTablet</string>
<string name="menu_settings">Settings</string>
<string name="preferences_host_title">Network host</string>
<string name="stylus_preference">Sense stylus only</string>
<string name="fullscreen_preference">Fullscreen</string>
<string name="menu_about">About / Help</string>
<string name="fullscreen_preference_summary">Title bar will only be hidden when hardware menu button is present</string>
<string name="stylus_preference_summary">Ignores touch events from fingers</string>
</resources>

View file

@ -1,14 +0,0 @@
<resources>
<string name="title_activity_settings">Settings</string>
<!-- Strings related to Settings -->
<!-- Example General settings -->
<!-- Example settings for Data & Sync -->
<!-- Example settings for Notifications -->
</resources>

View file

@ -1,20 +0,0 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference android:title="@string/stylus_preference" android:key="stylus_only_preference" android:defaultValue="false" android:summary="@string/stylus_preference_summary"/>
<CheckBoxPreference android:title="@string/fullscreen_preference" android:key="fullscreen_preference" android:defaultValue="false" android:summary="@string/fullscreen_preference_summary"/>
</PreferenceScreen>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<EditTextPreference android:title="@string/preferences_host_title" android:key="host_preference" android:defaultValue="please-replace.invalid" android:singleLine="true"/>
</PreferenceScreen>

View file

@ -1,9 +0,0 @@
<preference-headers
xmlns:android="http://schemas.android.com/apk/res/android">
<header android:fragment="at.bitfire.gfxtablet.SettingsActivity$NetworkPrefsFragment"
android:title="Networking" />
<header android:fragment="at.bitfire.gfxtablet.SettingsActivity$DrawingPrefsFragment"
android:title="Drawing" />
</preference-headers>

View file

@ -0,0 +1 @@
include ':app'

View file

@ -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);
}
}
}

View file

@ -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<Header> 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);
}
}
}