blob: dec32f910439fa9b5e00877f3c7249ae1d8bd319 [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;
Mindy Pereira6f92de62011-12-19 11:31:48 -080023import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080024import android.text.TextUtils;
Paul Westbrook334e64a2012-02-23 13:26:35 -080025import android.net.Uri;
Mindy Pereira82cc5662012-01-09 17:29:30 -080026
27import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080028
Paul Westbrook334e64a2012-02-23 13:26:35 -080029import java.lang.String;
Mindy Pereira82cc5662012-01-09 17:29:30 -080030import java.util.ArrayList;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080031
Mindy Pereira6f92de62011-12-19 11:31:48 -080032public class UIProvider {
Mindy Pereira82cc5662012-01-09 17:29:30 -080033 public static final String EMAIL_SEPARATOR = "\n";
Mindy Pereira326c6602012-01-04 15:32:42 -080034 public static final long INVALID_CONVERSATION_ID = -1;
35 public static final long INVALID_MESSAGE_ID = -1;
36
Marc Blank9ace18a2012-02-21 16:34:07 -080037 /**
38 * Values for the current state of a Folder/Account; note that it's possible that more than one
39 * sync is in progress
40 */
41 public static final class SyncStatus {
42 // No sync in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080043 public static final int NO_SYNC = 0;
Marc Blank9ace18a2012-02-21 16:34:07 -080044 // A user-requested sync/refresh is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080045 public static final int USER_REFRESH = 1<<0;
Marc Blank9ace18a2012-02-21 16:34:07 -080046 // A user-requested query is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080047 public static final int USER_QUERY = 1<<1;
Marc Blank9ace18a2012-02-21 16:34:07 -080048 // A user request for additional results is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080049 public static final int USER_MORE_RESULTS = 1<<2;
Marc Blank9ace18a2012-02-21 16:34:07 -080050 // A background sync is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080051 public static final int BACKGROUND_SYNC = 1<<3;
Marc Blank9ace18a2012-02-21 16:34:07 -080052 }
53
54 /**
55 * Values for the result of the last attempted sync of a Folder/Account
56 */
57 public static final class LastSyncResult {
58 // The sync completed successfully
59 public static final int SUCCESS = 0;
60 // The sync wasn't completed due to a connection error
61 public static final int CONNECTION_ERROR = 1;
62 // The sync wasn't completed due to an authentication error
63 public static final int AUTH_ERROR = 2;
64 // The sync wasn't completed due to a security error
65 public static final int SECURITY_ERROR = 3;
66 // The sync wasn't completed due to a low memory condition
67 public static final int STORAGE_ERROR = 4;
68 // The sync wasn't completed due to an internal error/exception
69 public static final int INTERNAL_ERROR = 5;
70 }
71
Paul Westbrook82ea6da2011-12-15 11:03:51 -080072 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -080073 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080074
75 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080076 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080077 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080078 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080079
80 public static final String[] ACCOUNTS_PROJECTION = {
81 BaseColumns._ID,
82 AccountColumns.NAME,
83 AccountColumns.PROVIDER_VERSION,
84 AccountColumns.URI,
85 AccountColumns.CAPABILITIES,
86 AccountColumns.FOLDER_LIST_URI,
87 AccountColumns.SEARCH_URI,
88 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Mindy Pereira33fe9082012-01-09 16:24:30 -080089 AccountColumns.SAVE_DRAFT_URI,
Mindy Pereira7ed1c112012-01-18 10:59:25 -080090 AccountColumns.SEND_MAIL_URI,
Mindy Pereira96b5c352012-02-01 11:33:40 -080091 AccountColumns.EXPUNGE_MESSAGE_URI,
Mindy Pereira9600dac2012-02-17 15:59:25 -080092 AccountColumns.UNDO_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -080093 AccountColumns.SETTINGS_INTENT_URI,
Paul Westbrook63eef792012-02-27 14:01:06 -080094 AccountColumns.SETTINGS_QUERY_URI,
Paul Westbrook94e440d2012-02-24 11:03:47 -080095 AccountColumns.SYNC_STATUS,
Mindy Pereira23755e22012-02-27 13:58:04 -080096 AccountColumns.HELP_INTENT_URI,
97 AccountColumns.COMPOSE_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -080098 };
99
Mindy Pereira33fe9082012-01-09 16:24:30 -0800100 public static final int ACCOUNT_ID_COLUMN = 0;
101 public static final int ACCOUNT_NAME_COLUMN = 1;
102 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
103 public static final int ACCOUNT_URI_COLUMN = 3;
104 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
105 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
106 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
107 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
108 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
109 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800110 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800111 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800112 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800113 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
114 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
115 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
116 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800117
Mindy Pereira6f92de62011-12-19 11:31:48 -0800118 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800119 /**
120 * Whether folders can be synchronized back to the server.
121 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800122 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800123 /**
124 * Whether the server allows reporting spam back.
125 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800126 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800127 /**
128 * Whether the server supports a concept of Archive: removing mail from the Inbox but
129 * keeping it around.
130 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800131 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800132 /**
133 * Whether the server will stop notifying on updates to this thread? This requires
134 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
135 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800136 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800137 /**
138 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
139 * to be true, otherwise it should be ignored.
140 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800141 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800142 /**
143 * Whether the server supports constraining search to a single folder. Requires
144 * SYNCABLE_FOLDERS, otherwise it should be ignored.
145 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800146 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800147 /**
148 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
149 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800150 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800151 /**
152 * Whether the server allows synchronization of draft messages. This does NOT require
153 * SYNCABLE_FOLDERS to be set.
154 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800155 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800156 /**
157 * Does the server allow the user to compose mails (and reply) using addresses other than
158 * their account name? For instance, GMail allows users to set FROM addresses that are
159 * different from account@gmail.com address. For instance, user@gmail.com could have another
160 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
161 * can compose (and reply) using either address.
162 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800163 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800164 /**
165 * Whether the server allows the original message to be included in the reply by setting a
166 * flag on the reply. If we can avoid including the entire previous message, we save on
167 * bandwidth (replies are shorter).
168 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800169 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800170 /**
171 * Does this account support searching locally, on the device? This requires the backend
172 * storage to support a mechanism for searching.
173 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800174 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800175 /**
176 * Whether the server supports a notion of threaded conversations: where replies to messages
177 * are tagged to keep conversations grouped. This could be full threading (each message
178 * lists its parent) or conversation-level threading (each message lists one conversation
179 * which it belongs to)
180 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800181 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800182 /**
183 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
184 * multiple labels on a single conversation, since labels and folders are interchangeable
185 * in this application.)
186 */
Mindy Pereira84648892012-02-03 08:29:55 -0800187 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800188 /**
189 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
190 */
191 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800192 /**
193 * Whether the account provides help content.
194 */
195 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800196 /**
197 * Whether the account provides a mechanism for marking conversations as important.
198 */
199 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800200 }
201
202 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800203 /**
204 * This string column contains the human visible name for the account.
205 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800206 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800207
208 /**
209 * This integer column returns the version of the UI provider schema from which this
210 * account provider will return results.
211 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800212 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800213
214 /**
215 * This string column contains the uri to directly access the information for this account.
216 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800217 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800218
219 /**
220 * This integer column contains a bit field of the possible cabibilities that this account
221 * supports.
222 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800223 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800224
225 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800226 * This string column contains the content provider uri to return the
227 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800228 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800229 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800230
231 /**
232 * This string column contains the content provider uri that can be queried for search
233 * results.
234 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800235 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800236
237 /**
238 * This string column contains the content provider uri that can be queried to access the
239 * from addresses for this account.
240 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800241 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800242
243 /**
244 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800245 * new draft messages for this account. NOTE: This might be better to
246 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800247 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800248 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800249
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800250 /**
251 * This string column contains the content provider uri that can be used to send
252 * a message for this account.
253 * NOTE: This might be better to be an update operation on the messageUri.
254 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800255 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800256
257 /**
258 * This string column contains the content provider uri that can be used
259 * to expunge a message from this account. NOTE: This might be better to
260 * be an update operation on the messageUri.
261 */
262 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800263
264 /**
265 * This string column contains the content provider uri that can be used
266 * to undo the last committed action.
267 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800268 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800269
270 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800271 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800272 * shown.
273 * TODO: When we want to support a heterogeneous set of account types, this value may need
274 * to be moved to a global content provider.
275 */
276 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800277
278 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800279 * This string column contains the content provider uri that can be used to query user
280 * settings/preferences.
281 *
282 * The cursor returned by this query support columnms declared in {@link #SettingsColumns}
283 */
284 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
285
286 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800287 * Uri for VIEW intent that will cause the help screens for this account type to be
288 * shown.
289 * TODO: When we want to support a heterogeneous set of account types, this value may need
290 * to be moved to a global content provider.
291 */
292 public static String HELP_INTENT_URI = "helpIntentUri";
293
294 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800295 * This int column contains the current sync status of the account (the logical AND of the
296 * sync status of folders in this account)
297 */
298 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800299 /**
300 * Uri for VIEW intent that will cause the compose screens for this type
301 * of account to be shown.
302 */
303 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800304 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800305
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800306 // We define a "folder" as anything that contains a list of conversations.
307 public static final String FOLDER_LIST_TYPE =
308 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
309 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800310 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800311
312 public static final String[] FOLDERS_PROJECTION = {
313 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800314 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800315 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800316 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800317 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800318 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800319 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800320 FolderColumns.CHILD_FOLDERS_LIST_URI,
321 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800322 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800323 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800324 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800325 FolderColumns.LAST_SYNC_RESULT,
326 FolderColumns.TYPE,
327 FolderColumns.ICON_RES_ID
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800328 };
329
Mindy Pereira818143e2012-01-11 13:59:49 -0800330 public static final int FOLDER_ID_COLUMN = 0;
331 public static final int FOLDER_URI_COLUMN = 1;
332 public static final int FOLDER_NAME_COLUMN = 2;
333 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
334 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800335 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
336 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
337 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
338 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
339 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
340 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
341 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
342 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800343 public static final int FOLDER_TYPE_COLUMN = 13;
344 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
345
346 public static final class FolderType {
347 public static final int DEFAULT = 0;
348 public static final int INBOX = 1;
349 public static final int DRAFT = 2;
350 public static final int OUTBOX = 3;
351 public static final int SENT = 4;
352 public static final int TRASH = 5;
353 public static final int SPAM = 6;
354 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800355
Mindy Pereira0973b202011-12-21 15:48:12 -0800356 public static final class FolderCapabilities {
357 public static final int SYNCABLE = 0x0001;
358 public static final int PARENT = 0x0002;
359 public static final int CAN_HOLD_MAIL = 0x0004;
360 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800361 /**
362 * For accounts that support archive, this will indicate that this folder supports
363 * the archive functionality.
364 */
365 public static final int ARCHIVE = 0x0010;
366
367 /**
368 * For accounts that support report spam, this will indicate that this folder supports
369 * the report spam functionality.
370 */
371 public static final int REPORT_SPAM = 0x0020;
372
373 /**
374 * For accounts that support mute, this will indicate if a mute is performed from within
375 * this folder, the action is destructive.
376 */
377 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800378 }
379
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800380 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800381 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800382 /**
383 * This string column contains the human visible name for the folder.
384 */
385 public static final String NAME = "name";
386 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800387 * This int column represents the capabilities of the folder specified by
388 * FolderCapabilities flags.
389 */
390 public static String CAPABILITIES = "capabilities";
391 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800392 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800393 * child folders.
394 */
395 public static String HAS_CHILDREN = "hasChildren";
396 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800397 * This int column represents how large the sync window is.
398 */
399 public static String SYNC_WINDOW = "syncWindow";
400 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800401 * This string column contains the content provider uri to return the
402 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800403 */
404 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800405 /**
406 * This string column contains the content provider uri to return the
407 * list of child folders of this folder.
408 */
Mindy Pereira77528642012-02-17 15:51:10 -0800409 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800410
Mindy Pereira77528642012-02-17 15:51:10 -0800411 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800412
Mindy Pereira77528642012-02-17 15:51:10 -0800413 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800414 /**
415 * This string column contains the content provider uri to force a
416 * refresh of this folder.
417 */
Mindy Pereira77528642012-02-17 15:51:10 -0800418 public static final String REFRESH_URI = "refreshUri";
419 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800420 * This int column contains current sync status of the folder; some combination of the
421 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800422 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800423 public static final String SYNC_STATUS = "syncStatus";
424 /**
425 * This int column contains the sync status of the last sync attempt; one of the
426 * LastSyncStatus values defined above
427 */
428 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800429 /**
430 * This long column contains the icon res id for this folder, or 0 if there is none.
431 */
432 public static final String ICON_RES_ID = "iconResId";
433 /**
434 * This int column contains the type of the folder. Zero is default.
435 */
436 public static final String TYPE = "type";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800437 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800438 }
439
Mindy Pereiraa1406072011-12-22 10:54:06 -0800440 // We define a "folder" as anything that contains a list of conversations.
441 public static final String CONVERSATION_LIST_TYPE =
442 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
443 public static final String CONVERSATION_TYPE =
444 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
445
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800446
Mindy Pereiraa1406072011-12-22 10:54:06 -0800447 public static final String[] CONVERSATION_PROJECTION = {
448 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800449 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800450 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800451 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800452 ConversationColumns.SNIPPET,
453 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800454 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800455 ConversationColumns.HAS_ATTACHMENTS,
456 ConversationColumns.NUM_MESSAGES,
457 ConversationColumns.NUM_DRAFTS,
458 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800459 ConversationColumns.PRIORITY,
460 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800461 ConversationColumns.STARRED,
462 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800463 };
464
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800465 // These column indexes only work when the caller uses the
466 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800467 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800468 public static final int CONVERSATION_URI_COLUMN = 1;
469 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
470 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
471 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
472 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
473 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
474 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800475 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
476 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
477 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
478 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800479 public static final int CONVERSATION_READ_COLUMN = 12;
480 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800481 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800482
483 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800484 public static final int OTHER = 0;
485 public static final int SENDING = 1;
486 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800487 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800488 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800489
490 public static final class ConversationPriority {
491 public static final int LOW = 0;
492 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800493 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800494
Marc Blankc8a99422012-01-19 14:27:47 -0800495 public static final class ConversationFlags {
496 public static final int READ = 1<<0;
497 public static final int STARRED = 1<<1;
498 public static final int REPLIED = 1<<2;
499 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800500 }
Marc Blankc8a99422012-01-19 14:27:47 -0800501
Mindy Pereiraa1406072011-12-22 10:54:06 -0800502 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800503 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800504 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800505 * This string column contains the content provider uri to return the
506 * list of messages for this conversation.
507 */
508 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800509 /**
510 * This string column contains the subject string for a conversation.
511 */
512 public static final String SUBJECT = "subject";
513 /**
514 * This string column contains the snippet string for a conversation.
515 */
516 public static final String SNIPPET = "snippet";
517 /**
518 * This string column contains the sender info string for a
519 * conversation.
520 */
521 public static final String SENDER_INFO = "senderInfo";
522 /**
523 * This long column contains the time in ms of the latest update to a
524 * conversation.
525 */
526 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
527
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800528 /**
529 * This boolean column contains whether any messages in this conversation
530 * have attachments.
531 */
532 public static final String HAS_ATTACHMENTS = "hasAttachments";
533
Mindy Pereira4db59c52012-01-12 09:45:13 -0800534 /**
535 * This int column contains the number of messages in this conversation.
536 * For unthreaded, this will always be 1.
537 */
538 public static String NUM_MESSAGES = "numMessages";
539
540 /**
541 * This int column contains the number of drafts associated with this
542 * conversation.
543 */
544 public static String NUM_DRAFTS = "numDrafts";
545
546 /**
547 * This int column contains the state of drafts and replies associated
548 * with this conversation. Use ConversationSendingState to interpret
549 * this field.
550 */
551 public static String SENDING_STATE = "sendingState";
552
553 /**
554 * This int column contains the priority of this conversation. Use
555 * ConversationPriority to interpret this field.
556 */
557 public static String PRIORITY = "priority";
558
Marc Blankc8a99422012-01-19 14:27:47 -0800559 /**
560 * This boolean column indicates whether the conversation has been read
561 */
562 public static String READ = "read";
563
564 /**
565 * This boolean column indicates whether the conversation has been read
566 */
567 public static String STARRED = "starred";
568
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800569 /**
570 * This string column contains a csv of all folders associated with this
571 * conversation
572 */
573 public static final String FOLDER_LIST = "folderList";
574
Paul Westbrook334e64a2012-02-23 13:26:35 -0800575 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800576 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800577 }
578
Mindy Pereira6f92de62011-12-19 11:31:48 -0800579 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800580 * List of operations that can can be performed on a conversation. These operations are applied
581 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
582 * where the conversation uri is specified, and the ContentValues specifies the operation to
583 * be performed.
584 * <p/>
585 * The operation to be performed is specified in the ContentValues by
586 * the {@link ConversationOperations#OPERATION_KEY}
587 * <p/>
588 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
589 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800590 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800591 public static final class ConversationOperations {
592 /**
593 * ContentValues key used to specify the operation to be performed
594 */
595 public static final String OPERATION_KEY = "operation";
596
597 /**
598 * Archive operation
599 */
600 public static final String ARCHIVE = "archive";
601
602 /**
603 * Mute operation
604 */
605 public static final String MUTE = "mute";
606
607 /**
608 * Report spam operation
609 */
610 public static final String REPORT_SPAM = "report_spam";
611
612 private ConversationOperations() {
613 }
614 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800615
616 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800617 public static final int NOT_A_DRAFT = 0;
618 public static final int COMPOSE = 1;
619 public static final int REPLY = 2;
620 public static final int REPLY_ALL = 3;
621 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800622
623 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800624 }
625
Mindy Pereiraa1406072011-12-22 10:54:06 -0800626 public static final String[] MESSAGE_PROJECTION = {
627 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800628 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800629 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800630 MessageColumns.CONVERSATION_ID,
631 MessageColumns.SUBJECT,
632 MessageColumns.SNIPPET,
633 MessageColumns.FROM,
634 MessageColumns.TO,
635 MessageColumns.CC,
636 MessageColumns.BCC,
637 MessageColumns.REPLY_TO,
638 MessageColumns.DATE_RECEIVED_MS,
639 MessageColumns.BODY_HTML,
640 MessageColumns.BODY_TEXT,
641 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
642 MessageColumns.REF_MESSAGE_ID,
643 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800644 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800645 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800646 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800647 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800648 MessageColumns.JOINED_ATTACHMENT_INFOS,
649 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800650 MessageColumns.SEND_MESSAGE_URI,
651 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800652 };
653
Mindy Pereiraf944e962012-01-17 11:43:36 -0800654 /** Separates attachment info parts in strings in a message. */
655 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800656 public static final String MESSAGE_LIST_TYPE =
657 "vnd.android.cursor.dir/vnd.com.android.mail.message";
658 public static final String MESSAGE_TYPE =
659 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800660
Mindy Pereira6349a042012-01-04 11:25:01 -0800661 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800662 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
663 public static final int MESSAGE_URI_COLUMN = 2;
664 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
665 public static final int MESSAGE_SUBJECT_COLUMN = 4;
666 public static final int MESSAGE_SNIPPET_COLUMN = 5;
667 public static final int MESSAGE_FROM_COLUMN = 6;
668 public static final int MESSAGE_TO_COLUMN = 7;
669 public static final int MESSAGE_CC_COLUMN = 8;
670 public static final int MESSAGE_BCC_COLUMN = 9;
671 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
672 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800673 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
674 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800675 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
676 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
677 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800678 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
679 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
680 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
681 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800682 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800683 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
684 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800685 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800686
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800687 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800688 public static final int STARRED = 1 << 0;
689 public static final int UNREAD = 1 << 1;
690 public static final int REPLIED = 1 << 2;
691 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800692 }
693
Mindy Pereira6f92de62011-12-19 11:31:48 -0800694 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800695 /**
696 * This string column contains a content provider URI that points to this single message.
697 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800698 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800699 /**
700 * This string column contains a server-assigned ID for this message.
701 */
702 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800703 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800704 /**
705 * This string column contains the subject of a message.
706 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800707 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800708 /**
709 * This string column contains a snippet of the message body.
710 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800711 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800712 /**
713 * This string column contains the single email address (and optionally name) of the sender.
714 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800715 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800716 /**
717 * This string column contains a comma-delimited list of "To:" recipient email addresses.
718 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800719 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800720 /**
721 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
722 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800723 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800724 /**
725 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
726 * This value will be null for incoming messages.
727 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800728 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800729 /**
730 * This string column contains the single email address (and optionally name) of the
731 * sender's reply-to address.
732 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800733 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800734 /**
735 * This long column contains the timestamp (in millis) of receipt of the message.
736 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800737 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800738 /**
739 * This string column contains the HTML form of the message body, if available. If not,
740 * a provider must populate BODY_TEXT.
741 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800742 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800743 /**
744 * This string column contains the plaintext form of the message body, if HTML is not
745 * otherwise available. If HTML is available, this value should be left empty (null).
746 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800747 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800748 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800749 /**
750 * This string column contains an opaque string used by the sendMessage api.
751 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800752 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800753 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800754 * This integer column contains the type of this draft, or zero (0) if this message is not a
755 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800756 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800757 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800758 /**
759 * This boolean column indicates whether an outgoing message should trigger special quoted
760 * text processing upon send. The value should default to zero (0) for protocols that do
761 * not support or require this flag, and for all incoming messages.
762 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800763 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800764 /**
765 * This boolean column indicates whether a message has attachments. The list of attachments
766 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
767 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800768 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800769 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800770 * This string column contains the content provider URI for the list of
771 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800772 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800773 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800774 /**
775 * This long column is a bit field of flags defined in {@link MessageFlags}.
776 */
Andy Huang732600e2012-01-10 17:47:17 -0800777 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800778 /**
779 * This string column contains a specially formatted string representing all
780 * attachments that we added to a message that is being sent or saved.
781 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800782 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800783 /**
784 * This string column contains the content provider URI for saving this
785 * message.
786 */
787 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
788 /**
789 * This string column contains content provider URI for sending this
790 * message.
791 */
792 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800793
Paul Westbrook104f7292012-02-28 16:07:07 -0800794 /**
795 * This integer column represents whether the user has specified that images should always
796 * be shown. The value of "1" indicates that the user has specified that images should be
797 * shown, while the value of "0" indicates that the user should be prompted before loading
798 * any external images.
799 */
800 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
801
Mindy Pereira6f92de62011-12-19 11:31:48 -0800802 private MessageColumns() {}
803 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800804
805 // We define a "folder" as anything that contains a list of conversations.
806 public static final String ATTACHMENT_LIST_TYPE =
807 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
808 public static final String ATTACHMENT_TYPE =
809 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
810
811 public static final String[] ATTACHMENT_PROJECTION = {
812 BaseColumns._ID,
813 AttachmentColumns.NAME,
814 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800815 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800816 AttachmentColumns.ORIGIN_EXTRAS,
817 AttachmentColumns.CONTENT_TYPE,
818 AttachmentColumns.SYNCED
819 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800820 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800821 public static final int ATTACHMENT_ID_COLUMN = 0;
822 public static final int ATTACHMENT_NAME_COLUMN = 1;
823 public static final int ATTACHMENT_SIZE_COLUMN = 2;
824 public static final int ATTACHMENT_URI_COLUMN = 3;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800825 public static final int ATTACHMENT_ORIGIN_EXTRAS_COLUMN = 4;
826 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 5;
827 public static final int ATTACHMENT_SYNCED_COLUMN = 6;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800828
829 public static final class AttachmentColumns {
830 public static final String NAME = "name";
831 public static final String SIZE = "size";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800832 public static final String URI = "uri";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800833 public static final String ORIGIN_EXTRAS = "originExtras";
834 public static final String CONTENT_TYPE = "contentType";
835 public static final String SYNCED = "synced";
836 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800837
838 public static int getMailMaxAttachmentSize(String account) {
839 // TODO: query the account to see what the max attachment size is?
840 return 5 * 1024 * 1024;
841 }
842
843 public static String getAttachmentTypeSetting() {
844 // TODO: query the account to see what kinds of attachments it supports?
845 return "com.google.android.gm.allowAddAnyAttachment";
846 }
Mindy Pereira82cc5662012-01-09 17:29:30 -0800847
848 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
849 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
850 ArrayList<String> recipients = new ArrayList<String>();
851 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
852 for (String address : addresses) {
853 recipients.add(address);
854 }
855 statsUpdater.updateWithAddress(recipients);
856 }
Marc Blankb31ab5a2012-02-01 12:28:29 -0800857
858 public static final String[] UNDO_PROJECTION = {
859 ConversationColumns.MESSAGE_LIST_URI
860 };
861 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -0800862
863 // Parameter used to indicate the sequence number for an undoable operation
864 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -0800865
866
867 public static final String[] SETTINGS_PROJECTION = {
868 SettingsColumns.SIGNATURE,
869 SettingsColumns.AUTO_ADVANCE,
870 SettingsColumns.MESSAGE_TEXT_SIZE,
871 SettingsColumns.SNAP_HEADERS,
872 SettingsColumns.REPLY_BEHAVIOR,
873 SettingsColumns.HIDE_CHECKBOXES,
874 SettingsColumns.CONFIRM_DELETE,
875 SettingsColumns.CONFIRM_ARCHIVE,
876 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -0800877 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -0800878 };
879
Mindy Pereira8bd82152012-03-01 10:06:35 -0800880 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
881 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
882 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
883 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
884 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
885 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
886 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
887 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
888 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
889 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
890
Paul Westbrook63eef792012-02-27 14:01:06 -0800891 public static final class AutoAdvance {
892 public static final int UNSET = 0;
893 public static final int OLDER = 1;
894 public static final int NEWER = 2;
895 public static final int LIST = 3;
896 }
897
898 public static final class SnapHeaderValue {
899 public static final int ALWAYS = 0;
900 public static final int PORTRAIT_ONLY = 1;
901 public static final int NEVER = 2;
902 }
903
904 public static final class MessageTextSize {
905 public static final int TINY = -2;
906 public static final int SMALL = -1;
907 public static final int NORMAL = 0;
908 public static final int LARGE = 1;
909 public static final int HUGE = 2;
910 }
911
912 public static final class DefaultReplyBehavior {
913 public static final int REPLY = 0;
914 public static final int REPLY_ALL = 1;
915 }
916
917 public static final class SettingsColumns {
918 /**
919 * String column containing the contents of the signature for this account. If no
920 * signature has been specified, the value will be null.
921 */
922 public static final String SIGNATURE = "signature";
923
924 /**
925 * Integer column containing the user's specified auto-advance policy. This value will be
926 * one of the values in {@link UIProvider.AutoAdvance}
927 */
928 public static final String AUTO_ADVANCE = "auto_advance";
929
930 /**
931 * Integer column containing the user's specified message text size preference. This value
932 * will be one of the values in {@link UIProvider.MessageTextSize}
933 */
934 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
935
936 /**
937 * Integer column contaning the user's specified snap header preference. This value
938 * will be one of the values in {@link UIProvider.SnapHeaderValue}
939 */
940 public static final String SNAP_HEADERS = "snap_headers";
941
942 /**
943 * Integer column containing the user's specified default reply behavior. This value will
944 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
945 */
946 public static final String REPLY_BEHAVIOR = "reply_behavior";
947
948 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -0800949 * Integer column containing the user's specified checkbox preference. A
950 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -0800951 */
952 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
953
954 /**
955 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800956 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800957 * be shown when a delete action is performed.
958 */
959 public static final String CONFIRM_DELETE = "confirm_delete";
960
961 /**
962 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800963 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800964 * be shown when an archive action is performed.
965 */
966 public static final String CONFIRM_ARCHIVE = "confirm_archive";
967
968 /**
969 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800970 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800971 * be shown when a send action is performed.
972 */
973 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -0800974 /**
975 * String folder containing the serialized default inbox folder for an account.
976 */
977 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -0800978 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800979}