blob: 57c4b722a3ab6310fdfd741c2720f71f981b07ca [file] [log] [blame]
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08001/*******************************************************************************
2 * Copyright (C) 2011 Google Inc.
3 * Licensed to The Android Open Source Project.
Mindy Pereira6f92de62011-12-19 11:31:48 -08004 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Mindy Pereira6f92de62011-12-19 11:31:48 -08008 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08009 * http://www.apache.org/licenses/LICENSE-2.0
Mindy Pereira6f92de62011-12-19 11:31:48 -080010 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -080011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
Mindy Pereira6f92de62011-12-19 11:31:48 -080017
Andy Huang30e2c242012-01-06 18:14:30 -080018package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080019
Paul Westbrook334e64a2012-02-23 13:26:35 -080020import android.content.ContentProvider;
21import android.content.ContentValues;
Mindy Pereira82cc5662012-01-09 17:29:30 -080022import android.content.Context;
Andy Huange0b83b82012-03-06 19:57:04 -080023import android.content.Intent;
Mindy Pereira6f92de62011-12-19 11:31:48 -080024import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080025import android.text.TextUtils;
Paul Westbrook334e64a2012-02-23 13:26:35 -080026import android.net.Uri;
Mindy Pereira82cc5662012-01-09 17:29:30 -080027
28import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080029
Paul Westbrook334e64a2012-02-23 13:26:35 -080030import java.lang.String;
Mindy Pereira82cc5662012-01-09 17:29:30 -080031import java.util.ArrayList;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080032
Mindy Pereira6f92de62011-12-19 11:31:48 -080033public class UIProvider {
Mindy Pereira82cc5662012-01-09 17:29:30 -080034 public static final String EMAIL_SEPARATOR = "\n";
Mindy Pereira326c6602012-01-04 15:32:42 -080035 public static final long INVALID_CONVERSATION_ID = -1;
36 public static final long INVALID_MESSAGE_ID = -1;
37
Marc Blank9ace18a2012-02-21 16:34:07 -080038 /**
39 * Values for the current state of a Folder/Account; note that it's possible that more than one
40 * sync is in progress
41 */
42 public static final class SyncStatus {
43 // No sync in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080044 public static final int NO_SYNC = 0;
Marc Blank9ace18a2012-02-21 16:34:07 -080045 // A user-requested sync/refresh is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080046 public static final int USER_REFRESH = 1<<0;
Marc Blank9ace18a2012-02-21 16:34:07 -080047 // A user-requested query is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080048 public static final int USER_QUERY = 1<<1;
Marc Blank9ace18a2012-02-21 16:34:07 -080049 // A user request for additional results is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080050 public static final int USER_MORE_RESULTS = 1<<2;
Marc Blank9ace18a2012-02-21 16:34:07 -080051 // A background sync is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080052 public static final int BACKGROUND_SYNC = 1<<3;
Marc Blank9ace18a2012-02-21 16:34:07 -080053 }
54
55 /**
56 * Values for the result of the last attempted sync of a Folder/Account
57 */
58 public static final class LastSyncResult {
59 // The sync completed successfully
60 public static final int SUCCESS = 0;
61 // The sync wasn't completed due to a connection error
62 public static final int CONNECTION_ERROR = 1;
63 // The sync wasn't completed due to an authentication error
64 public static final int AUTH_ERROR = 2;
65 // The sync wasn't completed due to a security error
66 public static final int SECURITY_ERROR = 3;
67 // The sync wasn't completed due to a low memory condition
68 public static final int STORAGE_ERROR = 4;
69 // The sync wasn't completed due to an internal error/exception
70 public static final int INTERNAL_ERROR = 5;
71 }
72
Paul Westbrook82ea6da2011-12-15 11:03:51 -080073 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -080074 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080075
76 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080077 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080078 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080079 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080080
81 public static final String[] ACCOUNTS_PROJECTION = {
82 BaseColumns._ID,
83 AccountColumns.NAME,
84 AccountColumns.PROVIDER_VERSION,
85 AccountColumns.URI,
86 AccountColumns.CAPABILITIES,
87 AccountColumns.FOLDER_LIST_URI,
88 AccountColumns.SEARCH_URI,
89 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Mindy Pereira33fe9082012-01-09 16:24:30 -080090 AccountColumns.SAVE_DRAFT_URI,
Mindy Pereira7ed1c112012-01-18 10:59:25 -080091 AccountColumns.SEND_MAIL_URI,
Mindy Pereira96b5c352012-02-01 11:33:40 -080092 AccountColumns.EXPUNGE_MESSAGE_URI,
Mindy Pereira9600dac2012-02-17 15:59:25 -080093 AccountColumns.UNDO_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -080094 AccountColumns.SETTINGS_INTENT_URI,
Paul Westbrook63eef792012-02-27 14:01:06 -080095 AccountColumns.SETTINGS_QUERY_URI,
Paul Westbrook94e440d2012-02-24 11:03:47 -080096 AccountColumns.SYNC_STATUS,
Mindy Pereira23755e22012-02-27 13:58:04 -080097 AccountColumns.HELP_INTENT_URI,
Mindy Pereira898cd382012-03-06 08:42:47 -080098 AccountColumns.COMPOSE_URI,
Vikram Aggarwal27e85f22012-03-05 16:29:17 -080099 AccountColumns.MIME_TYPE,
100 AccountColumns.RECENT_FOLDER_LIST_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -0800101 };
102
Mindy Pereira33fe9082012-01-09 16:24:30 -0800103 public static final int ACCOUNT_ID_COLUMN = 0;
104 public static final int ACCOUNT_NAME_COLUMN = 1;
105 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
106 public static final int ACCOUNT_URI_COLUMN = 3;
107 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
108 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
109 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
110 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
111 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
112 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800113 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800114 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800115 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800116 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
117 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
118 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
119 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira898cd382012-03-06 08:42:47 -0800120 public static final int ACCOUNT_MIME_TYPE_COLUMN = 17;
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800121 public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 18;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800122
Mindy Pereira6f92de62011-12-19 11:31:48 -0800123 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800124 /**
125 * Whether folders can be synchronized back to the server.
126 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800127 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800128 /**
129 * Whether the server allows reporting spam back.
130 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800131 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800132 /**
133 * Whether the server supports a concept of Archive: removing mail from the Inbox but
134 * keeping it around.
135 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800136 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800137 /**
138 * Whether the server will stop notifying on updates to this thread? This requires
139 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
140 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800141 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800142 /**
143 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
144 * to be true, otherwise it should be ignored.
145 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800146 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800147 /**
148 * Whether the server supports constraining search to a single folder. Requires
149 * SYNCABLE_FOLDERS, otherwise it should be ignored.
150 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800151 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800152 /**
153 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
154 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800155 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800156 /**
157 * Whether the server allows synchronization of draft messages. This does NOT require
158 * SYNCABLE_FOLDERS to be set.
159 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800160 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800161 /**
162 * Does the server allow the user to compose mails (and reply) using addresses other than
163 * their account name? For instance, GMail allows users to set FROM addresses that are
164 * different from account@gmail.com address. For instance, user@gmail.com could have another
165 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
166 * can compose (and reply) using either address.
167 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800168 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800169 /**
170 * Whether the server allows the original message to be included in the reply by setting a
171 * flag on the reply. If we can avoid including the entire previous message, we save on
172 * bandwidth (replies are shorter).
173 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800174 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800175 /**
176 * Does this account support searching locally, on the device? This requires the backend
177 * storage to support a mechanism for searching.
178 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800179 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800180 /**
181 * Whether the server supports a notion of threaded conversations: where replies to messages
182 * are tagged to keep conversations grouped. This could be full threading (each message
183 * lists its parent) or conversation-level threading (each message lists one conversation
184 * which it belongs to)
185 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800186 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800187 /**
188 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
Mindy Pereira30fd47b2012-03-09 09:24:00 -0800189 * multiple folders on a single conversation)
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800190 */
Mindy Pereira84648892012-02-03 08:29:55 -0800191 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800192 /**
193 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
194 */
195 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800196 /**
197 * Whether the account provides help content.
198 */
199 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800200 /**
201 * Whether the account provides a mechanism for marking conversations as important.
202 */
203 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800204 }
205
206 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800207 /**
208 * This string column contains the human visible name for the account.
209 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800210 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800211
212 /**
213 * This integer column returns the version of the UI provider schema from which this
214 * account provider will return results.
215 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800216 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800217
218 /**
219 * This string column contains the uri to directly access the information for this account.
220 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800221 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800222
223 /**
Andy Huange0b83b82012-03-06 19:57:04 -0800224 * This integer column contains a bit field of the possible capabilities that this account
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800225 * supports.
226 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800227 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800228
229 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800230 * This string column contains the content provider uri to return the
231 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800232 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800233 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800234
235 /**
236 * This string column contains the content provider uri that can be queried for search
237 * results.
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800238 * The supported query parameters are limited to those listed
239 * in {@link #SearchQueryParameters}
Paul Westbrook1475a7a2012-03-08 15:06:27 -0800240 * The cursor returned from this query is expected have one row, where the columnm are a
241 * subset of the columns specified in {@link #FolderColumns}
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800242 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800243 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800244
245 /**
246 * This string column contains the content provider uri that can be queried to access the
247 * from addresses for this account.
248 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800249 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800250
251 /**
252 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800253 * new draft messages for this account. NOTE: This might be better to
254 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800255 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800256 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800257
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800258 /**
259 * This string column contains the content provider uri that can be used to send
260 * a message for this account.
261 * NOTE: This might be better to be an update operation on the messageUri.
262 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800263 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800264
265 /**
266 * This string column contains the content provider uri that can be used
267 * to expunge a message from this account. NOTE: This might be better to
268 * be an update operation on the messageUri.
269 */
270 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800271
272 /**
273 * This string column contains the content provider uri that can be used
274 * to undo the last committed action.
275 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800276 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800277
278 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800279 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800280 * shown.
281 * TODO: When we want to support a heterogeneous set of account types, this value may need
282 * to be moved to a global content provider.
283 */
284 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800285
286 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800287 * This string column contains the content provider uri that can be used to query user
288 * settings/preferences.
289 *
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800290 * The cursor returned by this query support columns declared in {@link #SettingsColumns}
Paul Westbrook63eef792012-02-27 14:01:06 -0800291 */
292 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
293
294 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800295 * Uri for VIEW intent that will cause the help screens for this account type to be
296 * shown.
297 * TODO: When we want to support a heterogeneous set of account types, this value may need
298 * to be moved to a global content provider.
299 */
300 public static String HELP_INTENT_URI = "helpIntentUri";
301
302 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800303 * This int column contains the current sync status of the account (the logical AND of the
304 * sync status of folders in this account)
305 */
306 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800307 /**
308 * Uri for VIEW intent that will cause the compose screens for this type
309 * of account to be shown.
310 */
311 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800312 /**
313 * Mime-type defining this account.
314 */
315 public static final String MIME_TYPE = "mimeType";
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800316 /**
317 * URI for location of recent folders viewed on this account.
318 */
319 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800320 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800321
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800322 public static final class SearchQueryParameters {
323 /**
324 * Parameter used to specify the search query.
325 */
326 public static final String QUERY = "query";
327
328 /**
329 * If specified, the query results will be limited to this folder.
330 */
331 public static final String FOLDER = "folder";
332
333 private SearchQueryParameters() {}
334 }
335
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800336 // We define a "folder" as anything that contains a list of conversations.
337 public static final String FOLDER_LIST_TYPE =
338 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
339 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800340 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800341
342 public static final String[] FOLDERS_PROJECTION = {
343 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800344 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800345 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800346 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800347 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800348 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800349 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800350 FolderColumns.CHILD_FOLDERS_LIST_URI,
351 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800352 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800353 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800354 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800355 FolderColumns.LAST_SYNC_RESULT,
356 FolderColumns.TYPE,
Mindy Pereira9275a062012-03-08 15:12:14 -0800357 FolderColumns.ICON_RES_ID,
358 FolderColumns.BG_COLOR,
359 FolderColumns.FG_COLOR
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800360 };
361
Mindy Pereira818143e2012-01-11 13:59:49 -0800362 public static final int FOLDER_ID_COLUMN = 0;
363 public static final int FOLDER_URI_COLUMN = 1;
364 public static final int FOLDER_NAME_COLUMN = 2;
365 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
366 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800367 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
368 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
369 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
370 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
371 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
372 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
373 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
374 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800375 public static final int FOLDER_TYPE_COLUMN = 13;
376 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
Mindy Pereira9275a062012-03-08 15:12:14 -0800377 public static final int FOLDER_BG_COLOR_COLUMN = 15;
378 public static final int FOLDER_FG_COLOR_COLUMN = 16;
Mindy Pereira78664722012-03-05 13:53:07 -0800379
380 public static final class FolderType {
381 public static final int DEFAULT = 0;
382 public static final int INBOX = 1;
383 public static final int DRAFT = 2;
384 public static final int OUTBOX = 3;
385 public static final int SENT = 4;
386 public static final int TRASH = 5;
387 public static final int SPAM = 6;
388 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800389
Mindy Pereira0973b202011-12-21 15:48:12 -0800390 public static final class FolderCapabilities {
391 public static final int SYNCABLE = 0x0001;
392 public static final int PARENT = 0x0002;
393 public static final int CAN_HOLD_MAIL = 0x0004;
394 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800395 /**
396 * For accounts that support archive, this will indicate that this folder supports
397 * the archive functionality.
398 */
399 public static final int ARCHIVE = 0x0010;
400
401 /**
402 * For accounts that support report spam, this will indicate that this folder supports
403 * the report spam functionality.
404 */
405 public static final int REPORT_SPAM = 0x0020;
406
407 /**
408 * For accounts that support mute, this will indicate if a mute is performed from within
409 * this folder, the action is destructive.
410 */
411 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800412 }
413
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800414 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800415 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800416 /**
417 * This string column contains the human visible name for the folder.
418 */
419 public static final String NAME = "name";
420 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800421 * This int column represents the capabilities of the folder specified by
422 * FolderCapabilities flags.
423 */
424 public static String CAPABILITIES = "capabilities";
425 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800426 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800427 * child folders.
428 */
429 public static String HAS_CHILDREN = "hasChildren";
430 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800431 * This int column represents how large the sync window is.
432 */
433 public static String SYNC_WINDOW = "syncWindow";
434 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800435 * This string column contains the content provider uri to return the
436 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800437 */
438 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800439 /**
440 * This string column contains the content provider uri to return the
441 * list of child folders of this folder.
442 */
Mindy Pereira77528642012-02-17 15:51:10 -0800443 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800444
Mindy Pereira77528642012-02-17 15:51:10 -0800445 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800446
Mindy Pereira77528642012-02-17 15:51:10 -0800447 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800448 /**
449 * This string column contains the content provider uri to force a
450 * refresh of this folder.
451 */
Mindy Pereira77528642012-02-17 15:51:10 -0800452 public static final String REFRESH_URI = "refreshUri";
453 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800454 * This int column contains current sync status of the folder; some combination of the
455 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800456 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800457 public static final String SYNC_STATUS = "syncStatus";
458 /**
459 * This int column contains the sync status of the last sync attempt; one of the
460 * LastSyncStatus values defined above
461 */
462 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800463 /**
464 * This long column contains the icon res id for this folder, or 0 if there is none.
465 */
466 public static final String ICON_RES_ID = "iconResId";
467 /**
468 * This int column contains the type of the folder. Zero is default.
469 */
470 public static final String TYPE = "type";
Mindy Pereira9275a062012-03-08 15:12:14 -0800471 /**
472 * String representing the integer background color associated with this
473 * folder, or null.
474 */
475 public static final String BG_COLOR = "bgColor";
476 /**
477 * String representing the integer of the foreground color associated
478 * with this folder, or null.
479 */
480 public static final String FG_COLOR = "fgColor";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800481 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800482 }
483
Mindy Pereiraa1406072011-12-22 10:54:06 -0800484 // We define a "folder" as anything that contains a list of conversations.
485 public static final String CONVERSATION_LIST_TYPE =
486 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
487 public static final String CONVERSATION_TYPE =
488 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
489
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800490
Mindy Pereiraa1406072011-12-22 10:54:06 -0800491 public static final String[] CONVERSATION_PROJECTION = {
492 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800493 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800494 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800495 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800496 ConversationColumns.SNIPPET,
497 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800498 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800499 ConversationColumns.HAS_ATTACHMENTS,
500 ConversationColumns.NUM_MESSAGES,
501 ConversationColumns.NUM_DRAFTS,
502 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800503 ConversationColumns.PRIORITY,
504 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800505 ConversationColumns.STARRED,
506 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800507 };
508
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800509 // These column indexes only work when the caller uses the
510 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800511 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800512 public static final int CONVERSATION_URI_COLUMN = 1;
513 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
514 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
515 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
516 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
517 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
518 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800519 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
520 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
521 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
522 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800523 public static final int CONVERSATION_READ_COLUMN = 12;
524 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800525 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800526
527 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800528 public static final int OTHER = 0;
529 public static final int SENDING = 1;
530 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800531 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800532 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800533
534 public static final class ConversationPriority {
535 public static final int LOW = 0;
536 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800537 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800538
Marc Blankc8a99422012-01-19 14:27:47 -0800539 public static final class ConversationFlags {
540 public static final int READ = 1<<0;
541 public static final int STARRED = 1<<1;
542 public static final int REPLIED = 1<<2;
543 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800544 }
Marc Blankc8a99422012-01-19 14:27:47 -0800545
Mindy Pereiraa1406072011-12-22 10:54:06 -0800546 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800547 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800548 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800549 * This string column contains the content provider uri to return the
550 * list of messages for this conversation.
551 */
552 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800553 /**
554 * This string column contains the subject string for a conversation.
555 */
556 public static final String SUBJECT = "subject";
557 /**
558 * This string column contains the snippet string for a conversation.
559 */
560 public static final String SNIPPET = "snippet";
561 /**
562 * This string column contains the sender info string for a
563 * conversation.
564 */
565 public static final String SENDER_INFO = "senderInfo";
566 /**
567 * This long column contains the time in ms of the latest update to a
568 * conversation.
569 */
570 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
571
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800572 /**
573 * This boolean column contains whether any messages in this conversation
574 * have attachments.
575 */
576 public static final String HAS_ATTACHMENTS = "hasAttachments";
577
Mindy Pereira4db59c52012-01-12 09:45:13 -0800578 /**
579 * This int column contains the number of messages in this conversation.
580 * For unthreaded, this will always be 1.
581 */
582 public static String NUM_MESSAGES = "numMessages";
583
584 /**
585 * This int column contains the number of drafts associated with this
586 * conversation.
587 */
588 public static String NUM_DRAFTS = "numDrafts";
589
590 /**
591 * This int column contains the state of drafts and replies associated
592 * with this conversation. Use ConversationSendingState to interpret
593 * this field.
594 */
595 public static String SENDING_STATE = "sendingState";
596
597 /**
598 * This int column contains the priority of this conversation. Use
599 * ConversationPriority to interpret this field.
600 */
601 public static String PRIORITY = "priority";
602
Marc Blankc8a99422012-01-19 14:27:47 -0800603 /**
604 * This boolean column indicates whether the conversation has been read
605 */
606 public static String READ = "read";
607
608 /**
609 * This boolean column indicates whether the conversation has been read
610 */
611 public static String STARRED = "starred";
612
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800613 /**
614 * This string column contains a csv of all folders associated with this
615 * conversation
616 */
617 public static final String FOLDER_LIST = "folderList";
618
Paul Westbrook334e64a2012-02-23 13:26:35 -0800619 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800620 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800621 }
622
Mindy Pereira6f92de62011-12-19 11:31:48 -0800623 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800624 * List of operations that can can be performed on a conversation. These operations are applied
625 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
626 * where the conversation uri is specified, and the ContentValues specifies the operation to
627 * be performed.
628 * <p/>
629 * The operation to be performed is specified in the ContentValues by
630 * the {@link ConversationOperations#OPERATION_KEY}
631 * <p/>
632 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
633 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800634 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800635 public static final class ConversationOperations {
636 /**
637 * ContentValues key used to specify the operation to be performed
638 */
639 public static final String OPERATION_KEY = "operation";
640
641 /**
642 * Archive operation
643 */
644 public static final String ARCHIVE = "archive";
645
646 /**
647 * Mute operation
648 */
649 public static final String MUTE = "mute";
650
651 /**
652 * Report spam operation
653 */
654 public static final String REPORT_SPAM = "report_spam";
655
656 private ConversationOperations() {
657 }
658 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800659
660 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800661 public static final int NOT_A_DRAFT = 0;
662 public static final int COMPOSE = 1;
663 public static final int REPLY = 2;
664 public static final int REPLY_ALL = 3;
665 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800666
667 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800668 }
669
Mindy Pereiraa1406072011-12-22 10:54:06 -0800670 public static final String[] MESSAGE_PROJECTION = {
671 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800672 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800673 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800674 MessageColumns.CONVERSATION_ID,
675 MessageColumns.SUBJECT,
676 MessageColumns.SNIPPET,
677 MessageColumns.FROM,
678 MessageColumns.TO,
679 MessageColumns.CC,
680 MessageColumns.BCC,
681 MessageColumns.REPLY_TO,
682 MessageColumns.DATE_RECEIVED_MS,
683 MessageColumns.BODY_HTML,
684 MessageColumns.BODY_TEXT,
685 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
686 MessageColumns.REF_MESSAGE_ID,
687 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800688 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800689 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800690 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800691 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800692 MessageColumns.JOINED_ATTACHMENT_INFOS,
693 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800694 MessageColumns.SEND_MESSAGE_URI,
695 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800696 };
697
Mindy Pereiraf944e962012-01-17 11:43:36 -0800698 /** Separates attachment info parts in strings in a message. */
699 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800700 public static final String MESSAGE_LIST_TYPE =
701 "vnd.android.cursor.dir/vnd.com.android.mail.message";
702 public static final String MESSAGE_TYPE =
703 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800704
Mindy Pereira6349a042012-01-04 11:25:01 -0800705 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800706 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
707 public static final int MESSAGE_URI_COLUMN = 2;
708 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
709 public static final int MESSAGE_SUBJECT_COLUMN = 4;
710 public static final int MESSAGE_SNIPPET_COLUMN = 5;
711 public static final int MESSAGE_FROM_COLUMN = 6;
712 public static final int MESSAGE_TO_COLUMN = 7;
713 public static final int MESSAGE_CC_COLUMN = 8;
714 public static final int MESSAGE_BCC_COLUMN = 9;
715 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
716 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800717 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
718 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800719 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
720 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
721 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800722 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
723 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
724 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
725 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800726 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800727 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
728 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800729 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800730
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800731 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800732 public static final int STARRED = 1 << 0;
733 public static final int UNREAD = 1 << 1;
734 public static final int REPLIED = 1 << 2;
735 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800736 }
737
Mindy Pereira6f92de62011-12-19 11:31:48 -0800738 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800739 /**
740 * This string column contains a content provider URI that points to this single message.
741 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800742 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800743 /**
744 * This string column contains a server-assigned ID for this message.
745 */
746 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800747 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800748 /**
749 * This string column contains the subject of a message.
750 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800751 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800752 /**
753 * This string column contains a snippet of the message body.
754 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800755 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800756 /**
757 * This string column contains the single email address (and optionally name) of the sender.
758 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800759 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800760 /**
761 * This string column contains a comma-delimited list of "To:" recipient email addresses.
762 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800763 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800764 /**
765 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
766 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800767 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800768 /**
769 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
770 * This value will be null for incoming messages.
771 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800772 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800773 /**
774 * This string column contains the single email address (and optionally name) of the
775 * sender's reply-to address.
776 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800777 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800778 /**
779 * This long column contains the timestamp (in millis) of receipt of the message.
780 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800781 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800782 /**
783 * This string column contains the HTML form of the message body, if available. If not,
784 * a provider must populate BODY_TEXT.
785 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800786 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800787 /**
788 * This string column contains the plaintext form of the message body, if HTML is not
789 * otherwise available. If HTML is available, this value should be left empty (null).
790 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800791 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800792 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800793 /**
794 * This string column contains an opaque string used by the sendMessage api.
795 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800796 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800797 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800798 * This integer column contains the type of this draft, or zero (0) if this message is not a
799 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800800 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800801 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800802 /**
803 * This boolean column indicates whether an outgoing message should trigger special quoted
804 * text processing upon send. The value should default to zero (0) for protocols that do
805 * not support or require this flag, and for all incoming messages.
806 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800807 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800808 /**
809 * This boolean column indicates whether a message has attachments. The list of attachments
810 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
811 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800812 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800813 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800814 * This string column contains the content provider URI for the list of
815 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800816 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800817 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800818 /**
819 * This long column is a bit field of flags defined in {@link MessageFlags}.
820 */
Andy Huang732600e2012-01-10 17:47:17 -0800821 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800822 /**
823 * This string column contains a specially formatted string representing all
824 * attachments that we added to a message that is being sent or saved.
825 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800826 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800827 /**
828 * This string column contains the content provider URI for saving this
829 * message.
830 */
831 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
832 /**
833 * This string column contains content provider URI for sending this
834 * message.
835 */
836 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800837
Paul Westbrook104f7292012-02-28 16:07:07 -0800838 /**
839 * This integer column represents whether the user has specified that images should always
840 * be shown. The value of "1" indicates that the user has specified that images should be
841 * shown, while the value of "0" indicates that the user should be prompted before loading
842 * any external images.
843 */
844 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
845
Mindy Pereira6f92de62011-12-19 11:31:48 -0800846 private MessageColumns() {}
847 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800848
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800849 public static final String ATTACHMENT_LIST_TYPE =
850 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
851 public static final String ATTACHMENT_TYPE =
852 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
853
854 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800855 AttachmentColumns.NAME,
856 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800857 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800858 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -0800859 AttachmentColumns.STATE,
860 AttachmentColumns.DESTINATION,
861 AttachmentColumns.DOWNLOADED_SIZE,
862 AttachmentColumns.CONTENT_URI,
863 AttachmentColumns.THUMBNAIL_URI,
864 AttachmentColumns.PREVIEW_INTENT
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800865 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800866 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -0800867 public static final int ATTACHMENT_NAME_COLUMN = 0;
868 public static final int ATTACHMENT_SIZE_COLUMN = 1;
869 public static final int ATTACHMENT_URI_COLUMN = 2;
870 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
871 public static final int ATTACHMENT_STATE_COLUMN = 4;
872 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
873 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
874 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
875 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
876 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800877
Andy Huange0b83b82012-03-06 19:57:04 -0800878 /**
879 * Valid states for the {@link AttachmentColumns#STATE} column.
880 *
881 */
882 public static final class AttachmentState {
883 /**
884 * The full attachment is not present on device. When used as a command,
885 * setting this state will tell the provider to cancel a download in
886 * progress.
887 * <p>
888 * Valid next states: {@link #DOWNLOADING}
889 */
890 public static final int NOT_SAVED = 0;
891 /**
892 * The most recent attachment download attempt failed. The current UI
893 * design does not require providers to persist this state, but
894 * providers must return this state at least once after a download
895 * failure occurs. This state may not be used as a command.
896 * <p>
897 * Valid next states: {@link #DOWNLOADING}
898 */
899 public static final int FAILED = 1;
900 /**
901 * The attachment is currently being downloaded by the provider.
902 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
903 * download progress while in this state. When used as a command,
904 * setting this state will tell the provider to initiate a download to
905 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
906 * .
907 * <p>
908 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
909 * {@link #SAVED}
910 */
911 public static final int DOWNLOADING = 2;
912 /**
913 * The attachment was successfully downloaded to the destination in
914 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
915 * that a download is missing, it should reset the state to
916 * {@link #NOT_SAVED}. This state may not be used as a command on its
917 * own. To move a file from cache to external, update
918 * {@link AttachmentColumns#DESTINATION}.
919 * <p>
920 * Valid next states: {@link #NOT_SAVED}
921 */
922 public static final int SAVED = 3;
923
924 private AttachmentState() {}
925 }
926
927 public static final class AttachmentDestination {
928
929 /**
930 * The attachment will be or is already saved to the app-private cache partition.
931 */
932 public static final int CACHE = 0;
933 /**
934 * The attachment will be or is already saved to external shared device storage.
935 */
936 public static final int EXTERNAL = 1;
937
938 private AttachmentDestination() {}
939 }
940
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800941 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -0800942 /**
943 * This string column is the attachment's file name, intended for display in UI. It is not
944 * the full path of the file.
945 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800946 public static final String NAME = "name";
Andy Huange0b83b82012-03-06 19:57:04 -0800947 /**
948 * This integer column is the file size of the attachment, in bytes.
949 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800950 public static final String SIZE = "size";
Andy Huange0b83b82012-03-06 19:57:04 -0800951 /**
952 * This column is a {@link Uri} that can be queried to monitor download state and progress
953 * for this individual attachment (resulting cursor has one single row for this attachment).
954 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800955 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -0800956 /**
957 * This string column is the MIME type of the attachment.
958 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800959 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -0800960 /**
961 * This integer column is the current downloading state of the
962 * attachment as defined in {@link AttachmentState}.
963 * <p>
964 * Providers must accept updates to {@link URI} with new values of
965 * this column to initiate or cancel downloads.
966 */
967 public static final String STATE = "state";
968 /**
969 * This integer column is the file destination for the current download
970 * in progress (when {@link #STATE} is
971 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
972 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
973 * in {@link AttachmentDestination}. This value is undefined in any
974 * other state.
975 * <p>
976 * Providers must accept updates to {@link URI} with new values of
977 * this column to move an existing downloaded file.
978 */
979 public static final String DESTINATION = "destination";
980 /**
981 * This integer column is the current number of bytes downloaded when
982 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
983 * undefined in any other state.
984 */
985 public static final String DOWNLOADED_SIZE = "downloadedSize";
986 /**
987 * This column is a {@link Uri} that points to the downloaded local file
988 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
989 * undefined in any other state.
990 */
991 public static final String CONTENT_URI = "contentUri";
992 /**
993 * This column is a {@link Uri} that points to a local thumbnail file
994 * for the attachment. Providers that do not support downloading
995 * attachment thumbnails may leave this null.
996 */
997 public static final String THUMBNAIL_URI = "thumbnailUri";
998 /**
999 * This column is an {@link Intent} to launch a preview activity that
1000 * allows the user to efficiently view an attachment without having to
1001 * first download the entire file. Providers that do not support
1002 * previewing attachments may leave this null. The intent is represented
1003 * as a byte-array blob generated by writing an Intent to a parcel and
1004 * then marshaling that parcel.
1005 */
1006 public static final String PREVIEW_INTENT = "previewIntent";
1007
1008 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001009 }
Mindy Pereira013194c2012-01-06 15:09:33 -08001010
1011 public static int getMailMaxAttachmentSize(String account) {
1012 // TODO: query the account to see what the max attachment size is?
1013 return 5 * 1024 * 1024;
1014 }
1015
1016 public static String getAttachmentTypeSetting() {
1017 // TODO: query the account to see what kinds of attachments it supports?
1018 return "com.google.android.gm.allowAddAnyAttachment";
1019 }
Mindy Pereira82cc5662012-01-09 17:29:30 -08001020
1021 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1022 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1023 ArrayList<String> recipients = new ArrayList<String>();
1024 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1025 for (String address : addresses) {
1026 recipients.add(address);
1027 }
1028 statsUpdater.updateWithAddress(recipients);
1029 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001030
1031 public static final String[] UNDO_PROJECTION = {
1032 ConversationColumns.MESSAGE_LIST_URI
1033 };
1034 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001035
1036 // Parameter used to indicate the sequence number for an undoable operation
1037 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001038
1039
1040 public static final String[] SETTINGS_PROJECTION = {
1041 SettingsColumns.SIGNATURE,
1042 SettingsColumns.AUTO_ADVANCE,
1043 SettingsColumns.MESSAGE_TEXT_SIZE,
1044 SettingsColumns.SNAP_HEADERS,
1045 SettingsColumns.REPLY_BEHAVIOR,
1046 SettingsColumns.HIDE_CHECKBOXES,
1047 SettingsColumns.CONFIRM_DELETE,
1048 SettingsColumns.CONFIRM_ARCHIVE,
1049 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -08001050 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -08001051 };
1052
Mindy Pereira8bd82152012-03-01 10:06:35 -08001053 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
1054 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
1055 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
1056 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
1057 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
1058 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
1059 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
1060 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
1061 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
1062 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
1063
Paul Westbrook63eef792012-02-27 14:01:06 -08001064 public static final class AutoAdvance {
1065 public static final int UNSET = 0;
1066 public static final int OLDER = 1;
1067 public static final int NEWER = 2;
1068 public static final int LIST = 3;
1069 }
1070
1071 public static final class SnapHeaderValue {
1072 public static final int ALWAYS = 0;
1073 public static final int PORTRAIT_ONLY = 1;
1074 public static final int NEVER = 2;
1075 }
1076
1077 public static final class MessageTextSize {
1078 public static final int TINY = -2;
1079 public static final int SMALL = -1;
1080 public static final int NORMAL = 0;
1081 public static final int LARGE = 1;
1082 public static final int HUGE = 2;
1083 }
1084
1085 public static final class DefaultReplyBehavior {
1086 public static final int REPLY = 0;
1087 public static final int REPLY_ALL = 1;
1088 }
1089
1090 public static final class SettingsColumns {
1091 /**
1092 * String column containing the contents of the signature for this account. If no
1093 * signature has been specified, the value will be null.
1094 */
1095 public static final String SIGNATURE = "signature";
1096
1097 /**
1098 * Integer column containing the user's specified auto-advance policy. This value will be
1099 * one of the values in {@link UIProvider.AutoAdvance}
1100 */
1101 public static final String AUTO_ADVANCE = "auto_advance";
1102
1103 /**
1104 * Integer column containing the user's specified message text size preference. This value
1105 * will be one of the values in {@link UIProvider.MessageTextSize}
1106 */
1107 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
1108
1109 /**
1110 * Integer column contaning the user's specified snap header preference. This value
1111 * will be one of the values in {@link UIProvider.SnapHeaderValue}
1112 */
1113 public static final String SNAP_HEADERS = "snap_headers";
1114
1115 /**
1116 * Integer column containing the user's specified default reply behavior. This value will
1117 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
1118 */
1119 public static final String REPLY_BEHAVIOR = "reply_behavior";
1120
1121 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -08001122 * Integer column containing the user's specified checkbox preference. A
1123 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -08001124 */
1125 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
1126
1127 /**
1128 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001129 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001130 * be shown when a delete action is performed.
1131 */
1132 public static final String CONFIRM_DELETE = "confirm_delete";
1133
1134 /**
1135 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001136 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001137 * be shown when an archive action is performed.
1138 */
1139 public static final String CONFIRM_ARCHIVE = "confirm_archive";
1140
1141 /**
1142 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001143 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001144 * be shown when a send action is performed.
1145 */
1146 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -08001147 /**
1148 * String folder containing the serialized default inbox folder for an account.
1149 */
1150 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001151 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001152}