Added a simple 'about' dialog box with menu item to show it.

This commit is contained in:
Graham Jones
2015-11-17 23:02:40 +00:00
parent 16a9207ded
commit 65d7731c0b
8 changed files with 559 additions and 435 deletions

View File

@@ -71,6 +71,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -88,7 +90,10 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="pebblekit-2.6.0-eclipse" level="project" /> <orderEntry type="library" exported="" name="pebblekit-2.6.0-eclipse" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
<orderEntry type="library" exported="" name="mpandroidchartlibrary-2-0-7" level="project" /> <orderEntry type="library" exported="" name="mpandroidchartlibrary-2-0-7" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
</component> </component>
</module> </module>

View File

@@ -21,4 +21,5 @@ android {
dependencies { dependencies {
compile files('libs/mpandroidchartlibrary-2-0-7.jar') compile files('libs/mpandroidchartlibrary-2-0-7.jar')
compile files('libs/pebblekit-2.6.0-eclipse.jar') compile files('libs/pebblekit-2.6.0-eclipse.jar')
compile 'com.android.support:appcompat-v7:22.2.1'
} }

View File

@@ -3,36 +3,45 @@
package="uk.org.openseizuredetector" package="uk.org.openseizuredetector"
android:versionCode="17" android:versionCode="17"
android:versionName="2.0a" > android:versionName="2.0a" >
<uses-sdk android:minSdkVersion="11" /> <uses-sdk android:minSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<application android:label="@string/app_name" <uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/star_of_life_48x48" android:icon="@drawable/star_of_life_48x48"
> android:label="@string/app_name" >
<activity android:name="MainActivity" <activity
android:label="@string/app_name" android:name=".MainActivity"
android:icon="@drawable/star_of_life_48x48" android:icon="@drawable/star_of_life_48x48"
> android:label="@string/app_name" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="PrefActivity" <activity
android:label="OpenSeizureDetector Preferences" android:name=".PrefActivity"
android:icon="@drawable/star_of_life_48x48" android:icon="@drawable/star_of_life_48x48"
> android:label="OpenSeizureDetector Preferences" >
</activity> </activity>
<service <service
android:name=".SdServer" android:name=".SdServer"
android:exported="false" /> android:exported="false" />
</application> </application>
</manifest>
</manifest><!-- android:uiOptions="splitActionBarWhenNarrow" -->
<!-- android:uiOptions="splitActionBarWhenNarrow"
-->

View File

@@ -28,6 +28,7 @@ package uk.org.openseizuredetector;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo; import android.app.ActivityManager.RunningServiceInfo;
import android.app.AlertDialog;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -51,6 +52,7 @@ import android.view.ViewConfiguration;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Button; import android.widget.Button;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
@@ -58,6 +60,7 @@ import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.apache.http.conn.util.InetAddressUtils; import org.apache.http.conn.util.InetAddressUtils;
//MPAndroidChart //MPAndroidChart
@@ -66,8 +69,7 @@ import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet; import com.github.mikephil.charting.data.LineDataSet;
public class MainActivity extends Activity public class MainActivity extends Activity {
{
static final String TAG = "MainActivity"; static final String TAG = "MainActivity";
private int okColour = Color.BLUE; private int okColour = Color.BLUE;
private int warnColour = Color.MAGENTA; private int warnColour = Color.MAGENTA;
@@ -81,10 +83,11 @@ public class MainActivity extends Activity
final Handler serverStatusHandler = new Handler(); final Handler serverStatusHandler = new Handler();
Messenger messenger = new Messenger(new ResponseHandler()); Messenger messenger = new Messenger(new ResponseHandler());
/** Called when the activity is first created. */ /**
* Called when the activity is first created.
*/
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState) {
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Initialise the User Interface // Initialise the User Interface
@@ -123,7 +126,9 @@ public class MainActivity extends Activity
Timer uiTimer = new Timer(); Timer uiTimer = new Timer();
uiTimer.schedule(new TimerTask() { uiTimer.schedule(new TimerTask() {
@Override @Override
public void run() {updateServerStatus();} public void run() {
updateServerStatus();
}
}, 0, 1000); }, 0, 1000);
} }
@@ -132,8 +137,7 @@ public class MainActivity extends Activity
* Create Action Bar * Create Action Bar
*/ */
@Override @Override
public boolean onCreateOptionsMenu (Menu menu) public boolean onCreateOptionsMenu(Menu menu) {
{
getMenuInflater().inflate(R.menu.main_activity_actions, menu); getMenuInflater().inflate(R.menu.main_activity_actions, menu);
mOptionsMenu = menu; mOptionsMenu = menu;
return true; return true;
@@ -209,6 +213,11 @@ public class MainActivity extends Activity
Log.v(TAG, "exception starting settings activity " + ex.toString()); Log.v(TAG, "exception starting settings activity " + ex.toString());
} }
return true; return true;
case R.id.action_about:
Log.v(TAG, "action_about");
showAbout();
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@@ -257,7 +266,9 @@ public class MainActivity extends Activity
unbindFromServer(); unbindFromServer();
} }
/** Defines callbacks for service binding, passed to bindService() */ /**
* Defines callbacks for service binding, passed to bindService()
*/
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
@Override @Override
@@ -270,8 +281,7 @@ public class MainActivity extends Activity
if (mSdServer != null) { if (mSdServer != null) {
Log.v(TAG, "onServiceConnected() - Asking server to update its settings"); Log.v(TAG, "onServiceConnected() - Asking server to update its settings");
mSdServer.updatePrefs(); mSdServer.updatePrefs();
} } else {
else {
Log.v(TAG, "onServiceConnected() - mSdServer is null - this is wrong!"); Log.v(TAG, "onServiceConnected() - mSdServer is null - this is wrong!");
} }
} }
@@ -374,7 +384,8 @@ public class MainActivity extends Activity
} }
/** get the ip address of the phone. /**
* get the ip address of the phone.
* Based on http://stackoverflow.com/questions/11015912/how-do-i-get-ip-address-in-ipv4-format * Based on http://stackoverflow.com/questions/11015912/how-do-i-get-ip-address-in-ipv4-format
*/ */
public String getLocalIpAddress() { public String getLocalIpAddress() {
@@ -406,7 +417,6 @@ public class MainActivity extends Activity
} }
/* /*
* updateServerStatus - called by the uiTimer timer periodically. * updateServerStatus - called by the uiTimer timer periodically.
* requests the ui to be updated by calling serverStatusRunnable. * requests the ui to be updated by calling serverStatusRunnable.
@@ -495,8 +505,7 @@ public class MainActivity extends Activity
+ mSdServer.mSdData.simpleSpec[i] + mSdServer.mSdData.simpleSpec[i]
+ ", "; + ", ";
tv.setText("Spec = " + specStr); tv.setText("Spec = " + specStr);
} } else {
else {
tv = (TextView) findViewById(R.id.alarmTv); tv = (TextView) findViewById(R.id.alarmTv);
tv.setText("Not Connected to Server"); tv.setText("Not Connected to Server");
tv.setBackgroundColor(warnColour); tv.setBackgroundColor(warnColour);
@@ -542,6 +551,7 @@ public class MainActivity extends Activity
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@@ -553,8 +563,39 @@ public class MainActivity extends Activity
// String viewText = "Unknown"; // String viewText = "Unknown";
//} //}
private String getAppVersionName() {
String versionName = "unknown";
// From http://stackoverflow.com/questions/4471025/
// how-can-you-get-the-manifest-version-number-
// from-the-apps-layout-xml-variable
final PackageManager packageManager = getPackageManager();
if (packageManager != null) {
try {
PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
versionName = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
Log.v(TAG, "failed to find versionName");
versionName = null;
}
}
return versionName;
}
private void showAbout() {
View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false);
String versionName = getAppVersionName();
Log.v(TAG,"showAbout() - version name = "+versionName);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.icon_24x24);
builder.setTitle("OpenSeizureDetector V"+versionName);
builder.setView(aboutView);
builder.create();
builder.show();
}
class ResponseHandler extends Handler { class ResponseHandler extends Handler {
@Override public void handleMessage(Message message) { @Override
public void handleMessage(Message message) {
Log.v(TAG, "Message=" + message.toString()); Log.v(TAG, "Message=" + message.toString());
} }
} }

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
http://www.apache.org/licenses/LICENSE-2.0
-->
<ScrollView>
android:layout_width="match_parent"
android:layout_height="match_parent"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dip">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="OpenSeizureDetector epileptic\n
(tonic-clonic) seizure detector and \n
alarm system. Uses a Pebble Smart\n
watch to detect the shaking \n
associated with a seizure, \n
then raises audible and text\n
message (SMS) alerts for carers.\n
The system is free and open source - see \n
http://openseizuredetector.org.uk for details.
Please report any issues to graham@openseizuredetector.org.uk\n
or raise an issue on the project github source code \n
repository - https://github.com/OpenSeizureDetector"
/>
<TextView
android:id="@+id/about_credits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dip"
android:textSize="16sp"
android:text="Main Watch App and Android App \n
copyright Graham Jones, 2015.\n
The following libraries are used:\n
- SYLT-FFT - https://github.com/stg/SYLT-FFT by D. Taylor.\n
- NanoHTTPD - https://github.com/NanoHttpd/nanohttpd\n
- jQuery - http://jquery.org\n
- jBeep - http://www.ultraduz.com.br\n
- Chartjs - http://www.chartjs.org\n
- MPAndroidChart - https://github.com/PhilJay/MPAndroidChart\n
\n
The Logo is based on Star of life2 by Verdy P, \n
Licensed under Public Domain via\n
Wikimedia Commons (http://commons.wikimedia.org/wiki/File:Star_of_life2.svg#mediaviewer/File:Star_of_life2.svg).
"
android:autoLink="web"
/>
</LinearLayout>
</ScrollView>

View File

@@ -1,58 +1,56 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_accept_alarm" <item
android:title="Accept Alarm" android:id="@+id/action_accept_alarm"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Accept Alarm" />
<item android:id="@+id/action_launch_pebble_app" <item
android:id="@+id/action_launch_pebble_app"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Launch Pebble App"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Launch Pebble App" />
<item android:id="@+id/action_start_stop" <item
android:id="@+id/action_start_stop"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Stop Server"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Stop Server" />
<item android:id="@+id/action_test_fault_beep" <item
android:id="@+id/action_test_fault_beep"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Test Fault Beep"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Test Fault Beep" />
<item android:id="@+id/action_test_alarm_beep" <item
android:id="@+id/action_test_alarm_beep"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Test Alarm Beep"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Test Alarm Beep" />
<item android:id="@+id/action_test_warning_beep" <item
android:id="@+id/action_test_warning_beep"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Test Warning Beep"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Test Warning Beep" />
<item android:id="@+id/action_test_sms_alarm" <item
android:id="@+id/action_test_sms_alarm"
android:icon="@drawable/stop_server" android:icon="@drawable/stop_server"
android:title="Test SMS Alarm Notification"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Test SMS Alarm Notification" />
<item android:id="@+id/action_settings" <item
android:id="@+id/action_settings"
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
android:title="Settings"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="Settings" />
<!-- <item
<item android:id="@+id/action_watch_settings" android:id="@+id/action_about"
android:icon="@drawable/ic_action_settings"
android:title="Watch Settings"
android:showAsAction="never|withText" android:showAsAction="never|withText"
/> android:title="About..." />
-->
</menu> </menu>

View File

@@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View File

@@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>