Changeset 270 for trunk/hiptop/pester


Ignore:
Timestamp:
07/20/06 22:43:43 (18 years ago)
Author:
Nicholas Riley
Message:

Fix auto-day increment (Date.setToday() doesn't set today, it sets _now_). Save/restore the period regardless of the alarm type, so we don't end up with 1-second periods. Read the time from the time editor when the date picker is focused - less consistency, but easier to understand.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/net/sabi/pester/AlarmSetDialog.java

    r269 r270  
    9999    protected void editAlarm(Alarm alarm) {
    100100        mMessageField.setText(alarm.getMessage());
    101 
    102         boolean usesPeriod = alarm.getUsesPeriod();
    103         if (usesPeriod) {
    104             int period = alarm.getPeriod();
     101       
     102        int period = alarm.getPeriod();
     103        if (period > 0) {
    105104            for (int i = mPeriodUnitsPopup.itemCount() - 1 ; i >= 0 ; --i) {
    106105                int unitsPerSec = mPeriodUnitsPopup.getItem(i).getEvent().data;
     
    116115        editDate(new Date(alarm.getDate()));
    117116
     117        boolean usesPeriod = alarm.getUsesPeriod();
    118118        mInButton.setValue(usesPeriod ? 1 : 0);
    119119        mAtButton.setValue(usesPeriod ? 0 : 1);
     
    166166        } else {
    167167            date = mDateEditor.getDate();
    168             DEBUG.p("+ time editor.getTime = " + Alarm.dateTimeString(date, false));
    169168            date.setSeconds(0);
    170             DEBUG.p("+ seconds 0 = " + Alarm.dateTimeString(date, false));
    171169        }
    172170        return date;
     
    225223                return true;
    226224            mEditingAlarm.setMessage(mMessageField.toString());
    227             if (isIn()) {
    228                 mEditingAlarm.setPeriod(editingInterval(),
    229                                         mRepeatCheckBox.getValue() == 1);
    230             } else {
     225            // set the period regardless, so it gets saved for future use
     226            mEditingAlarm.setPeriod(editingInterval(),
     227                                    mRepeatCheckBox.getValue() == 1);
     228            if (!isIn()) { // otherwise, date = current time + period
    231229                mEditingAlarm.setDate(editingDate());
    232230            }
     
    266264            Date date = editingDate();
    267265            Date now = new Date();
    268             if (date.compareTo(now) <= 0) {
    269                 date.setToday();
     266            if (date.compareTo(now) <= 0) { // XXX do with 1 minute fuzz
     267                int time = date.getTime();
     268                date.set(now); // idiotically, setToday() sets the time too
     269                date.setTime(time);
    270270                if (date.compareTo(now) <= 0)
    271271                    date.addDays(1); // tomorrow
     
    282282        {
    283283            Date date = (Date)e.argument;
    284             date.setTime(mDateEditor.getDate().getTime());
     284            date.setTime(mTimeEditor.getDate().getTime());
    285285            mTimeEditor.setDate(date);
    286286            mDateEditor.setDate(date);
Note: See TracChangeset for help on using the changeset viewer.