Changeset 242


Ignore:
Timestamp:
07/09/06 00:47:17 (18 years ago)
Author:
Nicholas Riley
Message:

Basic functionality works.

Location:
trunk/hiptop/pester
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/locale/en_US/Pester.rsrc

    r241 r242  
    9898
    9999        typeAheadTextField
    100                 fillToRight = 0
    101100                id = ID_MESSAGE_FIELD
    102                 alignBaseline = ID_MESSAGE_LABEL
    103                 positionToRight = ID_MESSAGE_LABEL : 3 
    104101                autoCap
    105102                initiallySelectAll
    106103                initialFocus
     104                alignBaseline = ID_MESSAGE_LABEL
     105                positionToRight = ID_MESSAGE_LABEL : 3 
     106                fillToRight = 0
    107107
    108108        groupBox
     
    175175        button
    176176                id = ID_DISCARD_ALARM_BUTTON
     177                event = EVENT_DISCARD_ALARM
    177178                position = buttonTop2
    178179                title = "Discard"
    179                 event = EVENT_DISCARD_ALARM
    180180
    181181        button
    182182                id = ID_SET_ALARM_BUTTON
     183                event = EVENT_SET_ALARM
    183184                position = buttonBottom1
    184185                title = "Set"
    185186                shortcut = doneButton
    186                 event = EVENT_SET_ALARM
    187187endDialog
     188
     189alert ID_ALARM_ALERT
     190        systemDialog
     191        title = "Alarm"
     192        icon = ID_LARGE_ICON
     193        font = "BortBold12"
     194        text = "Alarm!"
     195        button
     196                event = EVENT_DISMISS_ALARM
     197                title = "OK"
     198                position = buttonBottom1
     199                shortcut = doneButton
     200endAlert
  • trunk/hiptop/pester/net/sabi/pester/Alarm.java

    r241 r242  
    55import java.io.DataInputStream;
    66import java.io.DataOutputStream;
     7import danger.app.Application;
    78import danger.internal.Date;
     9import danger.util.StdActiveList;
    810import danger.util.StdActiveObject;
    911import danger.util.DEBUG;
     
    2022    // transient
    2123    private int mState;
     24    private danger.app.Alarm mAlarm;
    2225
    2326    public Alarm() {
    2427        mState = STATE_INVALID;
     28        mAlarm = new danger.app.Alarm(0, Application.getCurrentApp(), this);
    2529    }
    2630
     
    9296    void beginEditing() {
    9397        mState = STATE_EDITING;
     98        mAlarm.deactivate();
    9499    }
    95100
    96     void endEditing() {
     101    void dismiss() {
     102        if (getRepeating())
     103            schedule();
     104        else
     105            ((StdActiveList)getDelegate()).removeItem(this);
     106    }
     107
     108    void cancel() {
     109        mState = STATE_INVALID;
     110        mAlarm.deactivate();
     111    }
     112
     113    void schedule() {
    97114        mState = STATE_SCHEDULED;
    98115        DEBUG.p("schedule alarm: " + mMessage);
     
    105122            DEBUG.p(" - date: " + mDate); break;
    106123        }
     124        mAlarm.resetWake(mPeriod);
    107125    }
    108126   
     
    118136    public static final int STATE_EDITING = 1;
    119137    public static final int STATE_SCHEDULED = 2;
    120     public static final int STATE_EXPIRED = 3;
    121138}
  • trunk/hiptop/pester/net/sabi/pester/AlarmListView.java

    r241 r242  
    3535    private Menu sPeriodUnitsMenu;
    3636    private PopupMenu sPeriodUnitsPopup;
     37    // XXX don't allow <5 second repeating alarms
    3738    private CheckBox sRepeatCheckBox;
    3839    private DateTimeEditor sTimeEditor, sDateEditor;
     
    128129    protected void constrainDate() {
    129130        // XXX schedule every minute (second?) if in AT mode
     131        // XXX could use onPeriodicPulse() perhaps
    130132        Date now = new Date();
    131133        sDateEditor.min(now);
    132134        sDatePicker.min(now);
    133         sSetAlarmButton.setEnabled(editingDate().compareTo(now) > 0);
     135        sSetAlarmButton.setEnabled(sInButton.getValue() == 1 ||
     136                                   editingDate().compareTo(now) > 0);
    134137    }
    135138
     
    153156                sAlarmList.addItem(sEditingAlarm);
    154157                setFocusedItem(sEditingAlarm);
    155                 sFocusedAlarm = sEditingAlarm; // XXX do we need this?
     158                sFocusedAlarm = sEditingAlarm;
    156159            } else {
    157160                sEditingAlarm.update();
    158161            }
    159162        case EVENT_CANCEL_ALARM:
    160             if (sEditingAlarm == sFocusedAlarm) { // existing alarm
    161                 // XXX (re)schedule alarm
    162                 sEditingAlarm.endEditing();
    163             }
     163            if (sEditingAlarm == sFocusedAlarm)
     164                sEditingAlarm.schedule();
    164165            sEditingAlarm = null;
    165166            return true;
     
    170171        case EVENT_IN:
    171172            sAtButton.setValue(0);
     173            constrainDate();
    172174            return true;
    173175        case EVENT_AT:
     
    177179        case EVENT_TIME_EDITOR:
    178180            Date date = editingDate();
    179             // XXX factor this out (it's used twice)
    180181            // XXX do this on exit from the field, not on change
    181182            if (date.compareTo(new Date()) <= 0) {
     
    214215    }
    215216    public void onItemRemoved(ActiveList list, Object item, int index) {
     217        ((Alarm)item).cancel();
    216218        sAlarmListWindow.updateAlarmCount();
    217219        super.onItemRemoved(list, item, index);
  • trunk/hiptop/pester/net/sabi/pester/AlarmListWindow.java

    r237 r242  
    1919        StringBuffer sb = new StringBuffer().append(size).append(" alarm");
    2020        if (size != 1) sb.append('s');
    21         sb.append(" set");
     21        // sb.append(" set");
    2222        setSubTitle(sb.toString());
    2323    }
  • trunk/hiptop/pester/net/sabi/pester/Pester.java

    r237 r242  
    22
    33import danger.app.Application;
     4import danger.app.Event;
     5import danger.ui.AlertWindow;
    46import danger.ui.ScreenWindow;
     7import danger.util.DEBUG;
     8import java.util.Stack;
    59
    610public class Pester extends Application implements Resources, Commands {
     11    private static ScreenWindow sAlarmListWindow;
     12    private static Stack sAlarmStack;
     13
    714    public Pester() {
    8         alarmListWindow = (ScreenWindow)getResources().getScreen(ID_ALARM_LIST_SCREEN);
    9         alarmListWindow.show();
     15        sAlarmListWindow = (ScreenWindow)getResources().getScreen(ID_ALARM_LIST_SCREEN);
     16        sAlarmListWindow.show();
     17        sAlarmStack = new Stack();
    1018    }
    1119
    12     static private ScreenWindow alarmListWindow;
     20    public boolean receiveEvent(Event e) {
     21        switch (e.type) {
     22        case Event.EVENT_ALARM:
     23            Alarm alarm = (Alarm)e.argument;
     24            AlertWindow alert = getAlert(ID_ALARM_ALERT, this);
     25            alert.setMessage(alarm.getMessage());
     26            // alert.setMessageFormatDate(alarm.getDate());
     27            alert.show(AlertWindow.SYSTEM_ALERT_TYPE_ALARM);
     28            sAlarmStack.push(alarm);
     29            return true;
     30        case EVENT_DISMISS_ALARM:
     31            ((Alarm)sAlarmStack.pop()).dismiss();
     32            return true;
     33        }
     34        return super.receiveEvent(e);
     35    }
    1336}
Note: See TracChangeset for help on using the changeset viewer.