Added cancel audible button (was only present on client app, not server)

This commit is contained in:
Graham Jones
2015-12-08 18:53:43 +00:00
parent 9826fda1ba
commit fe7cd37896
3 changed files with 54 additions and 4 deletions

View File

@@ -127,6 +127,18 @@ public class MainActivity extends Activity {
}
});
// Deal with the 'Cancel Audible Button'
button = (Button) findViewById(R.id.cancelAudibleButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.v(TAG, "cancelAudibleButton.onClick()");
if (mConnection.mBound) {
mConnection.mSdServer.cancelAudible();
}
}
});
// start timer to refresh user interface every second.
Timer uiTimer = new Timer();
uiTimer.schedule(new TimerTask() {
@@ -402,6 +414,26 @@ public class MainActivity extends Activity {
} catch (Exception e) {
Log.v(TAG, "ServerStatusRunnable: Exception - " + e.toString());
}
// Deal with Cancel Audible button
Button cancelAudibleButton =
(Button) findViewById(R.id.cancelAudibleButton);
if (mConnection.mSdServer.isAudibleCancelled()) {
cancelAudibleButton.setText("Audible Alarms Cancelled "
+ "for "
+ mConnection.mSdServer.
cancelAudibleTimeRemaining()
+ " sec."
+ " Press to re-enable");
} else {
if (mConnection.mSdServer.mAudibleAlarm) {
cancelAudibleButton.setText("Cancel Audible Alarms (temporarily)");
} else {
cancelAudibleButton.setText("Audible Alarms OFF");
}
}
////////////////////////////////////////////////////////////
// Produce graph
LineChart mChart = (LineChart) findViewById(R.id.chart1);

View File

@@ -91,7 +91,7 @@ public class SdServer extends Service implements SdDataReceiver {
private String mSdDataSourceName = "undefined"; // The name of the data soruce specified in the preferences.
private boolean mLatchAlarms = false;
private boolean mCancelAudible = false;
private boolean mAudibleAlarm = false;
public boolean mAudibleAlarm = false;
private boolean mAudibleWarning = false;
private boolean mAudibleFaultWarning = false;
private boolean mSMSAlarm = false;
@@ -232,6 +232,15 @@ public class SdServer extends Service implements SdDataReceiver {
mSdDataSource.stop();
// Stop the data update timer
if (mCancelAudibleTimer !=null) {
Log.v(TAG,"stop(): cancelling Cancel_Audible timer");
mCancelAudibleTimer.cancel();
//mCancelAudibleTimer.purge();
mCancelAudibleTimer = null;
}
try {
// Cancel the notification.
Log.v(TAG, "onDestroy(): cancelling notification");

View File

@@ -113,11 +113,20 @@
android:id="@+id/spectrumProgressBar"
android:indeterminate="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Accept Alarm"
android:id="@+id/acceptAlarmButton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel Audible (temporarily)"
android:id="@+id/cancelAudibleButton" />
</LinearLayout>
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/chart1"