diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java
index f1cf113..ccfc438 100644
--- a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java
+++ b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java
@@ -14,6 +14,7 @@ import android.text.format.Time;
public class FragmentCommon extends FragmentOsdBaseClass {
String TAG = "FragmentCommon";
+ private long mUiAlarmStartMillis = 0;
public FragmentCommon() {
// Required empty public constructor
@@ -79,6 +80,13 @@ public class FragmentCommon extends FragmentOsdBaseClass {
}
});
}
+ private String formatDuration(long elapsedMillis) {
+ long totalSeconds = elapsedMillis / 1000;
+ long minutes = totalSeconds / 60;
+ long seconds = totalSeconds % 60;
+
+ return String.format("%02d:%02d", minutes, seconds);
+ }
@Override
protected void updateUi() {
@@ -107,10 +115,23 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv = (TextView) mRootView.findViewById(R.id.alarmTv);
+ TextView durationTv = (TextView) mRootView.findViewById(R.id.seizureDurationTv);
+
+ boolean seizureAlarmActive = mConnection.mSdServer.mSdData.alarmStanding;
+ boolean fallAlarmActive = mConnection.mSdServer.mSdData.fallAlarmStanding;
+
+ if (!seizureAlarmActive && !fallAlarmActive) {
+ mUiAlarmStartMillis = 0;
+ if (durationTv != null) {
+ durationTv.setVisibility(View.GONE);
+ durationTv.setText("");
+ }
+ }
+
if ((mConnection.mSdServer.mSdData.alarmState == 0)
- && !mConnection.mSdServer.mSdData.alarmStanding
- && !mConnection.mSdServer.mSdData.fallAlarmStanding) {
- tv.setText(getString(R.string.okBtnTxt));
+ && !seizureAlarmActive
+ && !fallAlarmActive) {
+ tv.setText("Monitoring active");
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
}
@@ -126,13 +147,25 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour);
}
- if (mConnection.mSdServer.mSdData.alarmStanding) {
- tv.setText(getString(R.string.Alarm) + "\n" + mConnection.mSdServer.mSdData.alarmCause);
+ if (seizureAlarmActive) {
+ if (mUiAlarmStartMillis == 0) {
+ mUiAlarmStartMillis = System.currentTimeMillis();
+ }
+
+ tv.setText("SEIZURE DETECTED");
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
+
+ if (durationTv != null) {
+ long elapsedMillis = System.currentTimeMillis() - mUiAlarmStartMillis;
+ durationTv.setText("Seizure duration: " + formatDuration(elapsedMillis));
+ durationTv.setVisibility(View.VISIBLE);
+ durationTv.setBackgroundColor(alarmColour);
+ durationTv.setTextColor(alarmTextColour);
+ }
}
- if (mConnection.mSdServer.mSdData.fallAlarmStanding) {
- tv.setText(R.string.Fall);
+ if (fallAlarmActive) {
+ tv.setText("FALL DETECTED");
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
}
diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java b/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java
index 31ea009..76b0b68 100644
--- a/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java
+++ b/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java
@@ -89,6 +89,33 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_red);
pb.setProgressDrawable(pbDrawable);
+ TextView currentHrTv = (TextView) mRootView.findViewById(R.id.osd_current_hr_tv);
+ TextView avgHrTv = (TextView) mRootView.findViewById(R.id.osd_avg_hr_tv);
+ TextView hrStatusTv = (TextView) mRootView.findViewById(R.id.osd_hr_status_tv);
+
+ if (currentHrTv != null && avgHrTv != null && hrStatusTv != null) {
+ short currentHr = (short) mConnection.mSdServer.mSdData.mHR;
+ short avgHr = (short) mConnection.mSdServer.mSdData.mAdaptiveHrAverage;
+
+ if (currentHr > 0) {
+ currentHrTv.setText(currentHr + " bpm");
+ avgHrTv.setText(avgHr + " bpm");
+
+ if (mConnection.mSdServer.mSdData.mAdaptiveHrAlarmStanding) {
+ hrStatusTv.setText("Heart-rate alarm active");
+ hrStatusTv.setTextColor(Color.RED);
+ } else {
+ hrStatusTv.setText("Heart rate normal");
+ hrStatusTv.setTextColor(Color.WHITE);
+ }
+ } else {
+ currentHrTv.setText("-- bpm");
+ avgHrTv.setText("Avg --");
+ hrStatusTv.setText("Waiting for heart-rate data");
+ hrStatusTv.setTextColor(Color.GRAY);
+ }
+ }
+
((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
diff --git a/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java b/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java
index 575dec9..18ca5f7 100644
--- a/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java
+++ b/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java
@@ -9,6 +9,8 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
+import androidx.appcompat.app.ActionBar;
+import android.view.Gravity;
import android.content.Context;
import android.content.DialogInterface;
@@ -87,6 +89,27 @@ public class MainActivity2 extends AppCompatActivity {
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
mContext = this;
mHandler = new Handler();
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ TextView title = new TextView(this);
+ title.setText("FLOGA");
+ title.setTextColor(Color.BLACK);
+ title.setTextSize(22);
+ title.setGravity(Gravity.CENTER);
+ title.setPadding(48, 0, 0, 0);
+ title.setTypeface(null, android.graphics.Typeface.BOLD);
+
+ ActionBar.LayoutParams params = new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.MATCH_PARENT,
+ ActionBar.LayoutParams.MATCH_PARENT,
+ Gravity.CENTER
+ );
+
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayShowCustomEnabled(true);
+ actionBar.setCustomView(title, params);
+ }
}
/**
@@ -112,8 +135,7 @@ public class MainActivity2 extends AppCompatActivity {
TextView tv;
tv = (TextView) findViewById(R.id.versionTv);
- String versionName = mUtil.getAppVersionName();
- tv.setText(getString(R.string.AppTitleText) + " " + versionName);
+ tv.setText("FLOGA");
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
diff --git a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java
index 537c8dd..08a8aca 100644
--- a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java
+++ b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java
@@ -48,6 +48,8 @@ import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
+import androidx.appcompat.app.ActionBar;
+import android.view.Gravity;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
@@ -134,6 +136,26 @@ public class StartupActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate()");
setContentView(R.layout.startup_activity);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ TextView title = new TextView(this);
+ title.setText("FLOGA");
+ title.setTextColor(Color.BLACK);
+ title.setTextSize(22);
+ title.setGravity(Gravity.CENTER);
+ title.setPadding(48, 0, 0, 0);
+ title.setTypeface(null, android.graphics.Typeface.BOLD);
+
+ ActionBar.LayoutParams params = new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.MATCH_PARENT,
+ ActionBar.LayoutParams.MATCH_PARENT,
+ Gravity.CENTER
+ );
+
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayShowCustomEnabled(true);
+ actionBar.setCustomView(title, params);
+ }
// Set our custom uncaught exception handler to report issues.
//Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(StartupActivity.this));
@@ -269,7 +291,7 @@ public class StartupActivity extends AppCompatActivity {
String versionName = mUtil.getAppVersionName();
tv = (TextView) findViewById(R.id.appNameTv);
- tv.setText("OpenSeizureDetector V" + versionName);
+ tv.setText("Seizure monitoring");
// Display the DataSource name
SharedPreferences SP = PreferenceManager
@@ -285,6 +307,7 @@ public class StartupActivity extends AppCompatActivity {
} else {
tv.setText(String.format("%s = %s", getString(R.string.DataSource), mSdDataSourceName));
}
+ setStartupStatus("Checking app setup...");
if (mUtil.isServerRunning()) {
@@ -346,6 +369,12 @@ public class StartupActivity extends AppCompatActivity {
* If everything is ok, we close this activity and open the main user interface
* activity.
*/
+ private void setStartupStatus(String message) {
+ TextView statusTv = (TextView) findViewById(R.id.startupCurrentStatusTv);
+ if (statusTv != null) {
+ statusTv.setText(message);
+ }
+ }
final Runnable serverStatusRunnable = new Runnable() {
public void run() {
Boolean allOk = true;
@@ -438,6 +467,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setTextColor(alarmTextColour);
pb.setIndeterminate(true);
allOk = false;
+ setStartupStatus("Waiting for required permissions...");
requestPermissions(StartupActivity.this);
}
@@ -466,6 +496,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setTextColor(alarmTextColour);
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
+ setStartupStatus("Starting monitoring service...");
mMode = MODE_START_SERVER;
} else {
tv.setText(getString(R.string.ServerRunningOK));
@@ -500,6 +531,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
pb.setIndeterminate(true);
+ setStartupStatus("Connecting to monitoring service...");
allOk = false;
}
@@ -517,6 +549,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
pb.setIndeterminate(true);
+ setStartupStatus("Waiting for watch connection...");
allOk = false;
}
@@ -535,6 +568,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
pb.setIndeterminate(true);
+ setStartupStatus("Waiting for detector data...");
allOk = false;
}
@@ -553,6 +587,7 @@ public class StartupActivity extends AppCompatActivity {
tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour);
pb.setIndeterminate(true);
+ setStartupStatus("Waiting for detector data...");
allOk = false;
}
@@ -563,6 +598,7 @@ public class StartupActivity extends AppCompatActivity {
if (!mDialogDisplayed && !mBatteryOptDialogDisplayed) {
if (!mStartedMainActivity) {
Log.i(TAG, "serverStatusRunnable() - starting main activity...");
+ setStartupStatus("Ready. Opening dashboard...");
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - all checks ok - starting main activity.");
try {
Boolean useNewUi = SP.getBoolean("UseNewUi", true);
diff --git a/app/src/main/res/layout/activity_main2.xml b/app/src/main/res/layout/activity_main2.xml
index 9cda00c..14d043d 100644
--- a/app/src/main/res/layout/activity_main2.xml
+++ b/app/src/main/res/layout/activity_main2.xml
@@ -18,8 +18,8 @@
+ android:layout_height="0dp"
+ android:visibility="gone" />
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingTop="14dp"
+ android:paddingBottom="12dp">
+
+
+ android:layout_marginTop="8dp"
+ android:gravity="center"
+ android:text=""
+ android:textColor="@android:color/white"
+ android:textSize="18sp"
+ android:textStyle="bold"
+ android:visibility="gone" />
-
+
+ android:layout_marginTop="12dp"
+ android:orientation="vertical"
+ android:background="#1B222A"
+ android:padding="14dp"
+ android:visibility="gone">
-
+
+
+
+
+
+
+
-
+ android:orientation="horizontal"
+ android:visibility="gone">
+
+
+ android:text="---" />
-
+ android:layout_height="wrap_content"
+ android:text="---" />
-
+
-
-
-
-
-
-
-
+
-
-
-
+
+ android:layout_marginTop="14dp"
+ android:orientation="vertical">
+ android:layout_width="match_parent"
+ android:layout_height="52dp"
+ android:text="@string/AcceptAlarmBtnTxt"
+ android:textSize="15sp" />
+ android:layout_width="match_parent"
+ android:layout_height="52dp"
+ android:layout_marginTop="8dp"
+ android:text="@string/CancelAudibleButtonTxt"
+ android:textSize="15sp" />
-
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:layout_marginTop="8dp"
+ android:backgroundTint="#C62828"
+ android:text="@string/ManualAlarmBtnTxt"
+ android:textColor="@android:color/white"
+ android:textSize="16sp"
+ android:textStyle="bold" />
+
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_osdalg.xml b/app/src/main/res/layout/fragment_osdalg.xml
index f3d61d8..7ceb840 100644
--- a/app/src/main/res/layout/fragment_osdalg.xml
+++ b/app/src/main/res/layout/fragment_osdalg.xml
@@ -3,69 +3,228 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="#101418"
tools:context=".FragmentOsdBaseClass">
+ android:paddingStart="14dp"
+ android:paddingEnd="14dp"
+ android:paddingTop="12dp"
+ android:paddingBottom="12dp">
+ android:gravity="center"
+ android:text="Detection status"
+ android:textColor="@android:color/white"
+ android:textSize="21sp"
+ android:textStyle="bold" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+ android:id="@+id/osd_hr_status_tv"
+ android:layout_width="1dp"
+ android:layout_height="1dp"
+ android:visibility="gone"
+ android:text="Waiting for heart-rate data" />
+ android:layout_width="1dp"
+ android:layout_height="1dp"
+ android:visibility="gone"
+ android:text="@string/seizure_probability" />
-
+ android:layout_width="1dp"
+ android:layout_height="1dp"
+ android:visibility="gone" />
-
+ android:layout_width="1dp"
+ android:layout_height="1dp"
+ android:visibility="gone" />
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/startup_activity.xml b/app/src/main/res/layout/startup_activity.xml
index 6c81712..f9093cc 100644
--- a/app/src/main/res/layout/startup_activity.xml
+++ b/app/src/main/res/layout/startup_activity.xml
@@ -2,181 +2,240 @@
-
-
-
-
-
-
-
-
+ android:background="#101418"
+ android:fillViewport="true">
-
-
-
-
-
-
-
-
-
-
-
-
+ android:gravity="center_horizontal"
+ android:paddingStart="20dp"
+ android:paddingEnd="20dp"
+ android:paddingTop="32dp"
+ android:paddingBottom="24dp">
-
+
+
+
+
+
+
+ android:layout_marginTop="24dp"
+ android:gravity="center"
+ android:text="Getting monitoring ready..."
+ android:textColor="@android:color/white"
+ android:textSize="22sp"
+ android:textStyle="bold" />
-
+
-
-
+
+ android:layout_height="wrap_content"
+ android:layout_marginTop="18dp"
+ android:orientation="vertical"
+ android:background="#1B222A"
+ android:padding="14dp"
+ android:visibility="gone">
-
-
-
-
+ android:orientation="horizontal">
+
-
+
+
-
-
-
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:layout_marginTop="26dp"
+ android:gravity="center"
+ android:text="Taking too long?"
+ android:textColor="#B8C1CC"
+ android:textSize="14sp" />
-
-
-
-
+ android:layout_height="52dp"
+ android:layout_marginTop="8dp"
+ android:text="@string/edit_settings"
+ android:textSize="14sp" />
+
+
+
-
-
-
-
-
+
\ No newline at end of file