Added 'Raise Alarm' button on main screen

This commit is contained in:
Graham Jones
2022-01-10 16:31:25 +00:00
parent ee2e5042ec
commit ef27ba430d
5 changed files with 56 additions and 4 deletions

View File

@@ -566,7 +566,7 @@ public class LogManager implements AuthCallbackInterface, EventCallbackInterface
return;
}
Log.v(TAG,"writeToRemoteServer(): calling UploadSdData()");
Log.d(TAG,"writeToRemoteServer(): calling UploadSdData()");
uploadSdData();
}

View File

@@ -25,7 +25,9 @@
package uk.org.openseizuredetector;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
@@ -158,6 +160,38 @@ public class MainActivity extends AppCompatActivity {
}
});
// Deal with the 'Raise Alarm'
button = (Button) findViewById(R.id.manualAlarmButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.v(TAG, "manualAlarmButton.onClick()");
// Confirmation dialog based on: https://stackoverflow.com/a/12213536/2104584
//AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
//builder.setTitle("Raise Alarm");
//builder.setMessage(String.format("Raise a Seizure Detected Alarm NOW?"));
//builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
if (mConnection.mBound) {
mConnection.mSdServer.raiseManualAlarm();
}
// dialog.dismiss();
// }
//});
//builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
//});
//AlertDialog alert = builder.create();
//if (!(this).isFinishing()) {
// alert.show();
//}
}
});
}

View File

@@ -520,6 +520,13 @@ public class SdServer extends Service implements SdDataReceiver {
}
}
public void raiseManualAlarm() {
Log.d(TAG,"raiseManualAlarm()");
SdData sdData = mSdData;
sdData.alarmState = 5;
onSdDataReceived(sdData);
}
/**
* Process the data received from the SdData source. On exit, the mSdData structure is populated with
* the appropriate data.

View File

@@ -116,19 +116,29 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:baselineAligned="false">
<Button
android:id="@+id/acceptAlarmButton"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/AcceptAlarmBtnTxt" />
<Button
android:id="@+id/cancelAudibleButton"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/CancelAudibleButtonTxt" />
<Button
android:id="@+id/manualAlarmButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#ff0000"
android:text="@string/ManualAlarmBtnTxt" />
</LinearLayout>
<com.github.mikephil.charting.charts.BarChart

View File

@@ -318,4 +318,5 @@
<string name="AutoPruneDbSummary">Automatically Prune (Trim) the Database periodically to prevent excessive storage capacity (memory) usage.</string>
<string name="remoteLogPeriodSummary">The period (in seconds) between attempts to upload data to the remote server. Each attempt only uploads a single event, not all the available data.</string>
<string name="remoteLogPeriodTitle">Remote Log Period (seconds)</string>
<string name="ManualAlarmBtnTxt">Raise Alarm</string>
</resources>