From b3b8c941f8d3aaa73b9baacd80723a72cdef8dc3 Mon Sep 17 00:00:00 2001 From: Graham Jones Date: Wed, 23 Dec 2015 23:07:28 +0000 Subject: [PATCH] Notification icon colour changes for warning and alarm levels. Fixed issue with multiple versions of mainactivity starting on alarm. --- app/src/main/AndroidManifest.xml | 1 + .../org/openseizuredetector/MainActivity.java | 3 +- .../uk/org/openseizuredetector/SdServer.java | 58 ++++++++++++++---- .../res/drawable/star_of_life_red_24x24.png | Bin 0 -> 221 bytes .../drawable/star_of_life_yellow_24x24.png | Bin 0 -> 231 bytes 5 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/star_of_life_red_24x24.png create mode 100644 app/src/main/res/drawable/star_of_life_yellow_24x24.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3194086..c6e99d9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ + runningTaskInfo = manager.getRunningTasks(1); + ComponentName componentInfo = runningTaskInfo.get(0).topActivity; + + if (componentInfo.getPackageName().equals("uk.org.openseizuredetector")) { + Log.v(TAG,"showMainActivity(): OpenSeizureDetector Activity is already shown on top - not doing anything"); + } else { + Log.v(TAG,"showMainActivity(): Showing Main Activity"); + Intent i = new Intent(getApplicationContext(), MainActivity.class); + i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(i); + } } /** @@ -321,6 +350,7 @@ public class SdServer extends Service implements SdDataReceiver { sdData.alarmPhrase = "OK"; sdData.alarmStanding = false; sdData.fallAlarmStanding = false; + showNotification(0); } } if (sdData.alarmState == 1) { @@ -339,6 +369,7 @@ public class SdServer extends Service implements SdDataReceiver { Log.v(TAG, "WARNING"); } warningBeep(); + showNotification(1); } if ((sdData.alarmState == 2) || (sdData.alarmStanding)) { sdData.alarmPhrase = "ALARM"; @@ -352,6 +383,7 @@ public class SdServer extends Service implements SdDataReceiver { } // Make alarm beep tone alarmBeep(); + showNotification(2); // Display MainActvity showMainActivity(); // Send SMS Alarm. @@ -460,7 +492,7 @@ public class SdServer extends Service implements SdDataReceiver { Log.v(TAG, "alarmBeep() - CancelAudible Active - silent beep..."); } else { if (mAudibleAlarm) { - beep(1000); + beep(3000); Log.v(TAG, "alarmBeep()"); } else { Log.v(TAG, "alarmBeep() - silent..."); @@ -716,9 +748,9 @@ public class SdServer extends Service implements SdDataReceiver { } /* - * Temporary cancel audible alarms, for the period specified by the - * CancelAudiblePeriod setting. - */ + * Temporary cancel audible alarms, for the period specified by the + * CancelAudiblePeriod setting. + */ private class CancelAudibleTimer extends CountDownTimer { public CancelAudibleTimer(long startTime, long interval) { super(startTime, interval); diff --git a/app/src/main/res/drawable/star_of_life_red_24x24.png b/app/src/main/res/drawable/star_of_life_red_24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..22175c75553be4bd8e2f0b355ac3e6488088aba8 GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9Y)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHj@CxR|1p-<7RuK%p#87sn8b(|1E0xegd`WFProZ@Igd zZ_RAeX2X877PsVM0-}@5!!9iQb&=bpXUmgA>3iCX56T`bx{>pq+jrXJ(?{$sdAu%2 zd>Z=hUdzjTUxl~Pucr$=EDTWf2tN}4^PlYO+cvF7|nq{$p43`6VpAKPu8@uDrs9 UvRd68K>HayUHx3vIVCg!0RB`@0{{R3 literal 0 HcmV?d00001