blob: 568922766e7bc5cbc7993f5286bf947b80ffb555 [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 Westbrook82ea6da2011-12-15 11:03:51 -0800240 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800241 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800242
243 /**
244 * This string column contains the content provider uri that can be queried to access the
245 * from addresses for this account.
246 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800247 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800248
249 /**
250 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800251 * new draft messages for this account. NOTE: This might be better to
252 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800253 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800254 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800255
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800256 /**
257 * This string column contains the content provider uri that can be used to send
258 * a message for this account.
259 * NOTE: This might be better to be an update operation on the messageUri.
260 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800261 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800262
263 /**
264 * This string column contains the content provider uri that can be used
265 * to expunge a message from this account. NOTE: This might be better to
266 * be an update operation on the messageUri.
267 */
268 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800269
270 /**
271 * This string column contains the content provider uri that can be used
272 * to undo the last committed action.
273 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800274 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800275
276 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800277 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800278 * shown.
279 * TODO: When we want to support a heterogeneous set of account types, this value may need
280 * to be moved to a global content provider.
281 */
282 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800283
284 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800285 * This string column contains the content provider uri that can be used to query user
286 * settings/preferences.
287 *
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800288 * The cursor returned by this query support columns declared in {@link #SettingsColumns}
Paul Westbrook63eef792012-02-27 14:01:06 -0800289 */
290 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
291
292 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800293 * Uri for VIEW intent that will cause the help screens for this account type to be
294 * shown.
295 * TODO: When we want to support a heterogeneous set of account types, this value may need
296 * to be moved to a global content provider.
297 */
298 public static String HELP_INTENT_URI = "helpIntentUri";
299
300 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800301 * This int column contains the current sync status of the account (the logical AND of the
302 * sync status of folders in this account)
303 */
304 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800305 /**
306 * Uri for VIEW intent that will cause the compose screens for this type
307 * of account to be shown.
308 */
309 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800310 /**
311 * Mime-type defining this account.
312 */
313 public static final String MIME_TYPE = "mimeType";
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800314 /**
315 * URI for location of recent folders viewed on this account.
316 */
317 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800318 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800319
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800320 public static final class SearchQueryParameters {
321 /**
322 * Parameter used to specify the search query.
323 */
324 public static final String QUERY = "query";
325
326 /**
327 * If specified, the query results will be limited to this folder.
328 */
329 public static final String FOLDER = "folder";
330
331 private SearchQueryParameters() {}
332 }
333
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800334 // We define a "folder" as anything that contains a list of conversations.
335 public static final String FOLDER_LIST_TYPE =
336 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
337 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800338 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800339
340 public static final String[] FOLDERS_PROJECTION = {
341 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800342 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800343 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800344 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800345 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800346 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800347 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800348 FolderColumns.CHILD_FOLDERS_LIST_URI,
349 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800350 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800351 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800352 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800353 FolderColumns.LAST_SYNC_RESULT,
354 FolderColumns.TYPE,
Mindy Pereira9275a062012-03-08 15:12:14 -0800355 FolderColumns.ICON_RES_ID,
356 FolderColumns.BG_COLOR,
357 FolderColumns.FG_COLOR
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800358 };
359
Mindy Pereira818143e2012-01-11 13:59:49 -0800360 public static final int FOLDER_ID_COLUMN = 0;
361 public static final int FOLDER_URI_COLUMN = 1;
362 public static final int FOLDER_NAME_COLUMN = 2;
363 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
364 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800365 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
366 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
367 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
368 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
369 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
370 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
371 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
372 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800373 public static final int FOLDER_TYPE_COLUMN = 13;
374 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
Mindy Pereira9275a062012-03-08 15:12:14 -0800375 public static final int FOLDER_BG_COLOR_COLUMN = 15;
376 public static final int FOLDER_FG_COLOR_COLUMN = 16;
Mindy Pereira78664722012-03-05 13:53:07 -0800377
378 public static final class FolderType {
379 public static final int DEFAULT = 0;
380 public static final int INBOX = 1;
381 public static final int DRAFT = 2;
382 public static final int OUTBOX = 3;
383 public static final int SENT = 4;
384 public static final int TRASH = 5;
385 public static final int SPAM = 6;
386 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800387
Mindy Pereira0973b202011-12-21 15:48:12 -0800388 public static final class FolderCapabilities {
389 public static final int SYNCABLE = 0x0001;
390 public static final int PARENT = 0x0002;
391 public static final int CAN_HOLD_MAIL = 0x0004;
392 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800393 /**
394 * For accounts that support archive, this will indicate that this folder supports
395 * the archive functionality.
396 */
397 public static final int ARCHIVE = 0x0010;
398
399 /**
400 * For accounts that support report spam, this will indicate that this folder supports
401 * the report spam functionality.
402 */
403 public static final int REPORT_SPAM = 0x0020;
404
405 /**
406 * For accounts that support mute, this will indicate if a mute is performed from within
407 * this folder, the action is destructive.
408 */
409 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800410 }
411
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800412 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800413 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800414 /**
415 * This string column contains the human visible name for the folder.
416 */
417 public static final String NAME = "name";
418 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800419 * This int column represents the capabilities of the folder specified by
420 * FolderCapabilities flags.
421 */
422 public static String CAPABILITIES = "capabilities";
423 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800424 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800425 * child folders.
426 */
427 public static String HAS_CHILDREN = "hasChildren";
428 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800429 * This int column represents how large the sync window is.
430 */
431 public static String SYNC_WINDOW = "syncWindow";
432 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800433 * This string column contains the content provider uri to return the
434 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800435 */
436 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800437 /**
438 * This string column contains the content provider uri to return the
439 * list of child folders of this folder.
440 */
Mindy Pereira77528642012-02-17 15:51:10 -0800441 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800442
Mindy Pereira77528642012-02-17 15:51:10 -0800443 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800444
Mindy Pereira77528642012-02-17 15:51:10 -0800445 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800446 /**
447 * This string column contains the content provider uri to force a
448 * refresh of this folder.
449 */
Mindy Pereira77528642012-02-17 15:51:10 -0800450 public static final String REFRESH_URI = "refreshUri";
451 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800452 * This int column contains current sync status of the folder; some combination of the
453 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800454 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800455 public static final String SYNC_STATUS = "syncStatus";
456 /**
457 * This int column contains the sync status of the last sync attempt; one of the
458 * LastSyncStatus values defined above
459 */
460 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800461 /**
462 * This long column contains the icon res id for this folder, or 0 if there is none.
463 */
464 public static final String ICON_RES_ID = "iconResId";
465 /**
466 * This int column contains the type of the folder. Zero is default.
467 */
468 public static final String TYPE = "type";
Mindy Pereira9275a062012-03-08 15:12:14 -0800469 /**
470 * String representing the integer background color associated with this
471 * folder, or null.
472 */
473 public static final String BG_COLOR = "bgColor";
474 /**
475 * String representing the integer of the foreground color associated
476 * with this folder, or null.
477 */
478 public static final String FG_COLOR = "fgColor";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800479 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800480 }
481
Mindy Pereiraa1406072011-12-22 10:54:06 -0800482 // We define a "folder" as anything that contains a list of conversations.
483 public static final String CONVERSATION_LIST_TYPE =
484 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
485 public static final String CONVERSATION_TYPE =
486 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
487
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800488
Mindy Pereiraa1406072011-12-22 10:54:06 -0800489 public static final String[] CONVERSATION_PROJECTION = {
490 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800491 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800492 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800493 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800494 ConversationColumns.SNIPPET,
495 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800496 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800497 ConversationColumns.HAS_ATTACHMENTS,
498 ConversationColumns.NUM_MESSAGES,
499 ConversationColumns.NUM_DRAFTS,
500 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800501 ConversationColumns.PRIORITY,
502 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800503 ConversationColumns.STARRED,
504 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800505 };
506
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800507 // These column indexes only work when the caller uses the
508 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800509 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800510 public static final int CONVERSATION_URI_COLUMN = 1;
511 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
512 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
513 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
514 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
515 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
516 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800517 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
518 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
519 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
520 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800521 public static final int CONVERSATION_READ_COLUMN = 12;
522 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800523 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800524
525 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800526 public static final int OTHER = 0;
527 public static final int SENDING = 1;
528 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800529 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800530 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800531
532 public static final class ConversationPriority {
533 public static final int LOW = 0;
534 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800535 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800536
Marc Blankc8a99422012-01-19 14:27:47 -0800537 public static final class ConversationFlags {
538 public static final int READ = 1<<0;
539 public static final int STARRED = 1<<1;
540 public static final int REPLIED = 1<<2;
541 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800542 }
Marc Blankc8a99422012-01-19 14:27:47 -0800543
Mindy Pereiraa1406072011-12-22 10:54:06 -0800544 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800545 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800546 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800547 * This string column contains the content provider uri to return the
548 * list of messages for this conversation.
549 */
550 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800551 /**
552 * This string column contains the subject string for a conversation.
553 */
554 public static final String SUBJECT = "subject";
555 /**
556 * This string column contains the snippet string for a conversation.
557 */
558 public static final String SNIPPET = "snippet";
559 /**
560 * This string column contains the sender info string for a
561 * conversation.
562 */
563 public static final String SENDER_INFO = "senderInfo";
564 /**
565 * This long column contains the time in ms of the latest update to a
566 * conversation.
567 */
568 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
569
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800570 /**
571 * This boolean column contains whether any messages in this conversation
572 * have attachments.
573 */
574 public static final String HAS_ATTACHMENTS = "hasAttachments";
575
Mindy Pereira4db59c52012-01-12 09:45:13 -0800576 /**
577 * This int column contains the number of messages in this conversation.
578 * For unthreaded, this will always be 1.
579 */
580 public static String NUM_MESSAGES = "numMessages";
581
582 /**
583 * This int column contains the number of drafts associated with this
584 * conversation.
585 */
586 public static String NUM_DRAFTS = "numDrafts";
587
588 /**
589 * This int column contains the state of drafts and replies associated
590 * with this conversation. Use ConversationSendingState to interpret
591 * this field.
592 */
593 public static String SENDING_STATE = "sendingState";
594
595 /**
596 * This int column contains the priority of this conversation. Use
597 * ConversationPriority to interpret this field.
598 */
599 public static String PRIORITY = "priority";
600
Marc Blankc8a99422012-01-19 14:27:47 -0800601 /**
602 * This boolean column indicates whether the conversation has been read
603 */
604 public static String READ = "read";
605
606 /**
607 * This boolean column indicates whether the conversation has been read
608 */
609 public static String STARRED = "starred";
610
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800611 /**
612 * This string column contains a csv of all folders associated with this
613 * conversation
614 */
615 public static final String FOLDER_LIST = "folderList";
616
Paul Westbrook334e64a2012-02-23 13:26:35 -0800617 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800618 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800619 }
620
Mindy Pereira6f92de62011-12-19 11:31:48 -0800621 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800622 * List of operations that can can be performed on a conversation. These operations are applied
623 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
624 * where the conversation uri is specified, and the ContentValues specifies the operation to
625 * be performed.
626 * <p/>
627 * The operation to be performed is specified in the ContentValues by
628 * the {@link ConversationOperations#OPERATION_KEY}
629 * <p/>
630 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
631 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800632 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800633 public static final class ConversationOperations {
634 /**
635 * ContentValues key used to specify the operation to be performed
636 */
637 public static final String OPERATION_KEY = "operation";
638
639 /**
640 * Archive operation
641 */
642 public static final String ARCHIVE = "archive";
643
644 /**
645 * Mute operation
646 */
647 public static final String MUTE = "mute";
648
649 /**
650 * Report spam operation
651 */
652 public static final String REPORT_SPAM = "report_spam";
653
654 private ConversationOperations() {
655 }
656 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800657
658 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800659 public static final int NOT_A_DRAFT = 0;
660 public static final int COMPOSE = 1;
661 public static final int REPLY = 2;
662 public static final int REPLY_ALL = 3;
663 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800664
665 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800666 }
667
Mindy Pereiraa1406072011-12-22 10:54:06 -0800668 public static final String[] MESSAGE_PROJECTION = {
669 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800670 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800671 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800672 MessageColumns.CONVERSATION_ID,
673 MessageColumns.SUBJECT,
674 MessageColumns.SNIPPET,
675 MessageColumns.FROM,
676 MessageColumns.TO,
677 MessageColumns.CC,
678 MessageColumns.BCC,
679 MessageColumns.REPLY_TO,
680 MessageColumns.DATE_RECEIVED_MS,
681 MessageColumns.BODY_HTML,
682 MessageColumns.BODY_TEXT,
683 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
684 MessageColumns.REF_MESSAGE_ID,
685 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800686 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800687 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800688 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800689 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800690 MessageColumns.JOINED_ATTACHMENT_INFOS,
691 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800692 MessageColumns.SEND_MESSAGE_URI,
693 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800694 };
695
Mindy Pereiraf944e962012-01-17 11:43:36 -0800696 /** Separates attachment info parts in strings in a message. */
697 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800698 public static final String MESSAGE_LIST_TYPE =
699 "vnd.android.cursor.dir/vnd.com.android.mail.message";
700 public static final String MESSAGE_TYPE =
701 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800702
Mindy Pereira6349a042012-01-04 11:25:01 -0800703 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800704 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
705 public static final int MESSAGE_URI_COLUMN = 2;
706 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
707 public static final int MESSAGE_SUBJECT_COLUMN = 4;
708 public static final int MESSAGE_SNIPPET_COLUMN = 5;
709 public static final int MESSAGE_FROM_COLUMN = 6;
710 public static final int MESSAGE_TO_COLUMN = 7;
711 public static final int MESSAGE_CC_COLUMN = 8;
712 public static final int MESSAGE_BCC_COLUMN = 9;
713 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
714 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800715 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
716 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800717 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
718 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
719 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800720 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
721 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
722 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
723 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800724 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800725 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
726 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800727 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800728
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800729 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800730 public static final int STARRED = 1 << 0;
731 public static final int UNREAD = 1 << 1;
732 public static final int REPLIED = 1 << 2;
733 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800734 }
735
Mindy Pereira6f92de62011-12-19 11:31:48 -0800736 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800737 /**
738 * This string column contains a content provider URI that points to this single message.
739 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800740 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800741 /**
742 * This string column contains a server-assigned ID for this message.
743 */
744 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800745 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800746 /**
747 * This string column contains the subject of a message.
748 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800749 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800750 /**
751 * This string column contains a snippet of the message body.
752 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800753 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800754 /**
755 * This string column contains the single email address (and optionally name) of the sender.
756 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800757 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800758 /**
759 * This string column contains a comma-delimited list of "To:" recipient email addresses.
760 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800761 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800762 /**
763 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
764 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800765 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800766 /**
767 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
768 * This value will be null for incoming messages.
769 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800770 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800771 /**
772 * This string column contains the single email address (and optionally name) of the
773 * sender's reply-to address.
774 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800775 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800776 /**
777 * This long column contains the timestamp (in millis) of receipt of the message.
778 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800779 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800780 /**
781 * This string column contains the HTML form of the message body, if available. If not,
782 * a provider must populate BODY_TEXT.
783 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800784 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800785 /**
786 * This string column contains the plaintext form of the message body, if HTML is not
787 * otherwise available. If HTML is available, this value should be left empty (null).
788 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800789 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800790 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800791 /**
792 * This string column contains an opaque string used by the sendMessage api.
793 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800794 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800795 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800796 * This integer column contains the type of this draft, or zero (0) if this message is not a
797 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800798 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800799 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800800 /**
801 * This boolean column indicates whether an outgoing message should trigger special quoted
802 * text processing upon send. The value should default to zero (0) for protocols that do
803 * not support or require this flag, and for all incoming messages.
804 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800805 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800806 /**
807 * This boolean column indicates whether a message has attachments. The list of attachments
808 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
809 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800810 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800811 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800812 * This string column contains the content provider URI for the list of
813 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800814 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800815 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800816 /**
817 * This long column is a bit field of flags defined in {@link MessageFlags}.
818 */
Andy Huang732600e2012-01-10 17:47:17 -0800819 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800820 /**
821 * This string column contains a specially formatted string representing all
822 * attachments that we added to a message that is being sent or saved.
823 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800824 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800825 /**
826 * This string column contains the content provider URI for saving this
827 * message.
828 */
829 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
830 /**
831 * This string column contains content provider URI for sending this
832 * message.
833 */
834 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800835
Paul Westbrook104f7292012-02-28 16:07:07 -0800836 /**
837 * This integer column represents whether the user has specified that images should always
838 * be shown. The value of "1" indicates that the user has specified that images should be
839 * shown, while the value of "0" indicates that the user should be prompted before loading
840 * any external images.
841 */
842 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
843
Mindy Pereira6f92de62011-12-19 11:31:48 -0800844 private MessageColumns() {}
845 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800846
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800847 public static final String ATTACHMENT_LIST_TYPE =
848 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
849 public static final String ATTACHMENT_TYPE =
850 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
851
852 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800853 AttachmentColumns.NAME,
854 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800855 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800856 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -0800857 AttachmentColumns.STATE,
858 AttachmentColumns.DESTINATION,
859 AttachmentColumns.DOWNLOADED_SIZE,
860 AttachmentColumns.CONTENT_URI,
861 AttachmentColumns.THUMBNAIL_URI,
862 AttachmentColumns.PREVIEW_INTENT
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800863 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800864 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -0800865 public static final int ATTACHMENT_NAME_COLUMN = 0;
866 public static final int ATTACHMENT_SIZE_COLUMN = 1;
867 public static final int ATTACHMENT_URI_COLUMN = 2;
868 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
869 public static final int ATTACHMENT_STATE_COLUMN = 4;
870 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
871 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
872 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
873 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
874 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800875
Andy Huange0b83b82012-03-06 19:57:04 -0800876 /**
877 * Valid states for the {@link AttachmentColumns#STATE} column.
878 *
879 */
880 public static final class AttachmentState {
881 /**
882 * The full attachment is not present on device. When used as a command,
883 * setting this state will tell the provider to cancel a download in
884 * progress.
885 * <p>
886 * Valid next states: {@link #DOWNLOADING}
887 */
888 public static final int NOT_SAVED = 0;
889 /**
890 * The most recent attachment download attempt failed. The current UI
891 * design does not require providers to persist this state, but
892 * providers must return this state at least once after a download
893 * failure occurs. This state may not be used as a command.
894 * <p>
895 * Valid next states: {@link #DOWNLOADING}
896 */
897 public static final int FAILED = 1;
898 /**
899 * The attachment is currently being downloaded by the provider.
900 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
901 * download progress while in this state. When used as a command,
902 * setting this state will tell the provider to initiate a download to
903 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
904 * .
905 * <p>
906 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
907 * {@link #SAVED}
908 */
909 public static final int DOWNLOADING = 2;
910 /**
911 * The attachment was successfully downloaded to the destination in
912 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
913 * that a download is missing, it should reset the state to
914 * {@link #NOT_SAVED}. This state may not be used as a command on its
915 * own. To move a file from cache to external, update
916 * {@link AttachmentColumns#DESTINATION}.
917 * <p>
918 * Valid next states: {@link #NOT_SAVED}
919 */
920 public static final int SAVED = 3;
921
922 private AttachmentState() {}
923 }
924
925 public static final class AttachmentDestination {
926
927 /**
928 * The attachment will be or is already saved to the app-private cache partition.
929 */
930 public static final int CACHE = 0;
931 /**
932 * The attachment will be or is already saved to external shared device storage.
933 */
934 public static final int EXTERNAL = 1;
935
936 private AttachmentDestination() {}
937 }
938
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800939 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -0800940 /**
941 * This string column is the attachment's file name, intended for display in UI. It is not
942 * the full path of the file.
943 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800944 public static final String NAME = "name";
Andy Huange0b83b82012-03-06 19:57:04 -0800945 /**
946 * This integer column is the file size of the attachment, in bytes.
947 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800948 public static final String SIZE = "size";
Andy Huange0b83b82012-03-06 19:57:04 -0800949 /**
950 * This column is a {@link Uri} that can be queried to monitor download state and progress
951 * for this individual attachment (resulting cursor has one single row for this attachment).
952 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800953 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -0800954 /**
955 * This string column is the MIME type of the attachment.
956 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800957 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -0800958 /**
959 * This integer column is the current downloading state of the
960 * attachment as defined in {@link AttachmentState}.
961 * <p>
962 * Providers must accept updates to {@link URI} with new values of
963 * this column to initiate or cancel downloads.
964 */
965 public static final String STATE = "state";
966 /**
967 * This integer column is the file destination for the current download
968 * in progress (when {@link #STATE} is
969 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
970 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
971 * in {@link AttachmentDestination}. This value is undefined in any
972 * other state.
973 * <p>
974 * Providers must accept updates to {@link URI} with new values of
975 * this column to move an existing downloaded file.
976 */
977 public static final String DESTINATION = "destination";
978 /**
979 * This integer column is the current number of bytes downloaded when
980 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
981 * undefined in any other state.
982 */
983 public static final String DOWNLOADED_SIZE = "downloadedSize";
984 /**
985 * This column is a {@link Uri} that points to the downloaded local file
986 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
987 * undefined in any other state.
988 */
989 public static final String CONTENT_URI = "contentUri";
990 /**
991 * This column is a {@link Uri} that points to a local thumbnail file
992 * for the attachment. Providers that do not support downloading
993 * attachment thumbnails may leave this null.
994 */
995 public static final String THUMBNAIL_URI = "thumbnailUri";
996 /**
997 * This column is an {@link Intent} to launch a preview activity that
998 * allows the user to efficiently view an attachment without having to
999 * first download the entire file. Providers that do not support
1000 * previewing attachments may leave this null. The intent is represented
1001 * as a byte-array blob generated by writing an Intent to a parcel and
1002 * then marshaling that parcel.
1003 */
1004 public static final String PREVIEW_INTENT = "previewIntent";
1005
1006 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001007 }
Mindy Pereira013194c2012-01-06 15:09:33 -08001008
1009 public static int getMailMaxAttachmentSize(String account) {
1010 // TODO: query the account to see what the max attachment size is?
1011 return 5 * 1024 * 1024;
1012 }
1013
1014 public static String getAttachmentTypeSetting() {
1015 // TODO: query the account to see what kinds of attachments it supports?
1016 return "com.google.android.gm.allowAddAnyAttachment";
1017 }
Mindy Pereira82cc5662012-01-09 17:29:30 -08001018
1019 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1020 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1021 ArrayList<String> recipients = new ArrayList<String>();
1022 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1023 for (String address : addresses) {
1024 recipients.add(address);
1025 }
1026 statsUpdater.updateWithAddress(recipients);
1027 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001028
1029 public static final String[] UNDO_PROJECTION = {
1030 ConversationColumns.MESSAGE_LIST_URI
1031 };
1032 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001033
1034 // Parameter used to indicate the sequence number for an undoable operation
1035 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001036
1037
1038 public static final String[] SETTINGS_PROJECTION = {
1039 SettingsColumns.SIGNATURE,
1040 SettingsColumns.AUTO_ADVANCE,
1041 SettingsColumns.MESSAGE_TEXT_SIZE,
1042 SettingsColumns.SNAP_HEADERS,
1043 SettingsColumns.REPLY_BEHAVIOR,
1044 SettingsColumns.HIDE_CHECKBOXES,
1045 SettingsColumns.CONFIRM_DELETE,
1046 SettingsColumns.CONFIRM_ARCHIVE,
1047 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -08001048 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -08001049 };
1050
Mindy Pereira8bd82152012-03-01 10:06:35 -08001051 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
1052 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
1053 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
1054 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
1055 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
1056 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
1057 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
1058 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
1059 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
1060 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
1061
Paul Westbrook63eef792012-02-27 14:01:06 -08001062 public static final class AutoAdvance {
1063 public static final int UNSET = 0;
1064 public static final int OLDER = 1;
1065 public static final int NEWER = 2;
1066 public static final int LIST = 3;
1067 }
1068
1069 public static final class SnapHeaderValue {
1070 public static final int ALWAYS = 0;
1071 public static final int PORTRAIT_ONLY = 1;
1072 public static final int NEVER = 2;
1073 }
1074
1075 public static final class MessageTextSize {
1076 public static final int TINY = -2;
1077 public static final int SMALL = -1;
1078 public static final int NORMAL = 0;
1079 public static final int LARGE = 1;
1080 public static final int HUGE = 2;
1081 }
1082
1083 public static final class DefaultReplyBehavior {
1084 public static final int REPLY = 0;
1085 public static final int REPLY_ALL = 1;
1086 }
1087
1088 public static final class SettingsColumns {
1089 /**
1090 * String column containing the contents of the signature for this account. If no
1091 * signature has been specified, the value will be null.
1092 */
1093 public static final String SIGNATURE = "signature";
1094
1095 /**
1096 * Integer column containing the user's specified auto-advance policy. This value will be
1097 * one of the values in {@link UIProvider.AutoAdvance}
1098 */
1099 public static final String AUTO_ADVANCE = "auto_advance";
1100
1101 /**
1102 * Integer column containing the user's specified message text size preference. This value
1103 * will be one of the values in {@link UIProvider.MessageTextSize}
1104 */
1105 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
1106
1107 /**
1108 * Integer column contaning the user's specified snap header preference. This value
1109 * will be one of the values in {@link UIProvider.SnapHeaderValue}
1110 */
1111 public static final String SNAP_HEADERS = "snap_headers";
1112
1113 /**
1114 * Integer column containing the user's specified default reply behavior. This value will
1115 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
1116 */
1117 public static final String REPLY_BEHAVIOR = "reply_behavior";
1118
1119 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -08001120 * Integer column containing the user's specified checkbox preference. A
1121 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -08001122 */
1123 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
1124
1125 /**
1126 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001127 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001128 * be shown when a delete action is performed.
1129 */
1130 public static final String CONFIRM_DELETE = "confirm_delete";
1131
1132 /**
1133 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001134 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001135 * be shown when an archive action is performed.
1136 */
1137 public static final String CONFIRM_ARCHIVE = "confirm_archive";
1138
1139 /**
1140 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001141 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001142 * be shown when a send action is performed.
1143 */
1144 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -08001145 /**
1146 * String folder containing the serialized default inbox folder for an account.
1147 */
1148 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001149 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001150}