OSDN Git Service

resolved conflicts for merge of 439d5bd5 to master
authorPatrick Scott <phanna@android.com>
Tue, 14 Jul 2009 17:47:39 +0000 (13:47 -0400)
committerPatrick Scott <phanna@android.com>
Tue, 14 Jul 2009 17:47:39 +0000 (13:47 -0400)
1  2 
src/com/android/alarmclock/Alarms.java

@@@ -38,49 -40,266 +38,50 @@@ import java.text.DateFormatSymbols
   */
  public class Alarms {
  
 -    final static String ALARM_ALERT_ACTION = "com.android.alarmclock.ALARM_ALERT";
 -    final static String ID = "alarm_id";
 -    final static String TIME = "alarm_time";
 -    final static String LABEL = "alarm_label";
 +    // This action triggers the AlarmReceiver as well as the AlarmKlaxon. It
 +    // is a public action used in the manifest for receiving Alarm broadcasts
 +    // from the alarm manager.
 +    public static final String ALARM_ALERT_ACTION = "com.android.alarmclock.ALARM_ALERT";
  
 -    final static String PREF_SNOOZE_ID = "snooze_id";
 -    final static String PREF_SNOOZE_TIME = "snooze_time";
 -    final static String PREF_SNOOZE_LABEL = "snooze_label";
 -
 -    private final static String DM12 = "E h:mm aa";
 -    private final static String DM24 = "E kk:mm";
 -
 -    private final static String M12 = "h:mm aa";
 -    // Shared with DigitalClock
 -    final static String M24 = "kk:mm";
 -
 -    /**
 -     * Mapping from days in this application (where Monday is 0) to
 -     * days in DateFormatSymbols (where Monday is 2).
 -     */
 -    private static int[] DAY_MAP = new int[] {
 -        Calendar.MONDAY,
 -        Calendar.TUESDAY,
 -        Calendar.WEDNESDAY,
 -        Calendar.THURSDAY,
 -        Calendar.FRIDAY,
 -        Calendar.SATURDAY,
 -        Calendar.SUNDAY,
 -    };
 -
 -    static class DaysOfWeek {
 -
 -        int mDays;
 -
 -        /**
 -         * Days of week coded as single int, convenient for DB
 -         * storage:
 -         *
 -         * 0x00:  no day
 -         * 0x01:  Monday
 -         * 0x02:  Tuesday
 -         * 0x04:  Wednesday
 -         * 0x08:  Thursday
 -         * 0x10:  Friday
 -         * 0x20:  Saturday
 -         * 0x40:  Sunday
 -         */
 -        DaysOfWeek() {
 -            this(0);
 -        }
 -
 -        DaysOfWeek(int days) {
 -            mDays = days;
 -        }
 -
 -        public String toString(Context context, boolean showNever) {
 -            StringBuilder ret = new StringBuilder();
 +    // This is a private action used when the user clears all notifications.
 +    public static final String CLEAR_NOTIFICATION = "clear_notification";
  
 -            /* no days */
 -            if (mDays == 0) return showNever ? context.getText(
 -                    R.string.never).toString() : "";
 +    // This is a private action used by the AlarmKlaxon to update the UI to
 +    // show the alarm has been killed.
 +    public static final String ALARM_KILLED = "alarm_killed";
  
 -            /* every day */
 -            if (mDays == 0x7f) {
 -                return context.getText(R.string.every_day).toString();
 -            }
 +    // Extra in the ALARM_KILLED intent to indicate to the user how long the
 +    // alarm played before being killed.
 +    public static final String ALARM_KILLED_TIMEOUT = "alarm_killed_timeout";
  
 -            /* count selected days */
 -            int dayCount = 0, days = mDays;
 -            while (days > 0) {
 -                if ((days & 1) == 1) dayCount++;
 -                days >>= 1;
 -            }
 +    // This string is used to indicate a silent alarm in the db.
 +    public static final String ALARM_ALERT_SILENT = "silent";
  
 -            /* short or long form? */
 -            DateFormatSymbols dfs = new DateFormatSymbols();
 -            String[] dayList = (dayCount > 1) ?
 -                                    dfs.getShortWeekdays() :
 -                                    dfs.getWeekdays();
 -
 -            /* selected days */
 -            for (int i = 0; i < 7; i++) {
 -                if ((mDays & (1 << i)) != 0) {
 -                    ret.append(dayList[DAY_MAP[i]]);
 -                    dayCount -= 1;
 -                    if (dayCount > 0) ret.append(
 -                            context.getText(R.string.day_concat));
 -                }
 -            }
 -            return ret.toString();
 -        }
 +    // This intent is sent from the notification when the user cancels the
 +    // snooze alert.
 +    public static final String CANCEL_SNOOZE = "cancel_snooze";
  
 -        /**
 -         * @param day Mon=0 ... Sun=6
 -         * @return true if given day is set
 -         */
 -        public boolean isSet(int day) {
 -            return ((mDays & (1 << day)) > 0);
 -        }
 +    // This string is used when passing an Alarm object through an intent.
 +    public static final String ALARM_INTENT_EXTRA = "intent.extra.alarm";
  
 -        public void set(int day, boolean set) {
 -            if (set) {
 -                mDays |= (1 << day);
 -            } else {
 -                mDays &= ~(1 << day);
 -            }
 -        }
 -
 -        public void set(DaysOfWeek dow) {
 -            mDays = dow.mDays;
 -        }
 +    // This extra is the raw Alarm object data. It is used in the
 +    // AlarmManagerService to avoid a ClassNotFoundException when filling in
 +    // the Intent extras.
 +    public static final String ALARM_RAW_DATA = "intent.extra.alarm_raw";
  
 -        public int getCoded() {
 -            return mDays;
 -        }
 +    // This string is used to identify the alarm id passed to SetAlarm from the
 +    // list of alarms.
 +    public static final String ALARM_ID = "alarm_id";
  
 -        public boolean equals(DaysOfWeek dow) {
 -            return mDays == dow.mDays;
 -        }
 -
 -        // Returns days of week encoded in an array of booleans.
 -        public boolean[] getBooleanArray() {
 -            boolean[] ret = new boolean[7];
 -            for (int i = 0; i < 7; i++) {
 -                ret[i] = isSet(i);
 -            }
 -            return ret;
 -        }
 -
 -        public void setCoded(int days) {
 -            mDays = days;
 -        }
 -
 -        /**
 -         * @return true if alarm is set to repeat
 -         */
 -        public boolean isRepeatSet() {
 -            return mDays != 0;
 -        }
 -
 -        /**
 -         * @return true if alarm is set to repeat every day
 -         */
 -        public boolean isEveryDaySet() {
 -            return mDays == 0x7f;
 -        }
 -
 -
 -        /**
 -         * returns number of days from today until next alarm
 -         * @param c must be set to today
 -         */
 -        public int getNextAlarm(Calendar c) {
 -            if (mDays == 0) return -1;
 -            int today = (c.get(Calendar.DAY_OF_WEEK) + 5) % 7;
 -
 -            int day, dayCount;
 -            for (dayCount = 0; dayCount < 7; dayCount++) {
 -                day = (today + dayCount) % 7;
 -                if ((mDays & (1 << day)) > 0) {
 -                    break;
 -                }
 -            }
 -            return dayCount;
 -        }
 -    }
 +    final static String PREF_SNOOZE_ID = "snooze_id";
 +    final static String PREF_SNOOZE_TIME = "snooze_time";
  
 -    public static class AlarmColumns implements BaseColumns {
 -
 -        /**
 -         * The content:// style URL for this table
 -         */
 -        public static final Uri CONTENT_URI =
 -            Uri.parse("content://com.android.alarmclock/alarm");
 -
 -        public static final String _ID = "_id";
 -
 -        /**
 -         * The default sort order for this table
 -         */
 -        public static final String DEFAULT_SORT_ORDER = "_id ASC";
 -
 -        /**
 -         * Hour in 24-hour localtime 0 - 23.
 -         * <P>Type: INTEGER</P>
 -         */
 -        public static final String HOUR = "hour";
 -
 -        /**
 -         * Minutes in localtime 0 - 59
 -         * <P>Type: INTEGER</P>
 -         */
 -        public static final String MINUTES = "minutes";
 -
 -        /**
 -         * Days of week coded as integer
 -         * <P>Type: INTEGER</P>
 -         */
 -        public static final String DAYS_OF_WEEK = "daysofweek";
 -
 -        /**
 -         * Alarm time in UTC milliseconds from the epoch.
 -         * <P>Type: INTEGER</P>
 -         */
 -        public static final String ALARM_TIME = "alarmtime";
 -
 -        /**
 -         * True if alarm is active
 -         * <P>Type: BOOLEAN</P>
 -         */
 -        public static final String ENABLED = "enabled";
 -
 -        /**
 -         * True if alarm should vibrate
 -         * <P>Type: BOOLEAN</P>
 -         */
 -        public static final String VIBRATE = "vibrate";
 -
 -        /**
 -         * Message to show when alarm triggers
 -         * Note: not currently used
 -         * <P>Type: STRING</P>
 -         */
 -        public static final String MESSAGE = "message";
 -
 -        /**
 -         * Audio alert to play when alarm triggers
 -         * <P>Type: STRING</P>
 -         */
 -        public static final String ALERT = "alert";
 -
 -        static final String[] ALARM_QUERY_COLUMNS = {
 -            _ID, HOUR, MINUTES, DAYS_OF_WEEK, ALARM_TIME,
 -            ENABLED, VIBRATE, MESSAGE, ALERT};
 -
 -        /**
 -         * These save calls to cursor.getColumnIndexOrThrow()
 -         * THEY MUST BE KEPT IN SYNC WITH ABOVE QUERY COLUMNS
 -         */
 -        public static final int ALARM_ID_INDEX = 0;
 -        public static final int ALARM_HOUR_INDEX = 1;
 -        public static final int ALARM_MINUTES_INDEX = 2;
 -        public static final int ALARM_DAYS_OF_WEEK_INDEX = 3;
 -        public static final int ALARM_TIME_INDEX = 4;
 -        public static final int ALARM_ENABLED_INDEX = 5;
 -        public static final int ALARM_VIBRATE_INDEX = 6;
 -        public static final int ALARM_MESSAGE_INDEX = 7;
 -        public static final int ALARM_ALERT_INDEX = 8;
 -    }
 +    private final static String DM12 = "E h:mm aa";
 +    private final static String DM24 = "E k:mm";
  
 -    /**
 -     * getAlarm and getAlarms call this interface to report alarms in
 -     * the database
 -     */
 -    static interface AlarmSettings {
 -        void reportAlarm(
 -                int idx, boolean enabled, int hour, int minutes,
 -                DaysOfWeek daysOfWeek, boolean vibrate, String message,
 -                String alert);
 -    }
 +    private final static String M12 = "h:mm aa";
-     private final static String M24 = "k:mm";
++    // Shared with DigitalClock
++    final static String M24 = "kk:mm";
  
      /**
       * Creates a new Alarm.