ClockContract.java revision 8188813bc869d3df4885f9c2972f9cc85745b59b
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 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 */ 39public 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 */ 49 private ClockContract() {} 50 51 /** 52 * Constants for the Alarms table, which contains the user created alarms. 53 */ 54 protected interface AlarmsColumns extends BaseColumns { 55 /** 56 * The content:// style URL for this table. 57 */ 58 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/alarms"); 59 60 /** 61 * Hour in 24-hour localtime 0 - 23. 62 * <p>Type: INTEGER</p> 63 */ 64 public static final String HOUR = "hour"; 65 66 /** 67 * Minutes in localtime 0 - 59. 68 * <p>Type: INTEGER</p> 69 */ 70 public static final String MINUTES = "minutes"; 71 72 /** 73 * Alarm time in UTC milliseconds from the epoch. 74 * <p>Type: INTEGER</p> 75 */ 76 @Deprecated // Calculate this from the other fields 77 public static final String ALARM_TIME = "alarmtime"; 78 79 /** 80 * Days of the week encoded as a bit set. 81 * <p>Type: INTEGER</p> 82 * 83 * {@link DaysOfWeek} 84 */ 85 public static final String DAYS_OF_WEEK = "daysofweek"; 86 87 /** 88 * True if alarm is active. 89 * <p>Type: BOOLEAN</p> 90 */ 91 public static final String ENABLED = "enabled"; 92 93 /** 94 * True if alarm should vibrate 95 * <p>Type: BOOLEAN</p> 96 */ 97 public static final String VIBRATE = "vibrate"; 98 99 /** 100 * Message to show when alarm triggers 101 * Note: not currently used 102 * <p>Type: STRING</p> 103 */ 104 public static final String MESSAGE = "message"; 105 106 /** 107 * Audio alert to play when alarm triggers 108 * <p>Type: STRING</p> 109 */ 110 public static final String ALERT = "alert"; 111 112 /** 113 * Determine if alarm is deleted after it has been used. 114 * <p>Type: INTEGER</p> 115 */ 116 public static final String DELETE_AFTER_USE = "delete_after_use"; 117 } 118 119 /** 120 * Constants for the Instance table, which contains the state of each alarm. 121 */ 122 protected interface InstancesColumns extends BaseColumns { 123 /** 124 * The content:// style URL for this table. 125 */ 126 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/instances"); 127 128 /** 129 * Alarm year. 130 * 131 * <p>Type: INTEGER</p> 132 */ 133 public static final String YEAR = "year"; 134 135 /** 136 * Alarm month in year. 137 * 138 * <p>Type: INTEGER</p> 139 */ 140 public static final String MONTH = "month"; 141 142 /** 143 * Alarm day in month. 144 * 145 * <p>Type: INTEGER</p> 146 */ 147 public static final String DAY = "day"; 148 149 /** 150 * Alarm hour in 24-hour localtime 0 - 23. 151 * <p>Type: INTEGER</p> 152 */ 153 public static final String HOUR = "hour"; 154 155 /** 156 * Alarm minutes in localtime 0 - 59 157 * <p>Type: INTEGER</p> 158 */ 159 public static final String MINUTES = "minutes"; 160 161 /** 162 * Foreign key to Alarms table 163 * <p>Type: INTEGER (long)</p> 164 */ 165 public static final String ALARM_ID = "alarm_id"; 166 167 /** 168 * Alarm state 169 * <p>Type: INTEGER</p> 170 */ 171 public static final String ALARM_STATE = "alarm_state"; 172 } 173 174 /** 175 * Constants for the Cities table, which contains all selectable cities. 176 */ 177 protected interface CitiesColumns { 178 /** 179 * The content:// style URL for this table. 180 */ 181 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/cities"); 182 183 /** 184 * Primary id for city. 185 * <p>Type: STRING</p> 186 */ 187 public static final String CITY_ID = "city_id"; 188 189 /** 190 * City name. 191 * <p>Type: STRING</p> 192 */ 193 public static final String CITY_NAME = "city_name"; 194 195 /** 196 * Timezone name of city. 197 * <p>Type: STRING</p> 198 */ 199 public static final String TIMEZONE_NAME = "timezone_name"; 200 201 /** 202 * Timezone offset. 203 * <p>Type: INTEGER</p> 204 */ 205 public static final String TIMEZONE_OFFSET = "timezone_offset"; 206 } 207} 208