V2.5.4 - Added audio alarm notifications as an alternative to tone generator.

This commit is contained in:
Graham Jones
2017-12-03 19:32:29 +00:00
parent cbe5e49ad3
commit ef1c73905b
25 changed files with 34 additions and 7 deletions

View File

@@ -43,6 +43,8 @@ Logo based on ["Star of life2" by Verdy p - Own work. Licensed under Public Doma
Other icons crated using http://romannurik.github.io/AndroidAssetStudio. Other icons crated using http://romannurik.github.io/AndroidAssetStudio.
Audio Alarm sounds from freesound https://freesound.org/people/coltonmanz/sounds/381382/, https://freesound.org/people/NoiseCollector/sounds/4270/, https://freesound.org/people/pistak23/sounds/271632/
Graham Jones, 01 March 2015. (grahamjones139+sd@gmail.com)
Graham Jones, 03 December 2017. (grahamjones139+sd@gmail.com)

Binary file not shown.

Binary file not shown.

BIN
app/release/app-release.apk Normal file

Binary file not shown.

1
app/release/output.json Normal file
View File

@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":38},"path":"app-release.apk","properties":{"packageId":"uk.org.openseizuredetector","split":"","minSdkVersion":"14"}}]

View File

@@ -541,7 +541,20 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
Log.v(TAG, "faultWarningBeep() - CancelAudible Active - silent beep..."); Log.v(TAG, "faultWarningBeep() - CancelAudible Active - silent beep...");
} else { } else {
if (mAudibleFaultWarning) { if (mAudibleFaultWarning) {
if (mMp3Alarm) {
Log.v(TAG,"making MP3 alarm beep");
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
// This plays an audio file as a notification, using the notification sound channel.
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Uri soundUri = Uri.parse("android.resource://"+getPackageName()+"/raw/fault");
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSound(soundUri); //This sets the sound to play
notificationManager.notify(0, mBuilder.build());
} else {
beep(10); beep(10);
}
Log.v(TAG, "faultWarningBeep()"); Log.v(TAG, "faultWarningBeep()");
mUtil.writeToSysLogFile("SdServer.faultWarningBeep() - beeping"); mUtil.writeToSysLogFile("SdServer.faultWarningBeep() - beeping");
} else { } else {
@@ -567,15 +580,13 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
if (mMp3Alarm) { if (mMp3Alarm) {
Log.v(TAG,"making MP3 alarm beep"); Log.v(TAG,"making MP3 alarm beep");
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound // From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
// This plays an audio file as a notification, using the notification sound channel.
NotificationManager notificationManager = NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//Define sound URI Uri soundUri = Uri.parse("android.resource://"+getPackageName()+"/raw/alarm");
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext()) new NotificationCompat.Builder(getApplicationContext())
.setSound(soundUri); //This sets the sound to play .setSound(soundUri); //This sets the sound to play
//Display notification
notificationManager.notify(0, mBuilder.build()); notificationManager.notify(0, mBuilder.build());
} else { } else {
beep(3000); beep(3000);
@@ -596,7 +607,20 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
Log.v(TAG, "warningBeep() - CancelAudible Active - silent beep..."); Log.v(TAG, "warningBeep() - CancelAudible Active - silent beep...");
} else { } else {
if (mAudibleWarning) { if (mAudibleWarning) {
if (mMp3Alarm) {
Log.v(TAG,"making MP3 alarm beep");
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
// This plays an audio file as a notification, using the notification sound channel.
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Uri soundUri = Uri.parse("android.resource://"+getPackageName()+"/raw/warning");
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSound(soundUri); //This sets the sound to play
notificationManager.notify(0, mBuilder.build());
} else {
beep(100); beep(100);
}
Log.v(TAG, "warningBeep()"); Log.v(TAG, "warningBeep()");
mUtil.writeToSysLogFile("SdServer.warningBeep() - beeping"); mUtil.writeToSysLogFile("SdServer.warningBeep() - beeping");
} else { } else {

Binary file not shown.

Binary file not shown.

Binary file not shown.