OSDN Git Service

Check for null alarms and dismiss the snooze if the alarm is disabled.
[android-x86/packages-apps-DeskClock.git] / src / com / android / deskclock / AlarmAlertFullScreen.java
index 3442da3..0173a12 100644 (file)
@@ -132,6 +132,11 @@ public class AlarmAlertFullScreen extends Activity {
 
     // Attempt to snooze this alert.
     private void snooze() {
+        // Do not snooze if the snooze button is disabled.
+        if (!findViewById(R.id.snooze).isEnabled()) {
+            dismiss(false);
+            return;
+        }
         final String snooze =
                 PreferenceManager.getDefaultSharedPreferences(this)
                 .getString(SettingsActivity.KEY_ALARM_SNOOZE, DEFAULT_SNOOZE);
@@ -211,6 +216,16 @@ public class AlarmAlertFullScreen extends Activity {
     }
 
     @Override
+    protected void onResume() {
+        super.onResume();
+        // If the alarm was deleted at some point, disable snooze.
+        if (Alarms.getAlarm(getContentResolver(), mAlarm.id) == null) {
+            Button snooze = (Button) findViewById(R.id.snooze);
+            snooze.setEnabled(false);
+        }
+    }
+
+    @Override
     protected void onStop() {
         super.onStop();
         if (!isFinishing()) {