diff --git a/apollolib/.classpath b/apollolib/.classpath
index 609aa00..aff8e75 100644
--- a/apollolib/.classpath
+++ b/apollolib/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/apollolib/default.properties b/apollolib/project.properties
similarity index 81%
rename from apollolib/default.properties
rename to apollolib/project.properties
index 948be06..7662246 100644
--- a/apollolib/default.properties
+++ b/apollolib/project.properties
@@ -4,9 +4,9 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library=true
# Project target.
target=android-8
-android.library=true
diff --git a/cicada/.classpath b/cicada/.classpath
index ed3126c..a4f1e40 100644
--- a/cicada/.classpath
+++ b/cicada/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/cicada/.project b/cicada/.project
index 95b181e..dedbe81 100644
--- a/cicada/.project
+++ b/cicada/.project
@@ -30,16 +30,4 @@
com.android.ide.eclipse.adt.AndroidNature
org.eclipse.jdt.core.javanature
-
-
- ApolloLib_src
- 2
- _android_ApolloLib_c6286f16/src
-
-
- CicadaLib_src
- 2
- _android_CicadaLib_8981e3e4/src
-
-
diff --git a/cicada/default.properties b/cicada/default.properties
index 7bfb455..32299c2 100644
--- a/cicada/default.properties
+++ b/cicada/default.properties
@@ -1,13 +1,2 @@
-# 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-8
-android.library.reference.1=../apollolib
-android.library.reference.2=../cicadalib
diff --git a/cicada/project.properties b/cicada/project.properties
new file mode 100644
index 0000000..f8792c1
--- /dev/null
+++ b/cicada/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
+android.library.reference.1=../cicadalib
diff --git a/cicadalib/.classpath b/cicadalib/.classpath
index 729745d..a4f1e40 100644
--- a/cicadalib/.classpath
+++ b/cicadalib/.classpath
@@ -1,8 +1,8 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/cicadalib/default.properties b/cicadalib/project.properties
similarity index 83%
rename from cicadalib/default.properties
rename to cicadalib/project.properties
index ba2ea7b..855bd29 100644
--- a/cicadalib/default.properties
+++ b/cicadalib/project.properties
@@ -4,10 +4,10 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library=true
# Project target.
target=android-8
-android.library=true
android.library.reference.1=../apollolib
diff --git a/samples/WebImagePlayer/.classpath b/samples/WebImagePlayer/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/WebImagePlayer/.classpath
+++ b/samples/WebImagePlayer/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/notificationdemo/default.properties b/samples/WebImagePlayer/project.properties
similarity index 82%
rename from samples/notificationdemo/default.properties
rename to samples/WebImagePlayer/project.properties
index c33f3d2..94aab77 100644
--- a/samples/notificationdemo/default.properties
+++ b/samples/WebImagePlayer/project.properties
@@ -4,9 +4,9 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library.reference.1=../../cicadalib
# Project target.
target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/bitly/.classpath b/samples/bitly/.classpath
index 1f4e4b5..5f3f0c2 100644
--- a/samples/bitly/.classpath
+++ b/samples/bitly/.classpath
@@ -1,9 +1,10 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/bitly/.project b/samples/bitly/.project
index 9b32b47..0cdf21f 100644
--- a/samples/bitly/.project
+++ b/samples/bitly/.project
@@ -1,45 +1,45 @@
-
-
- Bitly
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
-
- ApolloLib_src
- 2
- _android_ApolloLib_c6286f16/src
-
-
- CicadaLib_src
- 2
- _android_CicadaLib_8981e3e4/src
-
-
-
+
+
+ Bitly
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
+
+ ApolloLib_src
+ 2
+ _android_ApolloLib_c6286f16/src
+
+
+ CicadaLib_src
+ 2
+ _android_CicadaLib_8981e3e4/src
+
+
+
diff --git a/samples/nextbuses/default.properties b/samples/bitly/project.properties
similarity index 82%
rename from samples/nextbuses/default.properties
rename to samples/bitly/project.properties
index c33f3d2..94aab77 100644
--- a/samples/nextbuses/default.properties
+++ b/samples/bitly/project.properties
@@ -4,9 +4,9 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library.reference.1=../../cicadalib
# Project target.
target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/digitalclock/.classpath b/samples/digitalclock/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/digitalclock/.classpath
+++ b/samples/digitalclock/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/bitly/default.properties b/samples/digitalclock/project.properties
similarity index 82%
rename from samples/bitly/default.properties
rename to samples/digitalclock/project.properties
index c33f3d2..2e3ebc1 100644
--- a/samples/bitly/default.properties
+++ b/samples/digitalclock/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
diff --git a/samples/hellocicada/.classpath b/samples/hellocicada/.classpath
index 729745d..a4f1e40 100644
--- a/samples/hellocicada/.classpath
+++ b/samples/hellocicada/.classpath
@@ -1,8 +1,8 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/hellocicada/default.properties b/samples/hellocicada/project.properties
similarity index 82%
rename from samples/hellocicada/default.properties
rename to samples/hellocicada/project.properties
index 7cf937f..9be174d 100644
--- a/samples/hellocicada/default.properties
+++ b/samples/hellocicada/project.properties
@@ -4,9 +4,9 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library.reference.1=../../apollolib
# Project target.
target=android-8
-android.library.reference.1=../../apollolib
diff --git a/samples/nextbuses/.classpath b/samples/nextbuses/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/nextbuses/.classpath
+++ b/samples/nextbuses/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/digitalclock/default.properties b/samples/nextbuses/project.properties
similarity index 82%
rename from samples/digitalclock/default.properties
rename to samples/nextbuses/project.properties
index c33f3d2..94aab77 100644
--- a/samples/digitalclock/default.properties
+++ b/samples/nextbuses/project.properties
@@ -4,9 +4,9 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
+android.library.reference.1=../../cicadalib
# Project target.
target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/notificationdemo/.classpath b/samples/notificationdemo/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/notificationdemo/.classpath
+++ b/samples/notificationdemo/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/notificationdemo/project.properties b/samples/notificationdemo/project.properties
new file mode 100644
index 0000000..94aab77
--- /dev/null
+++ b/samples/notificationdemo/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library.reference.1=../../cicadalib
+# Project target.
+target=android-8
diff --git a/samples/notifications/.classpath b/samples/notifications/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/notifications/.classpath
+++ b/samples/notifications/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/notifications/.project b/samples/notifications/.project
index 1d88aec..f692310 100644
--- a/samples/notifications/.project
+++ b/samples/notifications/.project
@@ -1,45 +1,33 @@
-
-
- Notifications
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
-
- ApolloLib_src
- 2
- _android_ApolloLib_c6286f16/src
-
-
- CicadaLib_src
- 2
- _android_CicadaLib_8981e3e4/src
-
-
-
+
+
+ Notifications
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/samples/notifications/default.properties b/samples/notifications/default.properties
index 7027a19..fc667cd 100644
--- a/samples/notifications/default.properties
+++ b/samples/notifications/default.properties
@@ -9,4 +9,4 @@
# Project target.
target=android-5
-android.library.reference.1=../cicada/cicadalib
+android.library.reference.1=../../cicadalib
diff --git a/samples/quicktext/default.properties b/samples/notifications/project.properties
similarity index 82%
rename from samples/quicktext/default.properties
rename to samples/notifications/project.properties
index fc667cd..02e082c 100644
--- a/samples/quicktext/default.properties
+++ b/samples/notifications/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
diff --git a/samples/phonestatus/.classpath b/samples/phonestatus/.classpath
new file mode 100644
index 0000000..7011827
--- /dev/null
+++ b/samples/phonestatus/.classpath
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/samples/phonestatus/.project b/samples/phonestatus/.project
new file mode 100644
index 0000000..36367ee
--- /dev/null
+++ b/samples/phonestatus/.project
@@ -0,0 +1,45 @@
+
+
+ PhoneStatus
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
+
+ ApolloLib_src
+ 2
+ _android_ApolloLib_c6286f16/src
+
+
+ CicadaLib_src
+ 2
+ _android_CicadaLib_8981e3e4/src
+
+
+
diff --git a/samples/phonestatus/AndroidManifest.xml b/samples/phonestatus/AndroidManifest.xml
new file mode 100644
index 0000000..f25421e
--- /dev/null
+++ b/samples/phonestatus/AndroidManifest.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/WebImagePlayer/default.properties b/samples/phonestatus/default.properties
similarity index 100%
rename from samples/WebImagePlayer/default.properties
rename to samples/phonestatus/default.properties
diff --git a/samples/phonestatus/proguard.cfg b/samples/phonestatus/proguard.cfg
new file mode 100644
index 0000000..b1cdf17
--- /dev/null
+++ b/samples/phonestatus/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 ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (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 *;
+}
diff --git a/samples/phonestatus/res/drawable-hdpi/icon.png b/samples/phonestatus/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000..8074c4c
Binary files /dev/null and b/samples/phonestatus/res/drawable-hdpi/icon.png differ
diff --git a/samples/phonestatus/res/drawable-ldpi/icon.png b/samples/phonestatus/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000..1095584
Binary files /dev/null and b/samples/phonestatus/res/drawable-ldpi/icon.png differ
diff --git a/samples/phonestatus/res/drawable-mdpi/icon.png b/samples/phonestatus/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..a07c69f
Binary files /dev/null and b/samples/phonestatus/res/drawable-mdpi/icon.png differ
diff --git a/samples/phonestatus/res/values/strings.xml b/samples/phonestatus/res/values/strings.xml
new file mode 100644
index 0000000..01f230e
--- /dev/null
+++ b/samples/phonestatus/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Phone Status
+
diff --git a/samples/phonestatus/src/com/hydraproductions/cicada/phonestatus/PhoneStatus.java b/samples/phonestatus/src/com/hydraproductions/cicada/phonestatus/PhoneStatus.java
new file mode 100644
index 0000000..798ba9d
--- /dev/null
+++ b/samples/phonestatus/src/com/hydraproductions/cicada/phonestatus/PhoneStatus.java
@@ -0,0 +1,102 @@
+package com.hydraproductions.cicada.phonestatus;
+
+import org.cicadasong.cicadalib.CicadaApp;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Typeface;
+
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.telephony.SignalStrength; // API Level 7+
+import android.util.Log;
+
+/**
+ * @See http://developer.android.com/reference/android/telephony/SignalStrength.html#getGsmSignalStrength%28%29
+ * @See 3GPP TS 27.007 v6.3.0 (2003-06) - Section 8.5 - Signal Quality +CSQ
+ * @author Dominic Clifton
+ */
+public class PhoneStatus extends CicadaApp {
+
+ public static final String TAG = PhoneStatus.class.getSimpleName();
+
+ private Paint paint;
+ private TelephonyManager telephonyManager;
+ private StatusPhoneStateListener phoneStateListener;
+ float signalStrengthPercentage;
+
+ final static short GSM_STRENGTH_MIN = 0;
+ final static short GSM_STRENGTH_MAX = 31;
+ final static short GSM_STRENGTH_UNKNOWN = 99;
+
+ protected float calculateSignalStrengthPercentage(SignalStrength signalStrength) {
+ // TODO add CDMA signal strength calculations
+ int gsmSignalStrength = signalStrength.getGsmSignalStrength();
+ Log.i(TAG, String.format("GSM Signal Strength: %d", gsmSignalStrength));
+ if (gsmSignalStrength == GSM_STRENGTH_MAX) {
+ return 0;
+ }
+ return (float)(gsmSignalStrength * 100) / GSM_STRENGTH_UNKNOWN;
+ }
+
+ protected void updateSignalStrength(SignalStrength signalStrength) {
+ signalStrengthPercentage = calculateSignalStrengthPercentage(signalStrength);
+
+ if (!PhoneStatus.this.isActive()) {
+ return;
+ }
+ invalidate();
+ }
+
+
+ private class StatusPhoneStateListener extends PhoneStateListener {
+ @Override
+ public void onSignalStrengthsChanged(SignalStrength signalStrength) {
+ updateSignalStrength(signalStrength);
+ }
+ };
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ phoneStateListener = new StatusPhoneStateListener();
+ telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
+ }
+
+ @Override
+ public String getAppName() {
+ return getString(R.string.app_name);
+ }
+
+ @Override
+ protected void onResume() {
+ paint = new Paint();
+ paint.setTextAlign(Paint.Align.CENTER);
+ paint.setTypeface(Typeface.DEFAULT_BOLD);
+ paint.setAntiAlias(false);
+ paint.setTextSize(16);
+
+ telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
+
+ invalidate();
+ }
+
+ @Override
+ protected void onPause() {
+ telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ int x = canvas.getWidth() / 2;
+ int y = (int) (canvas.getHeight() - paint.ascent()) / 2;
+ String readout = String.format("%3.2f%%", signalStrengthPercentage);
+ canvas.drawText(readout, x, y, paint);
+ }
+
+ @Override
+ protected void onButtonPress(WatchButton button) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/samples/quicktext/.classpath b/samples/quicktext/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/quicktext/.classpath
+++ b/samples/quicktext/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/quicktext/project.properties b/samples/quicktext/project.properties
new file mode 100644
index 0000000..cf20be6
--- /dev/null
+++ b/samples/quicktext/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library.reference.1=../../cicadalib
+# Project target.
+target=android-5
diff --git a/samples/smsnotifier/.classpath b/samples/smsnotifier/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/smsnotifier/.classpath
+++ b/samples/smsnotifier/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/smsnotifier/default.properties b/samples/smsnotifier/default.properties
deleted file mode 100644
index c33f3d2..0000000
--- a/samples/smsnotifier/default.properties
+++ /dev/null
@@ -1,12 +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 use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/smsnotifier/project.properties b/samples/smsnotifier/project.properties
new file mode 100644
index 0000000..94aab77
--- /dev/null
+++ b/samples/smsnotifier/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library.reference.1=../../cicadalib
+# Project target.
+target=android-8
diff --git a/samples/stopwatch/.classpath b/samples/stopwatch/.classpath
index cf5a7b1..a55e00e 100644
--- a/samples/stopwatch/.classpath
+++ b/samples/stopwatch/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/stopwatch/AndroidManifest.xml b/samples/stopwatch/AndroidManifest.xml
index bb18ddd..b054cf1 100644
--- a/samples/stopwatch/AndroidManifest.xml
+++ b/samples/stopwatch/AndroidManifest.xml
@@ -1,6 +1,6 @@
diff --git a/samples/stopwatch/default.properties b/samples/stopwatch/default.properties
deleted file mode 100644
index c33f3d2..0000000
--- a/samples/stopwatch/default.properties
+++ /dev/null
@@ -1,12 +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 use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/stopwatch/project.properties b/samples/stopwatch/project.properties
new file mode 100644
index 0000000..94aab77
--- /dev/null
+++ b/samples/stopwatch/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library.reference.1=../../cicadalib
+# Project target.
+target=android-8
diff --git a/samples/stopwatch/res/values/strings.xml b/samples/stopwatch/res/values/strings.xml
index 7b94ef3..9962d36 100644
--- a/samples/stopwatch/res/values/strings.xml
+++ b/samples/stopwatch/res/values/strings.xml
@@ -1,4 +1,4 @@
- StopWatch
+ Stopwatch
diff --git a/samples/stopwatch/src/com/hydraproductions/cicada/StopWatch.java b/samples/stopwatch/src/com/hydraproductions/cicada/stopwatch/StopWatch.java
similarity index 94%
rename from samples/stopwatch/src/com/hydraproductions/cicada/StopWatch.java
rename to samples/stopwatch/src/com/hydraproductions/cicada/stopwatch/StopWatch.java
index d464e99..12a984d 100644
--- a/samples/stopwatch/src/com/hydraproductions/cicada/StopWatch.java
+++ b/samples/stopwatch/src/com/hydraproductions/cicada/stopwatch/StopWatch.java
@@ -1,4 +1,4 @@
-package com.hydraproductions.cicada;
+package com.hydraproductions.cicada.stopwatch;
/**
* Stopwatch example
diff --git a/samples/tubestatus/.classpath b/samples/tubestatus/.classpath
index 1f4e4b5..a4f1e40 100644
--- a/samples/tubestatus/.classpath
+++ b/samples/tubestatus/.classpath
@@ -1,9 +1,8 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/tubestatus/default.properties b/samples/tubestatus/default.properties
deleted file mode 100644
index c33f3d2..0000000
--- a/samples/tubestatus/default.properties
+++ /dev/null
@@ -1,12 +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 use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-8
-android.library.reference.1=../../cicadalib
diff --git a/samples/tubestatus/project.properties b/samples/tubestatus/project.properties
new file mode 100644
index 0000000..2e3ebc1
--- /dev/null
+++ b/samples/tubestatus/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
+android.library.reference.1=../../cicadalib
diff --git a/samples/tubestatus/src/org/cicadasong/samples/tubestatus/TubeStatus.java b/samples/tubestatus/src/org/cicadasong/samples/tubestatus/TubeStatus.java
index 08ac239..08a99ad 100644
--- a/samples/tubestatus/src/org/cicadasong/samples/tubestatus/TubeStatus.java
+++ b/samples/tubestatus/src/org/cicadasong/samples/tubestatus/TubeStatus.java
@@ -21,6 +21,9 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.cicadasong.cicadalib.CicadaApp;
import org.json.JSONException;
@@ -37,6 +40,9 @@
* An example app that fetches the current status of a particular London Underground line.
* If this was a real app, it would also provide a phone-side setup screen to pick the train
* lines to show.
+ *
+ * It uses the tubeupdates.com site to get the information which currently scrapes information from TFL.
+ * Api documentation is here: http://tubeupdates.com/documentation/
*/
public class TubeStatus extends CicadaApp {
public static final String TAG = TubeStatus.class.getSimpleName();
@@ -44,11 +50,75 @@ public class TubeStatus extends CicadaApp {
// Update every 15 minutes so we don't barrage the server.
public static final int STATUS_UPDATE_INTERVAL_MSEC = 15 * 60 * 1000;
- private String line = "Victoria Line";
- private String status = "Fetching...";
+ private enum TubeLine {
+ ALL("All lines", "all"),
+ TUBE("Tube only", "tube"), // excludes DLR and Overground
+ OVERGROUND("Overground", "overground"),
+
+ BAKERLOO("Bakerloo", "bakerloo"),
+ CENTRAL("Central", "central"),
+ CIRCLE("Circle", "circle"),
+ DISTRICT("District", "district"),
+ DLR("DLR", "docklands"),
+ HAMMERSMITH_AND_CITY("Hammersmith & City", "hammersmithcity"),
+ JUBILEE("Jubilee", "jubilee"),
+ METROPOLITAN("Metropolitan", "metropolitan"),
+ NORTHERN("Northern", "northern"),
+ PICCADILLY("Piccadilly", "piccadilly"),
+ VICTORIA("Victoria", "victoria"),
+ WATERLOO_AND_CITY("Waterloo & City", "waterloocity");
+
+ public String name;
+ public String lineIdentifier;
+
+ TubeLine(String name, String lineIdentifier) {
+ this.name = name;
+ this.lineIdentifier = lineIdentifier;
+ }
+ }
+
+ // wildcards followed by alphabetically ordered list
+ private List allLines = new ArrayList(Arrays.asList(
+ TubeLine.ALL,
+ TubeLine.TUBE,
+ TubeLine.OVERGROUND,
+ TubeLine.BAKERLOO,
+ TubeLine.CENTRAL,
+ TubeLine.CIRCLE,
+ TubeLine.DISTRICT,
+ TubeLine.DLR,
+ TubeLine.HAMMERSMITH_AND_CITY,
+ TubeLine.JUBILEE,
+ TubeLine.METROPOLITAN,
+ TubeLine.NORTHERN,
+ TubeLine.PICCADILLY,
+ TubeLine.VICTORIA,
+ TubeLine.WATERLOO_AND_CITY
+ ));
+
+ private int selectionIndex;
+ private TubeLine selectedLine;
+ private String status;
private Runnable updateStatusTask;
private Handler handler;
+ @Override
+ public void onCreate() {
+ updateSelection(0);
+ refreshStatus();
+ }
+
+ private void updateSelection(int index) {
+ if (index < 0) {
+ index = allLines.size() - 1;
+ }
+ if (index >= allLines.size()) {
+ index = 0;
+ }
+ selectionIndex = index;
+ selectedLine = allLines.get(selectionIndex);
+ }
+
@Override
protected void onResume() {
Log.v(TAG, "Tube Status activated in mode: " + getCurrentMode());
@@ -78,8 +148,33 @@ protected void onPause() {
@Override
protected void onButtonPress(WatchButton button) {
+ switch (button) {
+ case TOP_RIGHT:
+ updateSelection(selectionIndex - 1);
+ refreshStatus();
+ break;
+ case MIDDLE_RIGHT:
+ handler.post(updateStatusTask);
+ refreshStatus();
+ break;
+ case BOTTOM_RIGHT:
+ updateSelection(selectionIndex + 1);
+ refreshStatus();
+ break;
+ }
}
+ protected void refreshStatus() {
+ status = "Fetching...";
+ if (!isActive()) {
+ return;
+ }
+ if (handler != null) {
+ handler.post(updateStatusTask);
+ }
+ invalidate();
+ }
+
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setTextAlign(Paint.Align.CENTER);
@@ -92,7 +187,7 @@ protected void onDraw(Canvas canvas) {
paint.setTypeface(Typeface.DEFAULT);
paint.setTextSize(11);
- canvas.drawText(line, x, y - paint.descent() - 1, paint);
+ canvas.drawText(selectedLine.name, x, y - paint.descent() - 1, paint);
paint.setTextSize(14);
canvas.drawText(status, x, y + (int)-paint.ascent() + 1, paint);
@@ -122,7 +217,7 @@ private void processStatusUpdate(String newStatus) {
private class GetStatusTask extends AsyncTask {
private static final String TUBE_STATUS_URL =
- "http://api.tubeupdates.com/?method=get.status&lines=victoria&return=status";
+ "http://api.tubeupdates.com/?method=get.status&lines={lineIdentifier}&return=status";
protected void onPostExecute(String result) {
processStatusUpdate(result);
}
@@ -131,7 +226,7 @@ protected String doInBackground(Void... params) {
String result = "Network Error";
HttpURLConnection connection = null;
try {
- URL url = new URL(TUBE_STATUS_URL);
+ URL url = new URL(TUBE_STATUS_URL.replace("{lineIdentifier}", selectedLine.lineIdentifier));
connection = (HttpURLConnection) url.openConnection();
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
String response = convertStreamToString(connection.getInputStream());