Changeset 278 for trunk/hiptop/pester
- Timestamp:
- 07/23/06 08:33:15 (18 years ago)
- Location:
- trunk/hiptop/pester
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hiptop/pester/locale/en_US/Pester.rsrc
r274 r278 49 49 title = "Discard" 50 50 shortcut = deleteKey 51 event = EVENT_ CONFIRM_DISCARD_ALARM51 event = EVENT_DISCARD_ALARM 52 52 endMenu 53 53 screen ID_ALARM_LIST_SCREEN … … 197 197 event = EVENT_DISCARD_ALARM 198 198 position = buttonTop2 199 title = "Discard"199 title = discardButton 200 200 201 201 button … … 214 214 text = "Alarm!" 215 215 button 216 event = EVENT_SNOOZE_ALARM 217 title = "Snooze" 218 position = buttonTop1 219 shortcut = cancelButton 220 button 221 event = EVENT_SET_ALARM 222 title = "Edit..." 223 position = buttonBottom2 224 button 216 225 event = EVENT_DISMISS_ALARM 217 226 title = okButton … … 226 235 text = "Permanently discard this alarm?" 227 236 button 228 event = EVENT_ DISCARD_ALARM237 event = EVENT_CONFIRM_DISCARD 229 238 title = discardButton 230 239 position = buttonBottom2 231 240 button 241 event = EVENT_CANCEL_DISCARD 232 242 title = backButton 233 243 position = buttonBottom1 -
trunk/hiptop/pester/net/sabi/pester/AlarmListView.java
r277 r278 5 5 import danger.ui.AlertWindow; 6 6 import danger.ui.ActiveListView; 7 import danger.ui.Font; 8 import danger.ui.Pen; 7 9 import danger.ui.Rect; 10 import danger.ui.Style; 8 11 import danger.ui.ToolTipWindow; 9 12 import danger.util.ActiveList; … … 25 28 setAutoResize(true); 26 29 setList(Alarms.getList()); 27 if (alarmsSet() == 0)28 setHasBorder(false); // this doesn't work in the rsrc file29 30 Application.registerForEvent(this, Event.EVENT_TIME_CHANGED); 30 31 super.onDecoded(); … … 53 54 alarmSetDialog().editAlarm(new Alarm(), true); 54 55 return true; 55 case EVENT_CONFIRM_DISCARD_ALARM: 56 case EVENT_DISCARD_ALARM: 57 mToolTipAlarm.deactivate(); 58 Alarm alarm = (Alarm)getFocusedItem(); 59 alarm.beginEditing(); 56 60 AlertWindow alert = 57 61 Application.getCurrentApp().getAlert(ID_DISCARD_ALERT, this); 58 // XXX localize59 62 alert.setMessage("Permanently discard \u201c" + 60 ((Alarm)getFocusedItem()).getMessage() + 61 "\u201d?"); 63 alarm.getMessage() + "\u201d?"); // XXX localize 62 64 alert.show(); 63 65 return true; 64 case EVENT_ DISCARD_ALARM:66 case EVENT_CONFIRM_DISCARD: 65 67 Alarms.removeAlarm((Alarm)getFocusedItem()); 66 68 return true; 67 case Event.EVENT_TIME_CHANGED: // XXX EVENT_TIME_FORMAT_CHANGED too 69 case EVENT_CANCEL_DISCARD: 70 ((Alarm)getFocusedItem()).resume(); 71 return true; 72 // XXX for EVENT_TIME_FORMAT_CHANGED, we also need to force a 73 // full redraw (in addition to invalidating the tooltip) 74 case Event.EVENT_TIME_CHANGED: 68 75 if (mToolTipWindow == null || !mToolTipWindow.isVisible()) 69 76 return true; … … 110 117 } 111 118 119 protected void paintEmptyList(Pen p, int width, int height) { 120 Style style = getStyle(); 121 Font font = style.getFont(Style.DISABLED_LABEL_FONT); 122 int y = (height / 4) - (font.getAscent() / 2); 123 if (y < 0) { 124 setHeight(sAlarmListWindow.getHeight()); 125 return; 126 } 127 // XXX localize 128 String emptyMessage = 129 "Press " + Font.GLYPH_MENU + " to set an alarm."; 130 int x = (width / 2) - (font.getWidth(emptyMessage) / 2); 131 p.setFont(font); 132 p.setColor(style.getColor(Style.DISABLED_LABEL_COLOR)); 133 p.drawText(x, y, emptyMessage); 134 } 135 112 136 public int alarmsSet() { 113 137 return getListSize(); … … 119 143 // which is admirable in general, but not what we want 120 144 setFocus(index); 121 setHasBorder(true);122 145 } 123 146 public void onItemRemoved(ActiveList list, Object item, int index) { … … 125 148 sAlarmListWindow.updateAlarmCount(); 126 149 super.onItemRemoved(list, item, index); 127 if (alarmsSet() == 0)128 setHasBorder(false);129 150 } 130 151 } -
trunk/hiptop/pester/net/sabi/pester/Alarms.java
r276 r278 23 23 private Alarms() { 24 24 mDataStore = DataStore.createDataStore("alarms", true /* auto sync */); 25 // register us for Event.EVENT_DATASTORE_RESTORED, which only 26 // seems to be documented at: 27 // <http://developer.danger.com/forum/index.php?t=msg&th=27> 28 mDataStore.setAutoSyncNotifyee(sListener); 29 refreshFromDataStore(false); 30 } 31 32 void refreshFromDataStore(boolean datastoreRestored) { 33 sAlarmList = null; 34 removeAllItems(); 35 if (datastoreRestored) 36 mDataStore.doneResolvingConflict(); // resolves UID conflicts 25 37 byte[][] alarmsData = mDataStore.getRecords(); 26 38 int i; … … 32 44 alarm.resume(); 33 45 } 46 sAlarmList = this; 34 47 } 35 48 … … 39 52 sSettingsDB = new SettingsDB("settings", true /* auto sync */); 40 53 sListener = new Listener(); 41 sAlarmList =new Alarms();54 new Alarms(); 42 55 } 43 56 return sAlarmList; … … 51 64 } 52 65 53 // XXX handle EVENT_DATASTORE_RESTORED: note that in the event of54 // a hard reset, items may come back out of order, so we need to55 // implement an in-place sort, then insert the current alarm list.56 // Aiee. Also, what on earth happens when UIDs aren't synchronized?57 58 66 protected void onItemAdded(Object item, int index) { 59 67 if (sAlarmList == null) // restoring from service … … 62 70 DEBUG.p("adding: " + alarm + 63 71 " next UID: " + mDataStore.getAutoSyncNextUID()); 64 index = mDataStore.addRecord(alarm.toByteArray() , index);72 index = mDataStore.addRecord(alarm.toByteArray()); 65 73 alarm.setUID(mDataStore.getRecordUID(index)); 66 74 DEBUG.p("added UID " + alarm.getUID() + " @ " + index); … … 68 76 69 77 protected void onItemRemoved(Object item, int index) { 78 if (sAlarmList == null) // restoring from service (after hard reset) 79 return; 70 80 Alarm alarm = (Alarm)item; 71 // XXX make sure +/- UIDs are OK72 81 int uid = alarm.getUID(); 73 82 if (uid == 0) 74 83 return; 75 DEBUG.p("removing; " + alarm + " UID " + uid);76 84 mDataStore.removeRecordByUID(uid); 77 85 } … … 81 89 return; 82 90 Alarm alarm = (Alarm)item; 83 // XXX check that updating a + UID by a - one is OK84 91 mDataStore.setRecordDataByUID(alarm.getUID(), alarm.toByteArray(), true); 85 92 DEBUG.p("updated: " + alarm + " UID " + alarm.getUID()); … … 114 121 Alarms.getList().forEach(this); 115 122 return true; 123 } else if (e.type == Event.EVENT_DATASTORE_RESTORED) { 124 String dbName = (String)e.argument; 125 DEBUG.p("DATASTORE_RESTORED: " + dbName); 126 if (!dbName.endsWith("alarms")) { 127 // because we only get/set the default alarm on demand 128 // there's no need to handle conflicts with the settings... 129 // XXX but what happens if we set a (default) alarm, then 130 // the SettingsDB restores? 131 Alarms.getList().refreshFromDataStore(true); 132 } 116 133 } 117 134 return super.receiveEvent(e); -
trunk/hiptop/pester/net/sabi/pester/Pester.java
r244 r278 23 23 Alarm alarm = (Alarm)e.argument; 24 24 AlertWindow alert = getAlert(ID_ALARM_ALERT, this); 25 alert.setTitle(al ert.getTitle() + ": " + alarm.getDateTimeString());25 alert.setTitle(alarm.getDateTimeString()); 26 26 alert.setMessage(alarm.getMessage()); 27 27 alert.setShowTone(alarm.getAlert());
Note:
See TracChangeset
for help on using the changeset viewer.