• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
16 package com.android.deskclock.provider;
17 
18 import android.net.Uri;
19 import android.provider.BaseColumns;
20 
21 /**
22  * <p>
23  * The contract between the clock provider and desk clock. Contains
24  * definitions for the supported URIs and data columns.
25  * </p>
26  * <h3>Overview</h3>
27  * <p>
28  * ClockContract defines the data model of clock related information.
29  * This data is stored in a number of tables:
30  * </p>
31  * <ul>
32  * <li>The {@link AlarmsColumns} table holds the user created alarms</li>
33  * <li>The {@link InstancesColumns} table holds the current state of each
34  * alarm in the AlarmsColumn table.
35  * </li>
36  * <li>The {@link CitiesColumns} table holds all user selectable cities</li>
37  * </ul>
38  */
39 public final class ClockContract {
40     /**
41      * This authority is used for writing to or querying from the clock
42      * provider.
43      */
44     public static final String AUTHORITY = "com.android.deskclock";
45 
46     /**
47      * This utility class cannot be instantiated
48      */
ClockContract()49     private ClockContract() {}
50 
51     /**
52      * Constants for tables with AlarmSettings.
53      */
54     private interface AlarmSettingColumns extends BaseColumns {
55         /**
56          * This string is used to indicate no ringtone.
57          */
58         public static final Uri NO_RINGTONE_URI = Uri.EMPTY;
59 
60         /**
61          * This string is used to indicate no ringtone.
62          */
63         public static final String NO_RINGTONE = NO_RINGTONE_URI.toString();
64 
65         /**
66          * True if alarm should vibrate
67          * <p>Type: BOOLEAN</p>
68          */
69         public static final String VIBRATE = "vibrate";
70 
71         /**
72          * Alarm label.
73          *
74          * <p>Type: STRING</p>
75          */
76         public static final String LABEL = "label";
77 
78         /**
79          * Audio alert to play when alarm triggers. Null entry
80          * means use system default and entry that equal
81          * Uri.EMPTY.toString() means no ringtone.
82          *
83          * <p>Type: STRING</p>
84          */
85         public static final String RINGTONE = "ringtone";
86     }
87 
88     /**
89      * Constants for the Alarms table, which contains the user created alarms.
90      */
91     protected interface AlarmsColumns extends AlarmSettingColumns, BaseColumns {
92         /**
93          * The content:// style URL for this table.
94          */
95         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/alarms");
96 
97         /**
98          * Hour in 24-hour localtime 0 - 23.
99          * <p>Type: INTEGER</p>
100          */
101         public static final String HOUR = "hour";
102 
103         /**
104          * Minutes in localtime 0 - 59.
105          * <p>Type: INTEGER</p>
106          */
107         public static final String MINUTES = "minutes";
108 
109         /**
110          * Days of the week encoded as a bit set.
111          * <p>Type: INTEGER</p>
112          *
113          * {@link DaysOfWeek}
114          */
115         public static final String DAYS_OF_WEEK = "daysofweek";
116 
117         /**
118          * True if alarm is active.
119          * <p>Type: BOOLEAN</p>
120          */
121         public static final String ENABLED = "enabled";
122 
123         /**
124          * Determine if alarm is deleted after it has been used.
125          * <p>Type: INTEGER</p>
126          */
127         public static final String DELETE_AFTER_USE = "delete_after_use";
128     }
129 
130     /**
131      * Constants for the Instance table, which contains the state of each alarm.
132      */
133     protected interface InstancesColumns extends AlarmSettingColumns, BaseColumns {
134         /**
135          * The content:// style URL for this table.
136          */
137         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/instances");
138 
139         /**
140          * Alarm state when to show no notification.
141          *
142          * Can transitions to:
143          * LOW_NOTIFICATION_STATE
144          */
145         public static final int SILENT_STATE = 0;
146 
147         /**
148          * Alarm state to show low priority alarm notification.
149          *
150          * Can transitions to:
151          * HIDE_NOTIFICATION_STATE
152          * HIGH_NOTIFICATION_STATE
153          * DISMISSED_STATE
154          */
155         public static final int LOW_NOTIFICATION_STATE = 1;
156 
157         /**
158          * Alarm state to hide low priority alarm notification.
159          *
160          * Can transitions to:
161          * HIGH_NOTIFICATION_STATE
162          */
163         public static final int HIDE_NOTIFICATION_STATE = 2;
164 
165         /**
166          * Alarm state to show high priority alarm notification.
167          *
168          * Can transitions to:
169          * DISMISSED_STATE
170          * FIRED_STATE
171          */
172         public static final int HIGH_NOTIFICATION_STATE = 3;
173 
174         /**
175          * Alarm state when alarm is in snooze.
176          *
177          * Can transitions to:
178          * DISMISSED_STATE
179          * FIRED_STATE
180          */
181         public static final int SNOOZE_STATE = 4;
182 
183         /**
184          * Alarm state when alarm is being fired.
185          *
186          * Can transitions to:
187          * DISMISSED_STATE
188          * SNOOZED_STATE
189          * MISSED_STATE
190          */
191         public static final int FIRED_STATE = 5;
192 
193         /**
194          * Alarm state when alarm has been missed.
195          *
196          * Can transitions to:
197          * DISMISSED_STATE
198          */
199         public static final int MISSED_STATE = 6;
200 
201         /**
202          * Alarm state when alarm is done.
203          */
204         public static final int DISMISSED_STATE = 7;
205 
206         /**
207          * Alarm state when alarm has been dismissed before its intended firing time.
208          */
209         public static final int PREDISMISSED_STATE = 8;
210 
211         /**
212          * Alarm year.
213          *
214          * <p>Type: INTEGER</p>
215          */
216         public static final String YEAR = "year";
217 
218         /**
219          * Alarm month in year.
220          *
221          * <p>Type: INTEGER</p>
222          */
223         public static final String MONTH = "month";
224 
225         /**
226          * Alarm day in month.
227          *
228          * <p>Type: INTEGER</p>
229          */
230         public static final String DAY = "day";
231 
232         /**
233          * Alarm hour in 24-hour localtime 0 - 23.
234          * <p>Type: INTEGER</p>
235          */
236         public static final String HOUR = "hour";
237 
238         /**
239          * Alarm minutes in localtime 0 - 59
240          * <p>Type: INTEGER</p>
241          */
242         public static final String MINUTES = "minutes";
243 
244         /**
245          * Foreign key to Alarms table
246          * <p>Type: INTEGER (long)</p>
247          */
248         public static final String ALARM_ID = "alarm_id";
249 
250         /**
251          * Alarm state
252          * <p>Type: INTEGER</p>
253          */
254         public static final String ALARM_STATE = "alarm_state";
255     }
256 
257     /**
258      * Constants for the Cities table, which contains all selectable cities.
259      */
260     protected interface CitiesColumns {
261         /**
262          * The content:// style URL for this table.
263          */
264         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/cities");
265 
266         /**
267          * Primary id for city.
268          * <p>Type: STRING</p>
269          */
270         public static final String CITY_ID = "city_id";
271 
272         /**
273          * City name.
274          * <p>Type: STRING</p>
275          */
276         public static final String CITY_NAME = "city_name";
277 
278         /**
279          * Timezone name of city.
280          * <p>Type: STRING</p>
281          */
282         public static final String TIMEZONE_NAME = "timezone_name";
283 
284         /**
285          * Timezone offset.
286          * <p>Type: INTEGER</p>
287          */
288         public static final String TIMEZONE_OFFSET = "timezone_offset";
289     }
290 }
291