1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.deskclock.provider;
17
18import android.net.Uri;
19import android.provider.BaseColumns;
20
21import com.android.deskclock.BuildConfig;
22
23/**
24 * <p>
25 * The contract between the clock provider and desk clock. Contains
26 * definitions for the supported URIs and data columns.
27 * </p>
28 * <h3>Overview</h3>
29 * <p>
30 * ClockContract defines the data model of clock related information.
31 * This data is stored in a number of tables:
32 * </p>
33 * <ul>
34 * <li>The {@link AlarmsColumns} table holds the user created alarms</li>
35 * <li>The {@link InstancesColumns} table holds the current state of each
36 * alarm in the AlarmsColumn table.
37 * </li>
38 * </ul>
39 */
40public final class ClockContract {
41    /**
42     * This authority is used for writing to or querying from the clock
43     * provider.
44     */
45    public static final String AUTHORITY = BuildConfig.APPLICATION_ID;
46
47    /**
48     * This utility class cannot be instantiated
49     */
50    private ClockContract() {}
51
52    /**
53     * Constants for tables with AlarmSettings.
54     */
55    private interface AlarmSettingColumns extends BaseColumns {
56        /**
57         * This string is used to indicate no ringtone.
58         */
59        Uri NO_RINGTONE_URI = Uri.EMPTY;
60
61        /**
62         * This string is used to indicate no ringtone.
63         */
64        String NO_RINGTONE = NO_RINGTONE_URI.toString();
65
66        /**
67         * True if alarm should vibrate
68         * <p>Type: BOOLEAN</p>
69         */
70        String VIBRATE = "vibrate";
71
72        /**
73         * Alarm label.
74         *
75         * <p>Type: STRING</p>
76         */
77        String LABEL = "label";
78
79        /**
80         * Audio alert to play when alarm triggers. Null entry
81         * means use system default and entry that equal
82         * Uri.EMPTY.toString() means no ringtone.
83         *
84         * <p>Type: STRING</p>
85         */
86        String RINGTONE = "ringtone";
87    }
88
89    /**
90     * Constants for the Alarms table, which contains the user created alarms.
91     */
92    protected interface AlarmsColumns extends AlarmSettingColumns, BaseColumns {
93        /**
94         * The content:// style URL for this table.
95         */
96        Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/alarms");
97
98        /**
99         * The content:// style URL for the alarms with instance tables, which is used to get the
100         * next firing instance and the current state of an alarm.
101         */
102        Uri ALARMS_WITH_INSTANCES_URI = Uri.parse("content://" + AUTHORITY
103                + "/alarms_with_instances");
104
105        /**
106         * Hour in 24-hour localtime 0 - 23.
107         * <p>Type: INTEGER</p>
108         */
109        String HOUR = "hour";
110
111        /**
112         * Minutes in localtime 0 - 59.
113         * <p>Type: INTEGER</p>
114         */
115        String MINUTES = "minutes";
116
117        /**
118         * Days of the week encoded as a bit set.
119         * <p>Type: INTEGER</p>
120         *
121         * {@link DaysOfWeek}
122         */
123        String DAYS_OF_WEEK = "daysofweek";
124
125        /**
126         * True if alarm is active.
127         * <p>Type: BOOLEAN</p>
128         */
129        String ENABLED = "enabled";
130
131        /**
132         * Determine if alarm is deleted after it has been used.
133         * <p>Type: INTEGER</p>
134         */
135        String DELETE_AFTER_USE = "delete_after_use";
136    }
137
138    /**
139     * Constants for the Instance table, which contains the state of each alarm.
140     */
141    protected interface InstancesColumns extends AlarmSettingColumns, BaseColumns {
142        /**
143         * The content:// style URL for this table.
144         */
145        Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/instances");
146
147        /**
148         * Alarm state when to show no notification.
149         *
150         * Can transitions to:
151         * LOW_NOTIFICATION_STATE
152         */
153        int SILENT_STATE = 0;
154
155        /**
156         * Alarm state to show low priority alarm notification.
157         *
158         * Can transitions to:
159         * HIDE_NOTIFICATION_STATE
160         * HIGH_NOTIFICATION_STATE
161         * DISMISSED_STATE
162         */
163        int LOW_NOTIFICATION_STATE = 1;
164
165        /**
166         * Alarm state to hide low priority alarm notification.
167         *
168         * Can transitions to:
169         * HIGH_NOTIFICATION_STATE
170         */
171        int HIDE_NOTIFICATION_STATE = 2;
172
173        /**
174         * Alarm state to show high priority alarm notification.
175         *
176         * Can transitions to:
177         * DISMISSED_STATE
178         * FIRED_STATE
179         */
180        int HIGH_NOTIFICATION_STATE = 3;
181
182        /**
183         * Alarm state when alarm is in snooze.
184         *
185         * Can transitions to:
186         * DISMISSED_STATE
187         * FIRED_STATE
188         */
189        int SNOOZE_STATE = 4;
190
191        /**
192         * Alarm state when alarm is being fired.
193         *
194         * Can transitions to:
195         * DISMISSED_STATE
196         * SNOOZED_STATE
197         * MISSED_STATE
198         */
199        int FIRED_STATE = 5;
200
201        /**
202         * Alarm state when alarm has been missed.
203         *
204         * Can transitions to:
205         * DISMISSED_STATE
206         */
207        int MISSED_STATE = 6;
208
209        /**
210         * Alarm state when alarm is done.
211         */
212        int DISMISSED_STATE = 7;
213
214        /**
215         * Alarm state when alarm has been dismissed before its intended firing time.
216         */
217        int PREDISMISSED_STATE = 8;
218
219        /**
220         * Alarm year.
221         *
222         * <p>Type: INTEGER</p>
223         */
224        String YEAR = "year";
225
226        /**
227         * Alarm month in year.
228         *
229         * <p>Type: INTEGER</p>
230         */
231        String MONTH = "month";
232
233        /**
234         * Alarm day in month.
235         *
236         * <p>Type: INTEGER</p>
237         */
238        String DAY = "day";
239
240        /**
241         * Alarm hour in 24-hour localtime 0 - 23.
242         * <p>Type: INTEGER</p>
243         */
244        String HOUR = "hour";
245
246        /**
247         * Alarm minutes in localtime 0 - 59
248         * <p>Type: INTEGER</p>
249         */
250        String MINUTES = "minutes";
251
252        /**
253         * Foreign key to Alarms table
254         * <p>Type: INTEGER (long)</p>
255         */
256        String ALARM_ID = "alarm_id";
257
258        /**
259         * Alarm state
260         * <p>Type: INTEGER</p>
261         */
262        String ALARM_STATE = "alarm_state";
263    }
264}
265