Changeset 253 for trunk/hiptop
- Timestamp:
- 07/18/06 06:02:30 (18 years ago)
- Location:
- trunk/hiptop/pester
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hiptop/pester/locale/en_US/Pester.rsrc
r251 r253 130 130 alignBaseline = ID_IN_BUTTON 131 131 positionToRight = ID_IN_BUTTON : 1 132 className = "net.sabi.pester.EventfulNumberEditor" 132 133 133 134 popupMenu -
trunk/hiptop/pester/net/sabi/pester/Alarm.java
r250 r253 78 78 dataStream.writeInt(mDate.getUnixTimeGMT()); 79 79 dataStream.writeInt(mType); 80 dataStream.writeInt(mAlert == null ? 0 : mAlert.getID()); 80 81 dataStream.flush(); 81 82 return byteStream.toByteArray(); 82 83 } catch (Exception e) { 83 84 // XXX do something 85 DEBUG.p("failed to write alarm:" + e); 84 86 } 85 87 return null; … … 97 99 mMessage = dataStream.readUTF(); 98 100 mPeriod = dataStream.readInt(); 101 mDate = new Date(dataStream.readInt()); 99 102 mType = dataStream.readInt(); 103 int alertID = dataStream.readInt(); 104 mAlert = (alertID == 0 ? null : new RingToneObject(alertID)); 100 105 } catch (Exception e) { 101 106 // XXX do something 107 DEBUG.p("failed to read alarm:" + e); 102 108 } 103 109 } … … 116 122 } 117 123 124 // XXX trigger on EVENT_TIME_CHANGED 118 125 void resume() { 119 126 mState = STATE_SCHEDULED; -
trunk/hiptop/pester/net/sabi/pester/AlarmSetDialog.java
r251 r253 42 42 private Alarm mEditingAlarm; 43 43 private boolean mAlarmIsNew; 44 private boolean haveShownWindow = false; 44 private boolean mHaveShownWindow = false; 45 46 private danger.app.Alarm mValidateAlarm; 45 47 46 48 public static AlarmSetDialog getDialog() { … … 82 84 mStatusBox.setAutoResize(false); 83 85 86 mValidateAlarm = new danger.app.Alarm(1, this); 87 84 88 super.onDecoded(); 85 89 } … … 100 104 } 101 105 102 Date date = alarm.getDate();106 Date date = new Date(alarm.getDate()); 103 107 mTimeEditor.setDate(date); 104 108 mDateEditor.setDate(date); … … 124 128 validate(); 125 129 show(); 126 if (! haveShownWindow) {130 if (!mHaveShownWindow) { 127 131 Rect alarmRect = mSetAlarmButton.getFrame(); 128 132 Rect contentRect = getContentRect(); … … 131 135 mStatusBox.show(); 132 136 addChild(mStatusBox); 133 haveShownWindow = true;137 mHaveShownWindow = true; 134 138 setAutoSize(false); // don't resize to contain it next time 135 139 } … … 170 174 mDateEditor.min(now); 171 175 mDatePicker.min(now); 172 if (!isIn() && editingDate().compareTo(now) <= 0) { 173 mStatusBox.setText("Specify a future date."); 174 return false; 175 } 176 mStatusBox.setText(Alarm.dateTimeString(editingDate(), true)); 177 // XXX invalidate @ alarm date if isIn() 178 // XXX invalidate in 1 sec if isAt() 176 Date editingDate = editingDate(); 177 if (isIn()) { 178 mValidateAlarm.resetWake(60 - now.getSeconds()); 179 } else { 180 int secondsUntilDate = 181 editingDate.getDangerTimeGMT() - now.getDangerTimeGMT(); 182 if (secondsUntilDate <= 0) { 183 mStatusBox.setText("Specify a future date."); 184 return false; 185 } 186 mValidateAlarm.resetWake(secondsUntilDate); 187 } 188 mStatusBox.setText(Alarm.dateTimeString(editingDate, true)); 179 189 return true; 180 190 } 181 191 192 // XXX make a timer-only version of this which doesn't try to extract 193 // XXX the editing date (it can cause odd behavior by forcing the 194 // XXX NumberEditor to spit out a value) 182 195 protected void validate() { 183 mSetAlarmButton.setEnabled(isValid()); 196 boolean isValid = isValid(); 197 mSetAlarmButton.setEnabled(isValid); 198 if (!isValid) 199 mValidateAlarm.deactivate(); 200 } 201 202 protected void stopEditing() { 203 mEditingAlarm = null; 204 mValidateAlarm.deactivate(); 184 205 } 185 206 … … 200 221 mEditingAlarm.schedule(); 201 222 if (mAlarmIsNew) Alarms.addAlarm(mEditingAlarm); 202 mEditingAlarm = null;223 stopEditing(); 203 224 return true; 204 225 case EVENT_CANCEL_ALARM: 205 226 if (!mAlarmIsNew) mEditingAlarm.resume(); 206 mEditingAlarm = null;227 stopEditing(); 207 228 return true; 208 229 case EVENT_DISCARD_ALARM: 209 // XXX confirmation 210 Alarms.removeAlarm(mEditingAlarm); 211 mEditingAlarm = null; 212 return true; 230 // XXX prompt for confirmation 231 stopEditing(); 232 return true; 233 case Event.EVENT_TIME_CHANGED: 234 // XXX this isn't being delivered on the simulator, why? 235 DEBUG.p("time changed"); 236 validate(); 237 return true; 238 case Event.EVENT_ALARM: 213 239 case EVENT_VALIDATE: // something changed 214 240 validate();
Note:
See TracChangeset
for help on using the changeset viewer.