Added a simple 'about' dialog box with menu item to show it.
This commit is contained in:
@@ -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>
|
||||||
@@ -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'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,47 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.SEND_SMS"/>
|
|
||||||
<uses-feature android:name="android.hardware.telephony" android:required="false" />
|
|
||||||
<application android:label="@string/app_name"
|
|
||||||
android:icon="@drawable/star_of_life_48x48"
|
|
||||||
>
|
|
||||||
<activity android:name="MainActivity"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:icon="@drawable/star_of_life_48x48"
|
|
||||||
>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity android:name="PrefActivity"
|
|
||||||
android:label="OpenSeizureDetector Preferences"
|
|
||||||
android:icon="@drawable/star_of_life_48x48"
|
|
||||||
>
|
|
||||||
</activity>
|
|
||||||
<service
|
|
||||||
android:name=".SdServer"
|
|
||||||
android:exported="false"/>
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="11" />
|
||||||
|
|
||||||
<!-- android:uiOptions="splitActionBarWhenNarrow"
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
-->
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
|
|
||||||
|
<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:label="@string/app_name" >
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:icon="@drawable/star_of_life_48x48"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".PrefActivity"
|
||||||
|
android:icon="@drawable/star_of_life_48x48"
|
||||||
|
android:label="OpenSeizureDetector Preferences" >
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".SdServer"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest><!-- android:uiOptions="splitActionBarWhenNarrow" -->
|
||||||
|
|||||||
@@ -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,50 +83,53 @@ 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
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
/* Force display of overflow menu - from stackoverflow
|
/* Force display of overflow menu - from stackoverflow
|
||||||
* "how to force use of..."
|
* "how to force use of..."
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
ViewConfiguration config = ViewConfiguration.get(this);
|
ViewConfiguration config = ViewConfiguration.get(this);
|
||||||
Field menuKeyField =
|
Field menuKeyField =
|
||||||
ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
|
ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
|
||||||
if (menuKeyField!=null) {
|
if (menuKeyField != null) {
|
||||||
menuKeyField.setAccessible(true);
|
menuKeyField.setAccessible(true);
|
||||||
menuKeyField.setBoolean(config,false);
|
menuKeyField.setBoolean(config, false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.v(TAG,"menubar fiddle exception: "+e.toString());
|
Log.v(TAG, "menubar fiddle exception: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force the screen to stay on when the app is running
|
// Force the screen to stay on when the app is running
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
// Deal with the 'AcceptAlarm Button'
|
// Deal with the 'AcceptAlarm Button'
|
||||||
Button button = (Button) findViewById(R.id.acceptAlarmButton);
|
Button button = (Button) findViewById(R.id.acceptAlarmButton);
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Log.v(TAG, "acceptAlarmButton.onClick()");
|
Log.v(TAG, "acceptAlarmButton.onClick()");
|
||||||
if (mBound) {
|
if (mBound) {
|
||||||
mSdServer.acceptAlarm();
|
mSdServer.acceptAlarm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// start timer to refresh user interface every second.
|
// start timer to refresh user interface every second.
|
||||||
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() {
|
||||||
}, 0, 1000);
|
updateServerStatus();
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,153 +137,158 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Log.v(TAG,"Option "+item.getItemId()+" selected");
|
Log.v(TAG, "Option " + item.getItemId() + " selected");
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_launch_pebble_app:
|
case R.id.action_launch_pebble_app:
|
||||||
Log.v(TAG,"action_launch_pebble_app");
|
Log.v(TAG, "action_launch_pebble_app");
|
||||||
try {
|
try {
|
||||||
PackageManager pm = this.getPackageManager();
|
PackageManager pm = this.getPackageManager();
|
||||||
Intent pebbleAppIntent = pm.getLaunchIntentForPackage("com.getpebble.android");
|
Intent pebbleAppIntent = pm.getLaunchIntentForPackage("com.getpebble.android");
|
||||||
this.startActivity(pebbleAppIntent);
|
this.startActivity(pebbleAppIntent);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.v(TAG,"exception starting pebble App "+ex.toString());
|
Log.v(TAG, "exception starting pebble App " + ex.toString());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_accept_alarm:
|
case R.id.action_accept_alarm:
|
||||||
Log.v(TAG,"action_accept_alarm");
|
Log.v(TAG, "action_accept_alarm");
|
||||||
if (mBound) {
|
if (mBound) {
|
||||||
mSdServer.acceptAlarm();
|
mSdServer.acceptAlarm();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_start_stop:
|
||||||
|
// Respond to the start/stop server menu item.
|
||||||
|
Log.v(TAG, "action_sart_stop");
|
||||||
|
if (mBound) {
|
||||||
|
Log.v(TAG, "Stopping Server");
|
||||||
|
unbindFromServer();
|
||||||
|
stopServer();
|
||||||
|
} else {
|
||||||
|
Log.v(TAG, "Starting Server");
|
||||||
|
startServer();
|
||||||
|
// and bind to it so we can see its data
|
||||||
|
bindToServer();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_test_fault_beep:
|
||||||
|
Log.v(TAG, "action_test_fault_beep");
|
||||||
|
if (mBound) {
|
||||||
|
mSdServer.faultWarningBeep();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_test_alarm_beep:
|
||||||
|
Log.v(TAG, "action_test_alarm_beep");
|
||||||
|
if (mBound) {
|
||||||
|
mSdServer.alarmBeep();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_test_warning_beep:
|
||||||
|
Log.v(TAG, "action_test_warning_beep");
|
||||||
|
if (mBound) {
|
||||||
|
mSdServer.warningBeep();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_test_sms_alarm:
|
||||||
|
Log.v(TAG, "action_test_sms_alarm");
|
||||||
|
if (mBound) {
|
||||||
|
mSdServer.sendSMSAlarm();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_settings:
|
||||||
|
Log.v(TAG, "action_settings");
|
||||||
|
try {
|
||||||
|
Intent prefsIntent = new Intent(
|
||||||
|
MainActivity.this,
|
||||||
|
PrefActivity.class);
|
||||||
|
this.startActivity(prefsIntent);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.v(TAG, "exception starting settings activity " + ex.toString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_about:
|
||||||
|
Log.v(TAG, "action_about");
|
||||||
|
showAbout();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
case R.id.action_start_stop:
|
|
||||||
// Respond to the start/stop server menu item.
|
|
||||||
Log.v(TAG,"action_sart_stop");
|
|
||||||
if (mBound) {
|
|
||||||
Log.v(TAG,"Stopping Server");
|
|
||||||
unbindFromServer();
|
|
||||||
stopServer();
|
|
||||||
} else {
|
|
||||||
Log.v(TAG,"Starting Server");
|
|
||||||
startServer();
|
|
||||||
// and bind to it so we can see its data
|
|
||||||
bindToServer();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_test_fault_beep:
|
|
||||||
Log.v(TAG,"action_test_fault_beep");
|
|
||||||
if (mBound) {
|
|
||||||
mSdServer.faultWarningBeep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_test_alarm_beep:
|
|
||||||
Log.v(TAG,"action_test_alarm_beep");
|
|
||||||
if (mBound) {
|
|
||||||
mSdServer.alarmBeep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_test_warning_beep:
|
|
||||||
Log.v(TAG,"action_test_warning_beep");
|
|
||||||
if (mBound) {
|
|
||||||
mSdServer.warningBeep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_test_sms_alarm:
|
|
||||||
Log.v(TAG,"action_test_sms_alarm");
|
|
||||||
if (mBound) {
|
|
||||||
mSdServer.sendSMSAlarm();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_settings:
|
|
||||||
Log.v(TAG,"action_settings");
|
|
||||||
try {
|
|
||||||
Intent prefsIntent = new Intent(
|
|
||||||
MainActivity.this,
|
|
||||||
PrefActivity.class);
|
|
||||||
this.startActivity(prefsIntent);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.v(TAG,"exception starting settings activity "+ex.toString());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
SharedPreferences SP = PreferenceManager
|
SharedPreferences SP = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getBaseContext());
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
boolean audibleAlarm = SP.getBoolean("AudibleAlarm",true);
|
boolean audibleAlarm = SP.getBoolean("AudibleAlarm", true);
|
||||||
Log.v(TAG,"onStart - auidbleAlarm = "+audibleAlarm);
|
Log.v(TAG, "onStart - auidbleAlarm = " + audibleAlarm);
|
||||||
|
|
||||||
TextView tv;
|
TextView tv;
|
||||||
tv = (TextView) findViewById(R.id.versionTv);
|
tv = (TextView) findViewById(R.id.versionTv);
|
||||||
String versionName = "unknown";
|
String versionName = "unknown";
|
||||||
// From http://stackoverflow.com/questions/4471025/
|
// From http://stackoverflow.com/questions/4471025/
|
||||||
// how-can-you-get-the-manifest-version-number-
|
// how-can-you-get-the-manifest-version-number-
|
||||||
// from-the-apps-layout-xml-variable
|
// from-the-apps-layout-xml-variable
|
||||||
final PackageManager packageManager = getPackageManager();
|
final PackageManager packageManager = getPackageManager();
|
||||||
if (packageManager != null) {
|
if (packageManager != null) {
|
||||||
try {
|
try {
|
||||||
PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
|
PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
|
||||||
versionName = packageInfo.versionName;
|
versionName = packageInfo.versionName;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
Log.v(TAG,"failed to find versionName");
|
Log.v(TAG, "failed to find versionName");
|
||||||
versionName = null;
|
versionName = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tv.setText("OpenSeizureDetector Server Version " + versionName);
|
tv.setText("OpenSeizureDetector Server Version " + versionName);
|
||||||
|
|
||||||
if (!isServerRunning()) {
|
if (!isServerRunning()) {
|
||||||
Log.v(TAG,"Server not Running - Starting Server");
|
Log.v(TAG, "Server not Running - Starting Server");
|
||||||
startServer();
|
startServer();
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG,"Server Already Running OK");
|
Log.v(TAG, "Server Already Running OK");
|
||||||
}
|
}
|
||||||
// and bind to it so we can see its data
|
// and bind to it so we can see its data
|
||||||
bindToServer();
|
bindToServer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
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
|
||||||
public void onServiceConnected(ComponentName className,
|
public void onServiceConnected(ComponentName className,
|
||||||
IBinder service) {
|
IBinder service) {
|
||||||
// We've bound to LocalService, cast the IBinder and get LocalService instance
|
// We've bound to LocalService, cast the IBinder and get LocalService instance
|
||||||
SdServer.SdBinder binder = (SdServer.SdBinder) service;
|
SdServer.SdBinder binder = (SdServer.SdBinder) service;
|
||||||
mSdServer = binder.getService();
|
mSdServer = binder.getService();
|
||||||
mBound = true;
|
mBound = true;
|
||||||
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!");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName arg0) {
|
public void onServiceDisconnected(ComponentName arg0) {
|
||||||
Log.v(TAG,"onServiceDisonnected()");
|
Log.v(TAG, "onServiceDisonnected()");
|
||||||
mBound = false;
|
mBound = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -288,68 +298,68 @@ public class MainActivity extends Activity
|
|||||||
* bind to an already running server.
|
* bind to an already running server.
|
||||||
*/
|
*/
|
||||||
private void bindToServer() {
|
private void bindToServer() {
|
||||||
Log.v(TAG,"bindToServer() - binding to SdServer");
|
Log.v(TAG, "bindToServer() - binding to SdServer");
|
||||||
Intent intent = new Intent(this,SdServer.class);
|
Intent intent = new Intent(this, SdServer.class);
|
||||||
bindService(intent,mConnection, Context.BIND_AUTO_CREATE);
|
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unbind from server
|
* unbind from server
|
||||||
*/
|
*/
|
||||||
private void unbindFromServer() {
|
private void unbindFromServer() {
|
||||||
// unbind this activity from the service if it is bound.
|
// unbind this activity from the service if it is bound.
|
||||||
if (mBound) {
|
if (mBound) {
|
||||||
Log.v(TAG,"unbindFromServer() - unbinding");
|
Log.v(TAG, "unbindFromServer() - unbinding");
|
||||||
try {
|
try {
|
||||||
unbindService(mConnection);
|
unbindService(mConnection);
|
||||||
mBound = false;
|
mBound = false;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e(TAG,"unbindFromServer() - error unbinding service - "+ex.toString());
|
Log.e(TAG, "unbindFromServer() - error unbinding service - " + ex.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG,"unbindFromServer() - not bound to server - ignoring");
|
Log.v(TAG, "unbindFromServer() - not bound to server - ignoring");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the SdServer service
|
* Start the SdServer service
|
||||||
*/
|
*/
|
||||||
private void startServer() {
|
private void startServer() {
|
||||||
// Start the server
|
// Start the server
|
||||||
sdServerIntent = new Intent(MainActivity.this,SdServer.class);
|
sdServerIntent = new Intent(MainActivity.this, SdServer.class);
|
||||||
sdServerIntent.setData(Uri.parse("Start"));
|
sdServerIntent.setData(Uri.parse("Start"));
|
||||||
getApplicationContext().startService(sdServerIntent);
|
getApplicationContext().startService(sdServerIntent);
|
||||||
|
|
||||||
// Change the action bar icon to show the option to stop the service.
|
// Change the action bar icon to show the option to stop the service.
|
||||||
if (mOptionsMenu!=null) {
|
if (mOptionsMenu != null) {
|
||||||
Log.v(TAG,"Changing menu icons");
|
Log.v(TAG, "Changing menu icons");
|
||||||
MenuItem menuItem = mOptionsMenu.findItem(R.id.action_start_stop);
|
MenuItem menuItem = mOptionsMenu.findItem(R.id.action_start_stop);
|
||||||
menuItem.setIcon(R.drawable.stop_server);
|
menuItem.setIcon(R.drawable.stop_server);
|
||||||
menuItem.setTitle("Stop Server");
|
menuItem.setTitle("Stop Server");
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG,"mOptionsMenu is null - not changing icons!");
|
Log.v(TAG, "mOptionsMenu is null - not changing icons!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the SdServer service
|
* Stop the SdServer service
|
||||||
*/
|
*/
|
||||||
private void stopServer() {
|
private void stopServer() {
|
||||||
Log.v(TAG,"stopping Server...");
|
Log.v(TAG, "stopping Server...");
|
||||||
|
|
||||||
// then send an Intent to stop the service.
|
// then send an Intent to stop the service.
|
||||||
sdServerIntent = new Intent(MainActivity.this,SdServer.class);
|
sdServerIntent = new Intent(MainActivity.this, SdServer.class);
|
||||||
sdServerIntent.setData(Uri.parse("Stop"));
|
sdServerIntent.setData(Uri.parse("Stop"));
|
||||||
getApplicationContext().stopService(sdServerIntent);
|
getApplicationContext().stopService(sdServerIntent);
|
||||||
|
|
||||||
// Change the action bar icon to show the option to start the service.
|
// Change the action bar icon to show the option to start the service.
|
||||||
if (mOptionsMenu!=null) {
|
if (mOptionsMenu != null) {
|
||||||
Log.v(TAG,"Changing action bar icons");
|
Log.v(TAG, "Changing action bar icons");
|
||||||
mOptionsMenu.findItem(R.id.action_start_stop).setIcon(R.drawable.start_server);
|
mOptionsMenu.findItem(R.id.action_start_stop).setIcon(R.drawable.start_server);
|
||||||
mOptionsMenu.findItem(R.id.action_start_stop).setTitle("Start Server");
|
mOptionsMenu.findItem(R.id.action_start_stop).setTitle("Start Server");
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG,"mOptionsMenu is null, not changing icons!");
|
Log.v(TAG, "mOptionsMenu is null, not changing icons!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,62 +367,62 @@ public class MainActivity extends Activity
|
|||||||
* Based on http://stackoverflow.com/questions/7440473/android-how-to-check-if-the-intent-service-is-still-running-or-has-stopped-running
|
* Based on http://stackoverflow.com/questions/7440473/android-how-to-check-if-the-intent-service-is-still-running-or-has-stopped-running
|
||||||
*/
|
*/
|
||||||
public boolean isServerRunning() {
|
public boolean isServerRunning() {
|
||||||
//Log.v(TAG,"isServerRunning()................");
|
//Log.v(TAG,"isServerRunning()................");
|
||||||
ActivityManager manager =
|
ActivityManager manager =
|
||||||
(ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
(ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||||
for (RunningServiceInfo service :
|
for (RunningServiceInfo service :
|
||||||
manager.getRunningServices(Integer.MAX_VALUE)) {
|
manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||||
//Log.v(TAG,"Service: "+service.service.getClassName());
|
//Log.v(TAG,"Service: "+service.service.getClassName());
|
||||||
if ("uk.org.openseizuredetector.SdServer"
|
if ("uk.org.openseizuredetector.SdServer"
|
||||||
.equals(service.service.getClassName())) {
|
.equals(service.service.getClassName())) {
|
||||||
//Log.v(TAG,"Yes!");
|
//Log.v(TAG,"Yes!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Log.v(TAG,"No!");
|
//Log.v(TAG,"No!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 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() {
|
||||||
try {
|
try {
|
||||||
for (Enumeration<NetworkInterface> en = NetworkInterface
|
for (Enumeration<NetworkInterface> en = NetworkInterface
|
||||||
.getNetworkInterfaces(); en.hasMoreElements();) {
|
.getNetworkInterfaces(); en.hasMoreElements(); ) {
|
||||||
NetworkInterface intf = en.nextElement();
|
NetworkInterface intf = en.nextElement();
|
||||||
for (Enumeration<InetAddress> enumIpAddr = intf
|
for (Enumeration<InetAddress> enumIpAddr = intf
|
||||||
.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
|
||||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||||
//Log.v(TAG,"ip1--:" + inetAddress);
|
//Log.v(TAG,"ip1--:" + inetAddress);
|
||||||
//Log.v(TAG,"ip2--:" + inetAddress.getHostAddress());
|
//Log.v(TAG,"ip2--:" + inetAddress.getHostAddress());
|
||||||
|
|
||||||
// for getting IPV4 format
|
// for getting IPV4 format
|
||||||
if (!inetAddress.isLoopbackAddress()
|
if (!inetAddress.isLoopbackAddress()
|
||||||
&& InetAddressUtils.isIPv4Address(
|
&& InetAddressUtils.isIPv4Address(
|
||||||
inetAddress.getHostAddress())) {
|
inetAddress.getHostAddress())) {
|
||||||
|
|
||||||
String ip = inetAddress.getHostAddress().toString();
|
String ip = inetAddress.getHostAddress().toString();
|
||||||
//Log.v(TAG,"ip---::" + ip);
|
//Log.v(TAG,"ip---::" + ip);
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e("IP Address", ex.toString());
|
Log.e("IP Address", ex.toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
private void updateServerStatus() {
|
private void updateServerStatus() {
|
||||||
serverStatusHandler.post(serverStatusRunnable);
|
serverStatusHandler.post(serverStatusRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -420,131 +430,131 @@ public class MainActivity extends Activity
|
|||||||
* user interface to reflect the current status received from the server.
|
* user interface to reflect the current status received from the server.
|
||||||
*/
|
*/
|
||||||
final Runnable serverStatusRunnable = new Runnable() {
|
final Runnable serverStatusRunnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
TextView tv;
|
TextView tv;
|
||||||
tv = (TextView) findViewById(R.id.textView1);
|
tv = (TextView) findViewById(R.id.textView1);
|
||||||
if (isServerRunning()) {
|
if (isServerRunning()) {
|
||||||
tv.setText("Server Running OK");
|
tv.setText("Server Running OK");
|
||||||
tv.setBackgroundColor(okColour);
|
tv.setBackgroundColor(okColour);
|
||||||
tv = (TextView)findViewById(R.id.textView2);
|
tv = (TextView) findViewById(R.id.textView2);
|
||||||
tv.setText("Access Server at http://"
|
tv.setText("Access Server at http://"
|
||||||
+getLocalIpAddress()
|
+ getLocalIpAddress()
|
||||||
+":8080");
|
+ ":8080");
|
||||||
tv.setBackgroundColor(okColour);
|
tv.setBackgroundColor(okColour);
|
||||||
} else {
|
} else {
|
||||||
tv.setText("*** Server Stopped ***");
|
tv.setText("*** Server Stopped ***");
|
||||||
tv.setBackgroundColor(alarmColour);
|
tv.setBackgroundColor(alarmColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mBound) {
|
if (mBound) {
|
||||||
tv = (TextView) findViewById(R.id.alarmTv);
|
tv = (TextView) findViewById(R.id.alarmTv);
|
||||||
if ((mSdServer.mSdData.alarmState==0)
|
if ((mSdServer.mSdData.alarmState == 0)
|
||||||
&& !mSdServer.mSdData.alarmStanding
|
&& !mSdServer.mSdData.alarmStanding
|
||||||
&& !mSdServer.mSdData.fallAlarmStanding) {
|
&& !mSdServer.mSdData.fallAlarmStanding) {
|
||||||
tv.setText("OK");
|
tv.setText("OK");
|
||||||
tv.setBackgroundColor(okColour);
|
tv.setBackgroundColor(okColour);
|
||||||
}
|
}
|
||||||
if ((mSdServer.mSdData.alarmState==1)
|
if ((mSdServer.mSdData.alarmState == 1)
|
||||||
&& !mSdServer.mSdData.alarmStanding
|
&& !mSdServer.mSdData.alarmStanding
|
||||||
&& !mSdServer.mSdData.fallAlarmStanding) {
|
&& !mSdServer.mSdData.fallAlarmStanding) {
|
||||||
tv.setText("WARNING");
|
tv.setText("WARNING");
|
||||||
tv.setBackgroundColor(warnColour);
|
tv.setBackgroundColor(warnColour);
|
||||||
}
|
}
|
||||||
if (mSdServer.mSdData.alarmStanding) {
|
if (mSdServer.mSdData.alarmStanding) {
|
||||||
tv.setText("**ALARM**");
|
tv.setText("**ALARM**");
|
||||||
tv.setBackgroundColor(alarmColour);
|
tv.setBackgroundColor(alarmColour);
|
||||||
}
|
}
|
||||||
if (mSdServer.mSdData.fallAlarmStanding) {
|
if (mSdServer.mSdData.fallAlarmStanding) {
|
||||||
tv.setText("**FALL**");
|
tv.setText("**FALL**");
|
||||||
tv.setBackgroundColor(alarmColour);
|
tv.setBackgroundColor(alarmColour);
|
||||||
|
}
|
||||||
|
tv = (TextView) findViewById(R.id.pebTimeTv);
|
||||||
|
tv.setText(mSdServer.mSdData.dataTime.format("%H:%M:%S"));
|
||||||
|
// Pebble Connected Phrase
|
||||||
|
tv = (TextView) findViewById(R.id.pebbleTv);
|
||||||
|
if (mSdServer.mSdData.pebbleConnected) {
|
||||||
|
tv.setText("Pebble Watch Connected OK");
|
||||||
|
tv.setBackgroundColor(okColour);
|
||||||
|
} else {
|
||||||
|
tv.setText("** Pebble Watch NOT Connected **");
|
||||||
|
tv.setBackgroundColor(alarmColour);
|
||||||
|
}
|
||||||
|
tv = (TextView) findViewById(R.id.appTv);
|
||||||
|
if (mSdServer.mSdData.pebbleAppRunning) {
|
||||||
|
tv.setText("Pebble App OK");
|
||||||
|
tv.setBackgroundColor(okColour);
|
||||||
|
} else {
|
||||||
|
tv.setText("** Pebble App NOT Running **");
|
||||||
|
tv.setBackgroundColor(alarmColour);
|
||||||
|
}
|
||||||
|
tv = (TextView) findViewById(R.id.battTv);
|
||||||
|
tv.setText("Pebble Battery = " + String.valueOf(mSdServer.mSdData.batteryPc) + "%");
|
||||||
|
if (mSdServer.mSdData.batteryPc <= 20)
|
||||||
|
tv.setBackgroundColor(alarmColour);
|
||||||
|
if (mSdServer.mSdData.batteryPc > 20)
|
||||||
|
tv.setBackgroundColor(warnColour);
|
||||||
|
if (mSdServer.mSdData.batteryPc >= 40)
|
||||||
|
tv.setBackgroundColor(okColour);
|
||||||
|
|
||||||
|
tv = (TextView) findViewById(R.id.debugTv);
|
||||||
|
String specStr = "";
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
specStr = specStr
|
||||||
|
+ mSdServer.mSdData.simpleSpec[i]
|
||||||
|
+ ", ";
|
||||||
|
tv.setText("Spec = " + specStr);
|
||||||
|
} else {
|
||||||
|
tv = (TextView) findViewById(R.id.alarmTv);
|
||||||
|
tv.setText("Not Connected to Server");
|
||||||
|
tv.setBackgroundColor(warnColour);
|
||||||
}
|
}
|
||||||
tv = (TextView) findViewById(R.id.pebTimeTv);
|
} catch (Exception e) {
|
||||||
tv.setText(mSdServer.mSdData.dataTime.format("%H:%M:%S"));
|
Log.v(TAG, "ServerStatusRunnable: Exception - " + e.toString());
|
||||||
// Pebble Connected Phrase
|
}
|
||||||
tv = (TextView) findViewById(R.id.pebbleTv);
|
////////////////////////////////////////////////////////////
|
||||||
if (mSdServer.mSdData.pebbleConnected) {
|
// Produce graph
|
||||||
tv.setText("Pebble Watch Connected OK");
|
LineChart mChart = (LineChart) findViewById(R.id.chart1);
|
||||||
tv.setBackgroundColor(okColour);
|
mChart.setDescription("");
|
||||||
} else {
|
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||||
tv.setText("** Pebble Watch NOT Connected **");
|
// X Values
|
||||||
tv.setBackgroundColor(alarmColour);
|
ArrayList<String> xVals = new ArrayList<String>();
|
||||||
}
|
for (int i = 0; i < 10; i++) {
|
||||||
tv = (TextView) findViewById(R.id.appTv);
|
xVals.add((i) + "");
|
||||||
if (mSdServer.mSdData.pebbleAppRunning) {
|
}
|
||||||
tv.setText("Pebble App OK");
|
// Y Values
|
||||||
tv.setBackgroundColor(okColour);
|
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||||
} else {
|
for (int i = 0; i < 10; i++) {
|
||||||
tv.setText("** Pebble App NOT Running **");
|
if (mSdServer != null)
|
||||||
tv.setBackgroundColor(alarmColour);
|
yVals.add(new Entry(mSdServer.mSdData.simpleSpec[i], i));
|
||||||
}
|
else
|
||||||
tv = (TextView) findViewById(R.id.battTv);
|
yVals.add(new Entry(i, i));
|
||||||
tv.setText("Pebble Battery = "+String.valueOf(mSdServer.mSdData.batteryPc)+"%");
|
}
|
||||||
if (mSdServer.mSdData.batteryPc<=20)
|
|
||||||
tv.setBackgroundColor(alarmColour);
|
|
||||||
if (mSdServer.mSdData.batteryPc>20)
|
|
||||||
tv.setBackgroundColor(warnColour);
|
|
||||||
if (mSdServer.mSdData.batteryPc>=40)
|
|
||||||
tv.setBackgroundColor(okColour);
|
|
||||||
|
|
||||||
tv = (TextView) findViewById(R.id.debugTv);
|
// create a dataset and give it a type
|
||||||
String specStr = "";
|
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||||
for (int i=0;i<10;i++)
|
set1.setColor(Color.BLACK);
|
||||||
specStr = specStr
|
set1.setLineWidth(1f);
|
||||||
+ mSdServer.mSdData.simpleSpec[i]
|
|
||||||
+ ", ";
|
|
||||||
tv.setText("Spec = "+specStr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tv = (TextView) findViewById(R.id.alarmTv);
|
|
||||||
tv.setText("Not Connected to Server");
|
|
||||||
tv.setBackgroundColor(warnColour);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v(TAG,"ServerStatusRunnable: Exception - "+e.toString());
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
// Produce graph
|
|
||||||
LineChart mChart = (LineChart) findViewById(R.id.chart1);
|
|
||||||
mChart.setDescription("");
|
|
||||||
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
|
||||||
// X Values
|
|
||||||
ArrayList<String> xVals = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
xVals.add((i) + "");
|
|
||||||
}
|
|
||||||
// Y Values
|
|
||||||
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
if (mSdServer!=null)
|
|
||||||
yVals.add(new Entry(mSdServer.mSdData.simpleSpec[i], i));
|
|
||||||
else
|
|
||||||
yVals.add(new Entry(i, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a dataset and give it a type
|
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
dataSets.add(set1); // add the datasets
|
||||||
set1.setColor(Color.BLACK);
|
LineData data = new LineData(xVals, dataSets);
|
||||||
set1.setLineWidth(1f);
|
//data.setValueTextSize(10f);
|
||||||
|
mChart.setData(data);
|
||||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
mChart.invalidate();
|
||||||
dataSets.add(set1); // add the datasets
|
}
|
||||||
LineData data = new LineData(xVals, dataSets);
|
};
|
||||||
//data.setValueTextSize(10f);
|
|
||||||
mChart.setData(data);
|
|
||||||
mChart.invalidate();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void updateUi() {
|
//public void updateUi() {
|
||||||
@@ -553,10 +563,41 @@ 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
|
||||||
Log.v(TAG,"Message="+message.toString());
|
public void handleMessage(Message message) {
|
||||||
}
|
Log.v(TAG, "Message=" + message.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
59
app/src/main/res/layout/about_layout.xml
Normal file
59
app/src/main/res/layout/about_layout.xml
Normal 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>
|
||||||
@@ -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:icon="@drawable/stop_server"
|
android:id="@+id/action_launch_pebble_app"
|
||||||
android:title="Launch Pebble App"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Launch Pebble App" />
|
||||||
|
|
||||||
<item android:id="@+id/action_start_stop"
|
<item
|
||||||
android:icon="@drawable/stop_server"
|
android:id="@+id/action_start_stop"
|
||||||
android:title="Stop Server"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Stop Server" />
|
||||||
|
|
||||||
<item android:id="@+id/action_test_fault_beep"
|
<item
|
||||||
android:icon="@drawable/stop_server"
|
android:id="@+id/action_test_fault_beep"
|
||||||
android:title="Test Fault Beep"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Test Fault Beep" />
|
||||||
|
|
||||||
<item android:id="@+id/action_test_alarm_beep"
|
<item
|
||||||
android:icon="@drawable/stop_server"
|
android:id="@+id/action_test_alarm_beep"
|
||||||
android:title="Test Alarm Beep"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Test Alarm Beep" />
|
||||||
|
|
||||||
<item android:id="@+id/action_test_warning_beep"
|
<item
|
||||||
android:icon="@drawable/stop_server"
|
android:id="@+id/action_test_warning_beep"
|
||||||
android:title="Test Warning Beep"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Test Warning Beep" />
|
||||||
|
|
||||||
<item android:id="@+id/action_test_sms_alarm"
|
<item
|
||||||
android:icon="@drawable/stop_server"
|
android:id="@+id/action_test_sms_alarm"
|
||||||
android:title="Test SMS Alarm Notification"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
/>
|
android:title="Test SMS Alarm Notification" />
|
||||||
|
|
||||||
|
|
||||||
<item android:id="@+id/action_settings"
|
<item
|
||||||
android:icon="@drawable/ic_action_settings"
|
android:id="@+id/action_settings"
|
||||||
android:title="Settings"
|
android:icon="@drawable/ic_action_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:showAsAction="never|withText"
|
||||||
android:title="Watch Settings"
|
android:title="About..." />
|
||||||
android:showAsAction="never|withText"
|
|
||||||
/>
|
</menu>
|
||||||
-->
|
|
||||||
</menu>
|
|
||||||
|
|||||||
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal 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>
|
||||||
5
app/src/main/res/values/dimens.xml
Normal file
5
app/src/main/res/values/dimens.xml
Normal 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>
|
||||||
Reference in New Issue
Block a user