From: Patrick Scott Date: Tue, 11 Aug 2009 17:39:40 +0000 (-0400) Subject: Fix the clock face preference. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e77fa5af5ac139f69ad504dbadd6f6aaab8c064d;p=android-x86%2Fpackages-apps-AlarmClock.git Fix the clock face preference. I was clearing all the preferences when removing the snooze and that was clearing the clock face and visibility preference as well. Instead, remove the snooze preferences. Also, use the constant PREF_CLOCK_FACE instead of the literal string. --- diff --git a/src/com/android/alarmclock/Alarms.java b/src/com/android/alarmclock/Alarms.java index 3b7adf4..d4973fa 100644 --- a/src/com/android/alarmclock/Alarms.java +++ b/src/com/android/alarmclock/Alarms.java @@ -367,12 +367,12 @@ public class Alarms { AlarmClock.PREFERENCES, 0); SharedPreferences.Editor ed = prefs.edit(); if (id == -1) { - ed.clear(); + clearSnoozePreference(ed); } else { ed.putInt(PREF_SNOOZE_ID, id); ed.putLong(PREF_SNOOZE_TIME, time); + ed.commit(); } - ed.commit(); // Set the next alert after updating the snooze. setNextAlert(context); } @@ -389,12 +389,18 @@ public class Alarms { return; } else if (snoozeId == id) { // This is the same id so clear the shared prefs. - SharedPreferences.Editor ed = prefs.edit(); - ed.clear(); - ed.commit(); + clearSnoozePreference(prefs.edit()); } } + // Helper to remove the snooze preference. Do not use clear because that + // will erase the clock preferences. + private static void clearSnoozePreference(final SharedPreferences.Editor ed) { + ed.remove(PREF_SNOOZE_ID); + ed.remove(PREF_SNOOZE_TIME); + ed.commit(); + }; + /** * If there is a snooze set, enable it in AlarmManager * @return true if snooze is set diff --git a/src/com/android/alarmclock/ClockPicker.java b/src/com/android/alarmclock/ClockPicker.java index 039f5b8..31150a2 100644 --- a/src/com/android/alarmclock/ClockPicker.java +++ b/src/com/android/alarmclock/ClockPicker.java @@ -83,7 +83,7 @@ public class ClockPicker extends Activity implements private synchronized void selectClock(int position) { SharedPreferences.Editor ed = mPrefs.edit(); - ed.putInt("face", position); + ed.putInt(AlarmClock.PREF_CLOCK_FACE, position); ed.commit(); setResult(RESULT_OK);