diff --git a/app/release/app-release-3.0.4.apk b/app/release/app-release-3.0.4.apk new file mode 100644 index 0000000..9ccc4c7 Binary files /dev/null and b/app/release/app-release-3.0.4.apk differ diff --git a/app/release/output.json b/app/release/output.json index ab2fe44..249dfaf 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":52,"versionName":"3.0.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":53,"versionName":"3.0.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 174c257..4e191d3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ diff --git a/app/src/main/java/uk/org/openseizuredetector/MainActivity.java b/app/src/main/java/uk/org/openseizuredetector/MainActivity.java index e989387..9cd363a 100644 --- a/app/src/main/java/uk/org/openseizuredetector/MainActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/MainActivity.java @@ -159,13 +159,12 @@ public class MainActivity extends AppCompatActivity { public boolean onCreateOptionsMenu(Menu menu) { Log.i(TAG, "onCreateOptionsMenu()"); getMenuInflater().inflate(R.menu.main_activity_actions, menu); - mOptionsMenu = menu; - if (mConnection.mSdServer.mSdDataSourceName != "Pebble") { - Log.v(TAG,"Disabling Pebble Specific Menu Items"); - menu.findItem(R.id.action_instal_watch_app).setEnabled(false); - menu.findItem(R.id.action_launch_pebble_app).setEnabled(false); - - } + //mOptionsMenu = menu; + //if (mConnection.mSdServer.mSdDataSourceName != "Pebble") { + // Log.v(TAG,"Disabling Pebble Specific Menu Items"); + // menu.findItem(R.id.action_instal_watch_app).setEnabled(false); + // menu.findItem(R.id.action_launch_pebble_app).setEnabled(false); + //} return true; } @@ -173,15 +172,17 @@ public class MainActivity extends AppCompatActivity { public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, "onOptionsItemSelected() : " + item.getItemId() + " selected"); switch (item.getItemId()) { - case R.id.action_launch_pebble_app: + /*case R.id.action_launch_pebble_app: Log.i(TAG, "action_launch_pebble_app"); mConnection.mSdServer.mSdDataSource.startPebbleApp(); return true; - case R.id.action_instal_watch_app: + */ + case R.id.action_install_watch_app: Log.i(TAG, "action_install_watch_app"); mConnection.mSdServer.mSdDataSource.installWatchApp(); + return true; - case R.id.action_accept_alarm: + case R.id.action_accept_alarm: Log.i(TAG, "action_accept_alarm"); if (mConnection.mBound) { mConnection.mSdServer.acceptAlarm(); @@ -281,10 +282,13 @@ public class MainActivity extends AppCompatActivity { String versionName = mUtil.getAppVersionName(); tv.setText("OpenSeizureDetector Android App Version " + versionName); - Log.i(TAG,"onStart() - binding to server"); - mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server"); - mUtil.bindToServer(this, mConnection); - + if (mUtil.isServerRunning()) { + mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server"); + mUtil.bindToServer(this, mConnection); + } else { + Log.i(TAG,"onStart() - Server Not Running"); + mUtil.writeToSysLogFile("MainActivity.onStart - Server Not Running"); + } // start timer to refresh user interface every second. mUiTimer = new Timer(); mUiTimer.schedule(new TimerTask() { @@ -395,21 +399,11 @@ public class MainActivity extends AppCompatActivity { tv.setBackgroundColor(warnColour); tv.setTextColor(warnTextColour); } - if (mConnection.mSdServer.mSdData.alarmState == 4) { - tv.setText("FAULT"); - tv.setBackgroundColor(warnColour); - tv.setTextColor(warnTextColour); - } if (mConnection.mSdServer.mSdData.alarmState == 6) { tv.setText("MUTE"); tv.setBackgroundColor(warnColour); tv.setTextColor(warnTextColour); } - if (mConnection.mSdServer.mSdData.alarmState == 7) { - tv.setText("NET FAULT"); - tv.setBackgroundColor(warnColour); - tv.setTextColor(warnTextColour); - } if (mConnection.mSdServer.mSdData.alarmStanding) { tv.setText("**ALARM**"); tv.setBackgroundColor(alarmColour); @@ -420,6 +414,7 @@ public class MainActivity extends AppCompatActivity { tv.setBackgroundColor(alarmColour); tv.setTextColor(alarmTextColour); } + tv = (TextView) findViewById(R.id.pebTimeTv); tv.setText(mConnection.mSdServer.mSdData.dataTime.format("%H:%M:%S")); tv.setBackgroundColor(okColour); @@ -526,12 +521,79 @@ public class MainActivity extends AppCompatActivity { pbDrawable = getResources().getDrawable(R.drawable.progress_bar_red); //pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN); pb.setProgressDrawable(pbDrawable); + + + + // Fault Conditions - We override the values in the UI because we do not know + // if the stored ones are correct or not with a fault present. + if ((mConnection.mSdServer.mSdData.alarmState == 4) || + (mConnection.mSdServer.mSdData.alarmState == 7)) { + tv = (TextView) findViewById(R.id.alarmTv); + if (mConnection.mSdServer.mSdData.alarmState == 4) { + tv.setText("FAULT"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + } + if (mConnection.mSdServer.mSdData.alarmState == 7) { + tv.setText("NET FAULT"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + } + tv = (TextView) findViewById(R.id.pebTimeTv); + tv.setText(mConnection.mSdServer.mSdData.dataTime.format("%H:%M:%S")); + tv.setBackgroundColor(okColour); + tv.setTextColor(okTextColour); + + tv = (TextView) findViewById(R.id.pebTimeTv); + tv.setText("--:--:--"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.pebbleTv); + tv.setText("HR = ---"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.appTv); + tv.setText("Watch App -----"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.battTv); + tv.setText("Watch Battery = ---%"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + } + } else { // Not bound to server tv = (TextView) findViewById(R.id.alarmTv); tv.setText("------"); tv.setBackgroundColor(warnColour); tv.setTextColor(warnTextColour); + tv = (TextView) findViewById(R.id.pebTimeTv); + tv.setText(mConnection.mSdServer.mSdData.dataTime.format("%H:%M:%S")); + tv.setBackgroundColor(okColour); + tv.setTextColor(okTextColour); + tv = (TextView) findViewById(R.id.pebTimeTv); + tv.setText("--:--:--"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.pebbleTv); + tv.setText("HR = ---"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.appTv); + tv.setText("Watch App -----"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + + tv = (TextView) findViewById(R.id.battTv); + tv.setText("Watch Battery = ---%"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); } } catch (Exception e) { Log.e(TAG, "ServerStatusRunnable: Exception - "); diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java index 2dbd45f..3aba1ef 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java @@ -24,6 +24,8 @@ package uk.org.openseizuredetector; import android.content.Context; +import android.content.Intent; +import android.net.Uri; import android.os.Handler; import android.util.Log; import android.widget.Toast; @@ -81,7 +83,17 @@ public abstract class SdDataSource { /** * Install the watch app on the watch. */ - public void installWatchApp() { Log.v(TAG,"installWatchApp"); } + public void installWatchApp() { + Log.v(TAG,"installWatchApp"); + try { + String url = "http://www.openseizuredetector.org.uk/?page_id=1207"; + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(url)); + mContext.startActivity(i); + } catch (Exception ex) { + Log.i(TAG, "exception starting install watch app activity " + ex.toString()); + } + } public void startPebbleApp() { Log.v(TAG,"startPebbleApp()"); } diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourcePebble.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourcePebble.java index 06d8838..ed2b109 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourcePebble.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourcePebble.java @@ -739,52 +739,6 @@ public class SdDataSourcePebble extends SdDataSource { nRawData = 0; } - /** - * Install the wach app that is bundled in the 'assets' folder of this - * phone app. - * from https://github.com/pebble-examples/pebblekit-android-example/blob/master/android/Eclipse/src/com/getpebble/pebblekitexample/MainActivity.java#L148 - */ - @Override - public void installWatchApp() { - Log.v(TAG, "SdDataSourcePebble.installWatchApp()"); - mUtil.writeToSysLogFile("SdDataSourcePebble.installWatchApp()"); - final String WATCHAPP_FILENAME = "pebble_sd.pbw"; - - try { - // Read .pbw from assets/ - Intent intent = new Intent(Intent.ACTION_VIEW); - File file = new File(mContext.getExternalFilesDir(null), WATCHAPP_FILENAME); - InputStream is = mContext.getResources().getAssets().open(WATCHAPP_FILENAME); - OutputStream os = new FileOutputStream(file); - byte[] pbw = new byte[is.available()]; - is.read(pbw); - os.write(pbw); - is.close(); - os.close(); - - // Install via Pebble Android app - intent.setDataAndType(Uri.fromFile(file), "application/pbw"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(intent); - } catch (IOException e) { - mUtil.writeToSysLogFile("SdDataSourcePebble.installWatchApp() - app install failed"+e.toString()); - Toast.makeText(mContext, "App install failed: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); - } - - } - - /** - * Install the OpenSeizureDetector watch app onto the watch from Pebble AppStore - * based on https://forums.getpebble.com/discussion/13128/install-watch-app-pebble-store-from-android-companion-app - */ - public void installWatchAppFromPebbleAppStore() { - Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("pebble://appstore/54d28a43e4d94c043f000008")); - myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(myIntent); - } - - - /** * Open Pebble or Pebble Time app. If it is not installed, open Play store so the user can install it. diff --git a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java index b6e0515..dd6d3e6 100644 --- a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java @@ -501,6 +501,7 @@ public class StartupActivity extends Activity { + "http://openseizuredetector.org.uk, or the app Facebook page at https://www.facebook.com/openseizuredetector. " + "so I can get in touch if necessary.\nThank you! Graham \ngraham@openseizuredetector.org.uk " + "\n\nChanges in this version:" + + "\n- V3.0.4 - Fixed issues with install watch app, and stopping server resulting in crashes" + "\n- V3.0.3 - Fixed problem with crash on phone boot if Auto Start on Boot option selected" + "\n- Upgraded to be compatible with Android Version 9" + "\n- Added support a Garmin based seizure detector with Heart Rate alarm " @@ -536,6 +537,7 @@ public class StartupActivity extends Activity { + "http://openseizuredetector.org.uk, or the app Facebook page at https://www.facebook.com/openseizuredetector. " + "so I can get in touch if necessary.\nThank you! Graham \ngraham@openseizuredetector.org.uk " + "\n\nChanges in this version:" + + "\n- V3.0.4 - Fixed issues with install watch app, and stopping server resulting in crashes" + "\n- V3.0.3 - Fixed problem with crash on phone boot if Auto Start on Boot option selected" + "\n- Upgraded to be compatible with Android Version 9" + "\n- Added support for a Garmin based seizure detector with Heart Rate alarm " diff --git a/app/src/main/res/menu/main_activity_actions.xml b/app/src/main/res/menu/main_activity_actions.xml index 9f74b14..9bcae6d 100644 --- a/app/src/main/res/menu/main_activity_actions.xml +++ b/app/src/main/res/menu/main_activity_actions.xml @@ -9,7 +9,7 @@ android:id="@+id/action_start_stop" android:icon="@drawable/stop_server" android:showAsAction="never|withText" - android:title="Stop Server" /> + android:title="Start/Stop Server" /> - - +--> diff --git a/build.gradle b/build.gradle index 073392b..54c91ac 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + classpath 'com.android.tools.build:gradle:3.3.2' } } allprojects {