Changeset 258 for trunk/hiptop/pester/net
- Timestamp:
- 07/19/06 22:50:24 (18 years ago)
- Location:
- trunk/hiptop/pester/net/sabi/pester
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hiptop/pester/net/sabi/pester/AlarmSetDialog.java
r257 r258 86 86 mValidateAlarm = new danger.app.Alarm(1, this); 87 87 88 editAlarm(Alarms.getDefaultAlarm()); 89 88 90 super.onDecoded(); 89 91 } 90 92 91 protected void editDateOrPeriod(Alarm alarm) { 93 protected void editAlarm(Alarm alarm) { 94 mMessageField.setText(alarm.getMessage()); 95 92 96 boolean usesPeriod = alarm.getUsesPeriod(); 93 97 if (usesPeriod) { … … 111 115 mInButton.setValue(usesPeriod ? 1 : 0); 112 116 mAtButton.setValue(usesPeriod ? 0 : 1); 117 118 mAlertPicker.setRingTone(alarm.getAlert()); 113 119 } 114 120 … … 121 127 // XXX default to now? 122 128 } else { 123 mMessageField.setText(alarm.getMessage());129 editAlarm(alarm); 124 130 mDiscardAlarmButton.show(); 125 editDateOrPeriod(alarm);126 mAlertPicker.setRingTone(mEditingAlarm.getAlert());127 131 } 128 132 validate(); … … 225 229 mEditingAlarm.schedule(); 226 230 if (mAlarmIsNew) Alarms.addAlarm(mEditingAlarm); 231 Alarms.setDefaultAlarm(mEditingAlarm); 227 232 stopEditing(); 228 233 return true; -
trunk/hiptop/pester/net/sabi/pester/Alarms.java
r255 r258 5 5 import danger.app.DataStore; 6 6 import danger.app.Event; 7 import danger.app.SettingsDB; 8 import danger.app.SettingsDBException; 9 import danger.internal.Date; 7 10 import danger.util.StdActiveList; 8 11 … … 13 16 private static Alarms sAlarmList = null; 14 17 private static Listener sListener; 18 private static SettingsDB sSettingsDB; 15 19 16 20 private DataStore mDataStore; … … 24 28 sAlarmList = new Alarms(); 25 29 sListener = new Listener(); 30 sSettingsDB = new SettingsDB("settings", true /* auto sync */); 26 31 Application.registerForEvent(sListener, Event.EVENT_TIME_CHANGED); 27 32 } … … 34 39 public static void removeAlarm(Alarm alarm) { 35 40 sAlarmList.removeItem(alarm); 41 } 42 43 private static String KEY_DEFAULT_ALARM = "default alarm"; 44 45 public static Alarm getDefaultAlarm() { 46 Alarm defaultAlarm = new Alarm(); 47 try { 48 defaultAlarm.fromByteArray(sSettingsDB.getBytes(KEY_DEFAULT_ALARM)); 49 } catch (SettingsDBException e) { 50 defaultAlarm = new Alarm(); 51 defaultAlarm.setDate(new Date()); 52 defaultAlarm.setPeriod(600, false); 53 } 54 return defaultAlarm; 55 } 56 public static void setDefaultAlarm(Alarm alarm) { 57 sSettingsDB.setBytes(KEY_DEFAULT_ALARM, alarm.toByteArray()); 36 58 } 37 59
Note:
See TracChangeset
for help on using the changeset viewer.