Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
paddybyers committed Oct 17, 2011
0 parents commit abbc285
Show file tree
Hide file tree
Showing 31 changed files with 860 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions .project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>anode-simple</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions app/.classpath
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="libnode_src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
41 changes: 41 additions & 0 deletions app/.project
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment></comment>
<projects>
<project>libnode</project>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>libnode_src</name>
<type>2</type>
<locationURI>_android_libnode_9e68607/src</locationURI>
</link>
</linkedResources>
</projectDescription>
23 changes: 23 additions & 0 deletions app/AndroidManifest.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.meshpoint.anode"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.STATUS_BAR"></uses-permission>


<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AnodeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
</manifest>
Empty file added app/assets/.gitignore
Empty file.
12 changes: 12 additions & 0 deletions app/default.properties
@@ -0,0 +1,12 @@
# 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 use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-10
android.library.reference.1=../libnode
40 changes: 40 additions & 0 deletions app/proguard.cfg
@@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Binary file added app/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions app/res/layout/main.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_height="wrap_content" android:text="@string/arguments" android:layout_width="fill_parent"></TextView>
<EditText android:layout_height="wrap_content" android:id="@+id/args_editText" android:layout_width="match_parent"></EditText>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="match_parent" android:weightSum="1">
<Button android:id="@+id/start_button" android:layout_height="wrap_content" android:text="@string/start" android:layout_width="wrap_content"></Button>
<Button android:id="@+id/stop_button" android:layout_height="wrap_content" android:text="@string/stop" android:layout_width="wrap_content"></Button>
<TextView android:layout_height="wrap_content" android:id="@+id/args_stateText" android:layout_width="105dp" android:layout_weight="0.54"></TextView>
</LinearLayout>
</LinearLayout>
12 changes: 12 additions & 0 deletions app/res/values/strings.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Anode</string>
<string name="start">Start</string>
<string name="stop">Stop</string>
<string name="arguments">Arguments:</string>
<string name="run_state">Run state</string>
<string name="created">Created</string>
<string name="started">Started</string>
<string name="stopping">Stopping</string>
<string name="stopped">Stopped</string>
</resources>
116 changes: 116 additions & 0 deletions app/src/org/meshpoint/anode/AnodeActivity.java
@@ -0,0 +1,116 @@
package org.meshpoint.anode;

import org.meshpoint.anode.Runtime;
import org.meshpoint.anode.Runtime.IllegalStateException;
import org.meshpoint.anode.Runtime.InitialisationException;
import org.meshpoint.anode.Runtime.NodeException;
import org.meshpoint.anode.Runtime.StateListener;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AnodeActivity extends Activity implements StateListener {

private static String TAG = "anode::AnodeActivity";
private Context ctx;
private Button startButton;
private Button stopButton;
private EditText argsText;
private TextView stateText;
private Handler viewHandler = new Handler();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ctx = getApplicationContext();
initUI();
initRuntime();
}

private Runtime runtime;

private void initUI() {
startButton = (Button)findViewById(R.id.start_button);
startButton.setOnClickListener(new StartClickListener());
stopButton = (Button)findViewById(R.id.stop_button);
stopButton.setOnClickListener(new StopClickListener());
argsText = (EditText)findViewById(R.id.args_editText);
stateText = (TextView)findViewById(R.id.args_stateText);
}

private void initRuntime() {
try {
runtime = Runtime.getRuntime(ctx);
if(runtime != null)
runtime.addStateListener(this);
} catch (InitialisationException e) {
Log.v(TAG, "initRuntime: exception: " + e + "cause: " + e.getCause());
}
}

class StartClickListener implements OnClickListener {
@Override
public void onClick(View arg0) {
String args = argsText.getText().toString();
try {
runtime.start(args.split("\\s"));
} catch (IllegalStateException e) {
Log.v(TAG, "runtime start: exception: " + e + "cause: " + e.getCause());
} catch (NodeException e) {
Log.v(TAG, "runtime start: exception: " + e);
}
}
}

class StopClickListener implements OnClickListener {
@Override
public void onClick(View arg0) {
try {
runtime.stop();
} catch (IllegalStateException e) {
Log.v(TAG, "runtime stop: exception: " + e + "cause: " + e.getCause());
} catch (NodeException e) {
Log.v(TAG, "runtime stop: exception: " + e);
}
}
}

@Override
public void stateChanged(final int state) {
viewHandler.post(new Runnable() {
public void run() {
stateText.setText(getStateString(state));
}});
}

private String getStateString(int state) {
Resources res = ctx.getResources();
String result = null;
switch(state) {
case Runtime.STATE_CREATED:
result = res.getString(R.string.created);
break;
case Runtime.STATE_STARTED:
result = res.getString(R.string.started);
break;
case Runtime.STATE_STOPPING:
result = res.getString(R.string.stopping);
break;
case Runtime.STATE_STOPPED:
result = res.getString(R.string.stopped);
break;
}
return result;
}
}
7 changes: 7 additions & 0 deletions libnode/.classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions libnode/.project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libnode</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions libnode/AndroidManifest.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.meshpoint.anode"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
</manifest>
Empty file added libnode/assets/.gitignore
Empty file.
12 changes: 12 additions & 0 deletions libnode/default.properties
@@ -0,0 +1,12 @@
# 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 use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-10
android.library=true

0 comments on commit abbc285

Please sign in to comment.