From 55e8777d42c74c09f2da289a53962473b1b84a52 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 18 Apr 2014 16:07:19 +0200 Subject: [PATCH] Bug fixes for Alarm service, to make sure we don't remove an inactive alarm service (thus preventing it from ever starting next time). Also add commented-out code for a radial timepicker, which can be reenabled when betterpickers releases 1.5.3 (but test it). --- .idea/libraries/library_1_5_2.xml | 10 ----- HypoAlarm/HypoAlarm-HypoAlarm.iml | 41 ++++++++----------- HypoAlarm/build.gradle | 10 ++--- .../hypoalarm/AlarmAlertActivity.java | 8 +++- .../org/treehouse/hypoalarm/AlarmService.java | 5 --- .../hypoalarm/CancelAlarmReceiver.java | 1 + 6 files changed, 29 insertions(+), 46 deletions(-) delete mode 100644 .idea/libraries/library_1_5_2.xml diff --git a/.idea/libraries/library_1_5_2.xml b/.idea/libraries/library_1_5_2.xml deleted file mode 100644 index d72fdf4..0000000 --- a/.idea/libraries/library_1_5_2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/HypoAlarm/HypoAlarm-HypoAlarm.iml b/HypoAlarm/HypoAlarm-HypoAlarm.iml index fa07357..70b00c6 100644 --- a/HypoAlarm/HypoAlarm-HypoAlarm.iml +++ b/HypoAlarm/HypoAlarm-HypoAlarm.iml @@ -8,11 +8,10 @@ - - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -75,7 +69,6 @@ - diff --git a/HypoAlarm/build.gradle b/HypoAlarm/build.gradle index 9d758da..8370ce7 100644 --- a/HypoAlarm/build.gradle +++ b/HypoAlarm/build.gradle @@ -32,12 +32,10 @@ dependencies { compile 'net.frakbot.glowpadbackport:glowpadbackport:+' //compile 'net.frakbot.glowpadbackport:glowpadbackport:2.1.0' - compile 'com.doomonafireball.betterpickers:library:+' + //compile 'com.doomonafireball.betterpickers:library:+' //compile 'com.doomonafireball.betterpickers:library:1.5.2' + //compile 'com.doomonafireball.betterpickers:library:1.5.3-SNAPSHOT' - //compile project(':GlowPadBackport') - //compile project(':SeekArc') - - //compile fileTree(dir: 'libs', include: ['*.aar']) - //compile fileTree(dir: 'libs', include: ['*.jar']) + //compile 'com.github.flavienlaurent.datetimepicker:library:+' + //compile 'com.github.flavienlaurent.datetimepicker:library:0.0.1' } diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java index b558b0f..39b439e 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java @@ -13,11 +13,17 @@ import net.frakbot.glowpadbackport.GlowPadView; public class AlarmAlertActivity extends Activity { public static Activity alertActivity; + @Override + protected void onDestroy() { + super.onDestroy(); + alertActivity = null; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Self-reference so we can run finish() from outside. + // Self-reference so we can run finish() from other classes alertActivity = this; requestWindowFeature(Window.FEATURE_NO_TITLE); diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java index 0d96458..0a7061f 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java @@ -21,7 +21,6 @@ public class AlarmService extends Service { private static final int SNOOZE_TIME = 1000*60*5; // Snooze for 5 minutes if need be private static final int ALERT_LIFE = 1000*60*2; // 2 minutes private static PowerManager.WakeLock wl; - private static AlarmManager alarmManager; private static Intent alarmServiceIntent, alertActivityIntent, notifyIntent; private static Boolean alarmStarted = false; public static volatile String alarmStatus; // Register ALARM_DISMISSED and its brethren here @@ -39,9 +38,6 @@ public class AlarmService extends Service { wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AlarmService"); // TODO: wake lock? //wl.acquire(); - - alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); - } @Override public void onDestroy() { @@ -74,7 +70,6 @@ public class AlarmService extends Service { Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (alarmStarted) { - stopAlert(getApplicationContext()); stopService(notifyIntent); } alarmStarted = true; diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelAlarmReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelAlarmReceiver.java index 29e5793..112d739 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelAlarmReceiver.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/CancelAlarmReceiver.java @@ -34,6 +34,7 @@ public class CancelAlarmReceiver extends BroadcastReceiver { Toast.makeText(context, context.getString(R.string.alarmCancelToast), Toast.LENGTH_LONG).show(); // Stop any snoozed/existing alarms that may have started + AlarmService.setAlarmStatus(AlarmService.ALARM_DISMISSED); context.stopService(new Intent(context, AlarmService.class)); // Remove notification