blob: b130c3d713db45bf3794e409b2d654d31ef5307d [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,
Mindy Pereira898cd382012-03-06 08:42:47 -080097 AccountColumns.COMPOSE_URI,
98 AccountColumns.MIME_TYPE
Mindy Pereira6f92de62011-12-19 11:31:48 -080099 };
100
Mindy Pereira33fe9082012-01-09 16:24:30 -0800101 public static final int ACCOUNT_ID_COLUMN = 0;
102 public static final int ACCOUNT_NAME_COLUMN = 1;
103 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
104 public static final int ACCOUNT_URI_COLUMN = 3;
105 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
106 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
107 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
108 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
109 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
110 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800111 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800112 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800113 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800114 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
115 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
116 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
117 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira898cd382012-03-06 08:42:47 -0800118 public static final int ACCOUNT_MIME_TYPE_COLUMN = 17;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800119
Mindy Pereira6f92de62011-12-19 11:31:48 -0800120 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800121 /**
122 * Whether folders can be synchronized back to the server.
123 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800124 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800125 /**
126 * Whether the server allows reporting spam back.
127 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800128 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800129 /**
130 * Whether the server supports a concept of Archive: removing mail from the Inbox but
131 * keeping it around.
132 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800133 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800134 /**
135 * Whether the server will stop notifying on updates to this thread? This requires
136 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
137 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800138 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800139 /**
140 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
141 * to be true, otherwise it should be ignored.
142 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800143 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800144 /**
145 * Whether the server supports constraining search to a single folder. Requires
146 * SYNCABLE_FOLDERS, otherwise it should be ignored.
147 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800148 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800149 /**
150 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
151 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800152 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800153 /**
154 * Whether the server allows synchronization of draft messages. This does NOT require
155 * SYNCABLE_FOLDERS to be set.
156 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800157 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800158 /**
159 * Does the server allow the user to compose mails (and reply) using addresses other than
160 * their account name? For instance, GMail allows users to set FROM addresses that are
161 * different from account@gmail.com address. For instance, user@gmail.com could have another
162 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
163 * can compose (and reply) using either address.
164 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800165 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800166 /**
167 * Whether the server allows the original message to be included in the reply by setting a
168 * flag on the reply. If we can avoid including the entire previous message, we save on
169 * bandwidth (replies are shorter).
170 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800171 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800172 /**
173 * Does this account support searching locally, on the device? This requires the backend
174 * storage to support a mechanism for searching.
175 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800176 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800177 /**
178 * Whether the server supports a notion of threaded conversations: where replies to messages
179 * are tagged to keep conversations grouped. This could be full threading (each message
180 * lists its parent) or conversation-level threading (each message lists one conversation
181 * which it belongs to)
182 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800183 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800184 /**
185 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
186 * multiple labels on a single conversation, since labels and folders are interchangeable
187 * in this application.)
188 */
Mindy Pereira84648892012-02-03 08:29:55 -0800189 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800190 /**
191 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
192 */
193 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800194 /**
195 * Whether the account provides help content.
196 */
197 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800198 /**
199 * Whether the account provides a mechanism for marking conversations as important.
200 */
201 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800202 }
203
204 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800205 /**
206 * This string column contains the human visible name for the account.
207 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800208 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800209
210 /**
211 * This integer column returns the version of the UI provider schema from which this
212 * account provider will return results.
213 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800214 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800215
216 /**
217 * This string column contains the uri to directly access the information for this account.
218 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800219 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800220
221 /**
222 * This integer column contains a bit field of the possible cabibilities that this account
223 * supports.
224 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800225 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800226
227 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800228 * This string column contains the content provider uri to return the
229 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800230 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800231 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800232
233 /**
234 * This string column contains the content provider uri that can be queried for search
235 * results.
236 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800237 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800238
239 /**
240 * This string column contains the content provider uri that can be queried to access the
241 * from addresses for this account.
242 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800243 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800244
245 /**
246 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800247 * new draft messages for this account. NOTE: This might be better to
248 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800249 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800250 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800251
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800252 /**
253 * This string column contains the content provider uri that can be used to send
254 * a message for this account.
255 * NOTE: This might be better to be an update operation on the messageUri.
256 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800257 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800258
259 /**
260 * This string column contains the content provider uri that can be used
261 * to expunge a message from this account. NOTE: This might be better to
262 * be an update operation on the messageUri.
263 */
264 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800265
266 /**
267 * This string column contains the content provider uri that can be used
268 * to undo the last committed action.
269 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800270 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800271
272 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800273 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800274 * shown.
275 * TODO: When we want to support a heterogeneous set of account types, this value may need
276 * to be moved to a global content provider.
277 */
278 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800279
280 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800281 * This string column contains the content provider uri that can be used to query user
282 * settings/preferences.
283 *
284 * The cursor returned by this query support columnms declared in {@link #SettingsColumns}
285 */
286 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
287
288 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800289 * Uri for VIEW intent that will cause the help screens for this account type to be
290 * shown.
291 * TODO: When we want to support a heterogeneous set of account types, this value may need
292 * to be moved to a global content provider.
293 */
294 public static String HELP_INTENT_URI = "helpIntentUri";
295
296 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800297 * This int column contains the current sync status of the account (the logical AND of the
298 * sync status of folders in this account)
299 */
300 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800301 /**
302 * Uri for VIEW intent that will cause the compose screens for this type
303 * of account to be shown.
304 */
305 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800306 /**
307 * Mime-type defining this account.
308 */
309 public static final String MIME_TYPE = "mimeType";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800310 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800311
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800312 // We define a "folder" as anything that contains a list of conversations.
313 public static final String FOLDER_LIST_TYPE =
314 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
315 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800316 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800317
318 public static final String[] FOLDERS_PROJECTION = {
319 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800320 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800321 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800322 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800323 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800324 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800325 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800326 FolderColumns.CHILD_FOLDERS_LIST_URI,
327 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800328 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800329 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800330 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800331 FolderColumns.LAST_SYNC_RESULT,
332 FolderColumns.TYPE,
333 FolderColumns.ICON_RES_ID
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800334 };
335
Mindy Pereira818143e2012-01-11 13:59:49 -0800336 public static final int FOLDER_ID_COLUMN = 0;
337 public static final int FOLDER_URI_COLUMN = 1;
338 public static final int FOLDER_NAME_COLUMN = 2;
339 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
340 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800341 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
342 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
343 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
344 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
345 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
346 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
347 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
348 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800349 public static final int FOLDER_TYPE_COLUMN = 13;
350 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
351
352 public static final class FolderType {
353 public static final int DEFAULT = 0;
354 public static final int INBOX = 1;
355 public static final int DRAFT = 2;
356 public static final int OUTBOX = 3;
357 public static final int SENT = 4;
358 public static final int TRASH = 5;
359 public static final int SPAM = 6;
360 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800361
Mindy Pereira0973b202011-12-21 15:48:12 -0800362 public static final class FolderCapabilities {
363 public static final int SYNCABLE = 0x0001;
364 public static final int PARENT = 0x0002;
365 public static final int CAN_HOLD_MAIL = 0x0004;
366 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800367 /**
368 * For accounts that support archive, this will indicate that this folder supports
369 * the archive functionality.
370 */
371 public static final int ARCHIVE = 0x0010;
372
373 /**
374 * For accounts that support report spam, this will indicate that this folder supports
375 * the report spam functionality.
376 */
377 public static final int REPORT_SPAM = 0x0020;
378
379 /**
380 * For accounts that support mute, this will indicate if a mute is performed from within
381 * this folder, the action is destructive.
382 */
383 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800384 }
385
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800386 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800387 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800388 /**
389 * This string column contains the human visible name for the folder.
390 */
391 public static final String NAME = "name";
392 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800393 * This int column represents the capabilities of the folder specified by
394 * FolderCapabilities flags.
395 */
396 public static String CAPABILITIES = "capabilities";
397 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800398 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800399 * child folders.
400 */
401 public static String HAS_CHILDREN = "hasChildren";
402 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800403 * This int column represents how large the sync window is.
404 */
405 public static String SYNC_WINDOW = "syncWindow";
406 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800407 * This string column contains the content provider uri to return the
408 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800409 */
410 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800411 /**
412 * This string column contains the content provider uri to return the
413 * list of child folders of this folder.
414 */
Mindy Pereira77528642012-02-17 15:51:10 -0800415 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800416
Mindy Pereira77528642012-02-17 15:51:10 -0800417 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800418
Mindy Pereira77528642012-02-17 15:51:10 -0800419 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800420 /**
421 * This string column contains the content provider uri to force a
422 * refresh of this folder.
423 */
Mindy Pereira77528642012-02-17 15:51:10 -0800424 public static final String REFRESH_URI = "refreshUri";
425 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800426 * This int column contains current sync status of the folder; some combination of the
427 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800428 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800429 public static final String SYNC_STATUS = "syncStatus";
430 /**
431 * This int column contains the sync status of the last sync attempt; one of the
432 * LastSyncStatus values defined above
433 */
434 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800435 /**
436 * This long column contains the icon res id for this folder, or 0 if there is none.
437 */
438 public static final String ICON_RES_ID = "iconResId";
439 /**
440 * This int column contains the type of the folder. Zero is default.
441 */
442 public static final String TYPE = "type";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800443 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800444 }
445
Mindy Pereiraa1406072011-12-22 10:54:06 -0800446 // We define a "folder" as anything that contains a list of conversations.
447 public static final String CONVERSATION_LIST_TYPE =
448 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
449 public static final String CONVERSATION_TYPE =
450 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
451
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800452
Mindy Pereiraa1406072011-12-22 10:54:06 -0800453 public static final String[] CONVERSATION_PROJECTION = {
454 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800455 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800456 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800457 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800458 ConversationColumns.SNIPPET,
459 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800460 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800461 ConversationColumns.HAS_ATTACHMENTS,
462 ConversationColumns.NUM_MESSAGES,
463 ConversationColumns.NUM_DRAFTS,
464 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800465 ConversationColumns.PRIORITY,
466 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800467 ConversationColumns.STARRED,
468 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800469 };
470
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800471 // These column indexes only work when the caller uses the
472 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800473 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800474 public static final int CONVERSATION_URI_COLUMN = 1;
475 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
476 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
477 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
478 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
479 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
480 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800481 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
482 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
483 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
484 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800485 public static final int CONVERSATION_READ_COLUMN = 12;
486 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800487 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800488
489 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800490 public static final int OTHER = 0;
491 public static final int SENDING = 1;
492 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800493 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800494 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800495
496 public static final class ConversationPriority {
497 public static final int LOW = 0;
498 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800499 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800500
Marc Blankc8a99422012-01-19 14:27:47 -0800501 public static final class ConversationFlags {
502 public static final int READ = 1<<0;
503 public static final int STARRED = 1<<1;
504 public static final int REPLIED = 1<<2;
505 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800506 }
Marc Blankc8a99422012-01-19 14:27:47 -0800507
Mindy Pereiraa1406072011-12-22 10:54:06 -0800508 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800509 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800510 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800511 * This string column contains the content provider uri to return the
512 * list of messages for this conversation.
513 */
514 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800515 /**
516 * This string column contains the subject string for a conversation.
517 */
518 public static final String SUBJECT = "subject";
519 /**
520 * This string column contains the snippet string for a conversation.
521 */
522 public static final String SNIPPET = "snippet";
523 /**
524 * This string column contains the sender info string for a
525 * conversation.
526 */
527 public static final String SENDER_INFO = "senderInfo";
528 /**
529 * This long column contains the time in ms of the latest update to a
530 * conversation.
531 */
532 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
533
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800534 /**
535 * This boolean column contains whether any messages in this conversation
536 * have attachments.
537 */
538 public static final String HAS_ATTACHMENTS = "hasAttachments";
539
Mindy Pereira4db59c52012-01-12 09:45:13 -0800540 /**
541 * This int column contains the number of messages in this conversation.
542 * For unthreaded, this will always be 1.
543 */
544 public static String NUM_MESSAGES = "numMessages";
545
546 /**
547 * This int column contains the number of drafts associated with this
548 * conversation.
549 */
550 public static String NUM_DRAFTS = "numDrafts";
551
552 /**
553 * This int column contains the state of drafts and replies associated
554 * with this conversation. Use ConversationSendingState to interpret
555 * this field.
556 */
557 public static String SENDING_STATE = "sendingState";
558
559 /**
560 * This int column contains the priority of this conversation. Use
561 * ConversationPriority to interpret this field.
562 */
563 public static String PRIORITY = "priority";
564
Marc Blankc8a99422012-01-19 14:27:47 -0800565 /**
566 * This boolean column indicates whether the conversation has been read
567 */
568 public static String READ = "read";
569
570 /**
571 * This boolean column indicates whether the conversation has been read
572 */
573 public static String STARRED = "starred";
574
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800575 /**
576 * This string column contains a csv of all folders associated with this
577 * conversation
578 */
579 public static final String FOLDER_LIST = "folderList";
580
Paul Westbrook334e64a2012-02-23 13:26:35 -0800581 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800582 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800583 }
584
Mindy Pereira6f92de62011-12-19 11:31:48 -0800585 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800586 * List of operations that can can be performed on a conversation. These operations are applied
587 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
588 * where the conversation uri is specified, and the ContentValues specifies the operation to
589 * be performed.
590 * <p/>
591 * The operation to be performed is specified in the ContentValues by
592 * the {@link ConversationOperations#OPERATION_KEY}
593 * <p/>
594 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
595 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800596 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800597 public static final class ConversationOperations {
598 /**
599 * ContentValues key used to specify the operation to be performed
600 */
601 public static final String OPERATION_KEY = "operation";
602
603 /**
604 * Archive operation
605 */
606 public static final String ARCHIVE = "archive";
607
608 /**
609 * Mute operation
610 */
611 public static final String MUTE = "mute";
612
613 /**
614 * Report spam operation
615 */
616 public static final String REPORT_SPAM = "report_spam";
617
618 private ConversationOperations() {
619 }
620 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800621
622 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800623 public static final int NOT_A_DRAFT = 0;
624 public static final int COMPOSE = 1;
625 public static final int REPLY = 2;
626 public static final int REPLY_ALL = 3;
627 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800628
629 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800630 }
631
Mindy Pereiraa1406072011-12-22 10:54:06 -0800632 public static final String[] MESSAGE_PROJECTION = {
633 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800634 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800635 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800636 MessageColumns.CONVERSATION_ID,
637 MessageColumns.SUBJECT,
638 MessageColumns.SNIPPET,
639 MessageColumns.FROM,
640 MessageColumns.TO,
641 MessageColumns.CC,
642 MessageColumns.BCC,
643 MessageColumns.REPLY_TO,
644 MessageColumns.DATE_RECEIVED_MS,
645 MessageColumns.BODY_HTML,
646 MessageColumns.BODY_TEXT,
647 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
648 MessageColumns.REF_MESSAGE_ID,
649 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800650 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800651 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800652 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800653 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800654 MessageColumns.JOINED_ATTACHMENT_INFOS,
655 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800656 MessageColumns.SEND_MESSAGE_URI,
657 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800658 };
659
Mindy Pereiraf944e962012-01-17 11:43:36 -0800660 /** Separates attachment info parts in strings in a message. */
661 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800662 public static final String MESSAGE_LIST_TYPE =
663 "vnd.android.cursor.dir/vnd.com.android.mail.message";
664 public static final String MESSAGE_TYPE =
665 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800666
Mindy Pereira6349a042012-01-04 11:25:01 -0800667 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800668 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
669 public static final int MESSAGE_URI_COLUMN = 2;
670 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
671 public static final int MESSAGE_SUBJECT_COLUMN = 4;
672 public static final int MESSAGE_SNIPPET_COLUMN = 5;
673 public static final int MESSAGE_FROM_COLUMN = 6;
674 public static final int MESSAGE_TO_COLUMN = 7;
675 public static final int MESSAGE_CC_COLUMN = 8;
676 public static final int MESSAGE_BCC_COLUMN = 9;
677 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
678 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800679 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
680 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800681 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
682 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
683 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800684 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
685 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
686 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
687 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800688 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800689 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
690 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800691 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800692
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800693 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800694 public static final int STARRED = 1 << 0;
695 public static final int UNREAD = 1 << 1;
696 public static final int REPLIED = 1 << 2;
697 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800698 }
699
Mindy Pereira6f92de62011-12-19 11:31:48 -0800700 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800701 /**
702 * This string column contains a content provider URI that points to this single message.
703 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800704 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800705 /**
706 * This string column contains a server-assigned ID for this message.
707 */
708 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800709 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800710 /**
711 * This string column contains the subject of a message.
712 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800713 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800714 /**
715 * This string column contains a snippet of the message body.
716 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800717 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800718 /**
719 * This string column contains the single email address (and optionally name) of the sender.
720 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800721 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800722 /**
723 * This string column contains a comma-delimited list of "To:" recipient email addresses.
724 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800725 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800726 /**
727 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
728 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800729 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800730 /**
731 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
732 * This value will be null for incoming messages.
733 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800734 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800735 /**
736 * This string column contains the single email address (and optionally name) of the
737 * sender's reply-to address.
738 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800739 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800740 /**
741 * This long column contains the timestamp (in millis) of receipt of the message.
742 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800743 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800744 /**
745 * This string column contains the HTML form of the message body, if available. If not,
746 * a provider must populate BODY_TEXT.
747 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800748 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800749 /**
750 * This string column contains the plaintext form of the message body, if HTML is not
751 * otherwise available. If HTML is available, this value should be left empty (null).
752 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800753 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800754 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800755 /**
756 * This string column contains an opaque string used by the sendMessage api.
757 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800758 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800759 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800760 * This integer column contains the type of this draft, or zero (0) if this message is not a
761 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800762 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800763 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800764 /**
765 * This boolean column indicates whether an outgoing message should trigger special quoted
766 * text processing upon send. The value should default to zero (0) for protocols that do
767 * not support or require this flag, and for all incoming messages.
768 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800769 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800770 /**
771 * This boolean column indicates whether a message has attachments. The list of attachments
772 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
773 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800774 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800775 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800776 * This string column contains the content provider URI for the list of
777 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800778 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800779 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800780 /**
781 * This long column is a bit field of flags defined in {@link MessageFlags}.
782 */
Andy Huang732600e2012-01-10 17:47:17 -0800783 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800784 /**
785 * This string column contains a specially formatted string representing all
786 * attachments that we added to a message that is being sent or saved.
787 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800788 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800789 /**
790 * This string column contains the content provider URI for saving this
791 * message.
792 */
793 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
794 /**
795 * This string column contains content provider URI for sending this
796 * message.
797 */
798 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800799
Paul Westbrook104f7292012-02-28 16:07:07 -0800800 /**
801 * This integer column represents whether the user has specified that images should always
802 * be shown. The value of "1" indicates that the user has specified that images should be
803 * shown, while the value of "0" indicates that the user should be prompted before loading
804 * any external images.
805 */
806 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
807
Mindy Pereira6f92de62011-12-19 11:31:48 -0800808 private MessageColumns() {}
809 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800810
811 // We define a "folder" as anything that contains a list of conversations.
812 public static final String ATTACHMENT_LIST_TYPE =
813 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
814 public static final String ATTACHMENT_TYPE =
815 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
816
817 public static final String[] ATTACHMENT_PROJECTION = {
818 BaseColumns._ID,
819 AttachmentColumns.NAME,
820 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800821 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800822 AttachmentColumns.ORIGIN_EXTRAS,
823 AttachmentColumns.CONTENT_TYPE,
824 AttachmentColumns.SYNCED
825 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800826 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800827 public static final int ATTACHMENT_ID_COLUMN = 0;
828 public static final int ATTACHMENT_NAME_COLUMN = 1;
829 public static final int ATTACHMENT_SIZE_COLUMN = 2;
830 public static final int ATTACHMENT_URI_COLUMN = 3;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800831 public static final int ATTACHMENT_ORIGIN_EXTRAS_COLUMN = 4;
832 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 5;
833 public static final int ATTACHMENT_SYNCED_COLUMN = 6;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800834
835 public static final class AttachmentColumns {
836 public static final String NAME = "name";
837 public static final String SIZE = "size";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800838 public static final String URI = "uri";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800839 public static final String ORIGIN_EXTRAS = "originExtras";
840 public static final String CONTENT_TYPE = "contentType";
841 public static final String SYNCED = "synced";
842 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800843
844 public static int getMailMaxAttachmentSize(String account) {
845 // TODO: query the account to see what the max attachment size is?
846 return 5 * 1024 * 1024;
847 }
848
849 public static String getAttachmentTypeSetting() {
850 // TODO: query the account to see what kinds of attachments it supports?
851 return "com.google.android.gm.allowAddAnyAttachment";
852 }
Mindy Pereira82cc5662012-01-09 17:29:30 -0800853
854 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
855 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
856 ArrayList<String> recipients = new ArrayList<String>();
857 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
858 for (String address : addresses) {
859 recipients.add(address);
860 }
861 statsUpdater.updateWithAddress(recipients);
862 }
Marc Blankb31ab5a2012-02-01 12:28:29 -0800863
864 public static final String[] UNDO_PROJECTION = {
865 ConversationColumns.MESSAGE_LIST_URI
866 };
867 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -0800868
869 // Parameter used to indicate the sequence number for an undoable operation
870 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -0800871
872
873 public static final String[] SETTINGS_PROJECTION = {
874 SettingsColumns.SIGNATURE,
875 SettingsColumns.AUTO_ADVANCE,
876 SettingsColumns.MESSAGE_TEXT_SIZE,
877 SettingsColumns.SNAP_HEADERS,
878 SettingsColumns.REPLY_BEHAVIOR,
879 SettingsColumns.HIDE_CHECKBOXES,
880 SettingsColumns.CONFIRM_DELETE,
881 SettingsColumns.CONFIRM_ARCHIVE,
882 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -0800883 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -0800884 };
885
Mindy Pereira8bd82152012-03-01 10:06:35 -0800886 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
887 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
888 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
889 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
890 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
891 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
892 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
893 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
894 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
895 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
896
Paul Westbrook63eef792012-02-27 14:01:06 -0800897 public static final class AutoAdvance {
898 public static final int UNSET = 0;
899 public static final int OLDER = 1;
900 public static final int NEWER = 2;
901 public static final int LIST = 3;
902 }
903
904 public static final class SnapHeaderValue {
905 public static final int ALWAYS = 0;
906 public static final int PORTRAIT_ONLY = 1;
907 public static final int NEVER = 2;
908 }
909
910 public static final class MessageTextSize {
911 public static final int TINY = -2;
912 public static final int SMALL = -1;
913 public static final int NORMAL = 0;
914 public static final int LARGE = 1;
915 public static final int HUGE = 2;
916 }
917
918 public static final class DefaultReplyBehavior {
919 public static final int REPLY = 0;
920 public static final int REPLY_ALL = 1;
921 }
922
923 public static final class SettingsColumns {
924 /**
925 * String column containing the contents of the signature for this account. If no
926 * signature has been specified, the value will be null.
927 */
928 public static final String SIGNATURE = "signature";
929
930 /**
931 * Integer column containing the user's specified auto-advance policy. This value will be
932 * one of the values in {@link UIProvider.AutoAdvance}
933 */
934 public static final String AUTO_ADVANCE = "auto_advance";
935
936 /**
937 * Integer column containing the user's specified message text size preference. This value
938 * will be one of the values in {@link UIProvider.MessageTextSize}
939 */
940 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
941
942 /**
943 * Integer column contaning the user's specified snap header preference. This value
944 * will be one of the values in {@link UIProvider.SnapHeaderValue}
945 */
946 public static final String SNAP_HEADERS = "snap_headers";
947
948 /**
949 * Integer column containing the user's specified default reply behavior. This value will
950 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
951 */
952 public static final String REPLY_BEHAVIOR = "reply_behavior";
953
954 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -0800955 * Integer column containing the user's specified checkbox preference. A
956 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -0800957 */
958 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
959
960 /**
961 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800962 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800963 * be shown when a delete action is performed.
964 */
965 public static final String CONFIRM_DELETE = "confirm_delete";
966
967 /**
968 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800969 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800970 * be shown when an archive action is performed.
971 */
972 public static final String CONFIRM_ARCHIVE = "confirm_archive";
973
974 /**
975 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800976 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800977 * be shown when a send action is performed.
978 */
979 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -0800980 /**
981 * String folder containing the serialized default inbox folder for an account.
982 */
983 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -0800984 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800985}