blob: bd704ac81f4e37ab98c785e9d6c4e9e94bc74549 [file] [log] [blame]
Mindy Pereira6f92de62011-12-19 11:31:48 -08001/**
2 * Copyright (c) 2011, Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andy Huang30e2c242012-01-06 18:14:30 -080017package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080018
Mindy Pereira82cc5662012-01-09 17:29:30 -080019import android.content.Context;
Mindy Pereira6f92de62011-12-19 11:31:48 -080020import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080021import android.text.TextUtils;
22
23import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080024
Paul Westbrook82ea6da2011-12-15 11:03:51 -080025import java.lang.String;
Mindy Pereira82cc5662012-01-09 17:29:30 -080026import java.util.ArrayList;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080027
Mindy Pereira6f92de62011-12-19 11:31:48 -080028
29public class UIProvider {
Mindy Pereira82cc5662012-01-09 17:29:30 -080030 public static final String EMAIL_SEPARATOR = "\n";
Mindy Pereira326c6602012-01-04 15:32:42 -080031 public static final long INVALID_CONVERSATION_ID = -1;
32 public static final long INVALID_MESSAGE_ID = -1;
33
Paul Westbrook82ea6da2011-12-15 11:03:51 -080034 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -080035 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080036
37 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080038 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080039 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080040 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080041
42 public static final String[] ACCOUNTS_PROJECTION = {
43 BaseColumns._ID,
44 AccountColumns.NAME,
45 AccountColumns.PROVIDER_VERSION,
46 AccountColumns.URI,
47 AccountColumns.CAPABILITIES,
48 AccountColumns.FOLDER_LIST_URI,
49 AccountColumns.SEARCH_URI,
50 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Mindy Pereira33fe9082012-01-09 16:24:30 -080051 AccountColumns.SAVE_DRAFT_URI,
Mindy Pereira82cc5662012-01-09 17:29:30 -080052 AccountColumns.SEND_MESSAGE_URI,
53 AccountColumns.EXPUNGE_MESSAGE_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -080054 };
55
Mindy Pereira33fe9082012-01-09 16:24:30 -080056 public static final int ACCOUNT_ID_COLUMN = 0;
57 public static final int ACCOUNT_NAME_COLUMN = 1;
58 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
59 public static final int ACCOUNT_URI_COLUMN = 3;
60 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
61 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
62 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
63 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
64 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
65 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -080066 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira33fe9082012-01-09 16:24:30 -080067
Mindy Pereira6f92de62011-12-19 11:31:48 -080068 public static final class AccountCapabilities {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080069 public static final int SYNCABLE_FOLDERS = 0x0001;
70 public static final int REPORT_SPAM = 0x0002;
71 public static final int ARCHIVE = 0x0004;
72 public static final int MUTE = 0x0008;
73 public static final int SERVER_SEARCH = 0x0010;
74 public static final int FOLDER_SERVER_SEARCH = 0x0020;
75 public static final int SANITIZED_HTML = 0x0040;
76 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
77 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
78 public static final int SMART_REPLY = 0x0200;
79 public static final int LOCAL_SEARCH = 0x0400;
80 public static final int THREADED_CONVERSATIONS = 0x0800;
Mindy Pereira6f92de62011-12-19 11:31:48 -080081 }
82
83 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080084 /**
85 * This string column contains the human visible name for the account.
86 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080087 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080088
89 /**
90 * This integer column returns the version of the UI provider schema from which this
91 * account provider will return results.
92 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080093 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080094
95 /**
96 * This string column contains the uri to directly access the information for this account.
97 */
Mindy Pereira6349a042012-01-04 11:25:01 -080098 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080099
100 /**
101 * This integer column contains a bit field of the possible cabibilities that this account
102 * supports.
103 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800104 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800105
106 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800107 * This string column contains the content provider uri to return the
108 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800109 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800110 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800111
112 /**
113 * This string column contains the content provider uri that can be queried for search
114 * results.
115 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800116 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800117
118 /**
119 * This string column contains the content provider uri that can be queried to access the
120 * from addresses for this account.
121 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800122 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800123
124 /**
125 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800126 * new draft messages for this account. NOTE: This might be better to
127 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800128 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800129 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800130
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800131 /**
132 * This string column contains the content provider uri that can be used to send
133 * a message for this account.
134 * NOTE: This might be better to be an update operation on the messageUri.
135 */
136 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800137
138 /**
139 * This string column contains the content provider uri that can be used
140 * to expunge a message from this account. NOTE: This might be better to
141 * be an update operation on the messageUri.
142 */
143 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800144 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800145
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800146 // We define a "folder" as anything that contains a list of conversations.
147 public static final String FOLDER_LIST_TYPE =
148 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
149 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800150 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800151
152 public static final String[] FOLDERS_PROJECTION = {
153 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800154 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800155 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800156 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800157 FolderColumns.CAPABILITIES,
158 FolderColumns.SYNC_FREQUENCY,
159 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800160 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800161 FolderColumns.CHILD_FOLDERS_LIST_URI,
162 FolderColumns.UNREAD_COUNT,
163 FolderColumns.TOTAL_COUNT
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800164 };
165
Mindy Pereira818143e2012-01-11 13:59:49 -0800166 public static final int FOLDER_ID_COLUMN = 0;
167 public static final int FOLDER_URI_COLUMN = 1;
168 public static final int FOLDER_NAME_COLUMN = 2;
169 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
170 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
171 public static final int FOLDER_SYNC_FREQUENCY_COLUMN = 5;
172 public static final int FOLDER_SYNC_WINDOW_COLUMN = 6;
173 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 7;
174 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 8;
175 public static final int FOLDER_UNREAD_COUNT_COLUMN = 9;
176 public static final int FOLDER_TOTAL_COUNT_COLUMN = 10;
177
Mindy Pereira0973b202011-12-21 15:48:12 -0800178 public static final class FolderCapabilities {
179 public static final int SYNCABLE = 0x0001;
180 public static final int PARENT = 0x0002;
181 public static final int CAN_HOLD_MAIL = 0x0004;
182 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
183 }
184
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800185 public static final class FolderColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800186 public static String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800187 /**
188 * This string column contains the human visible name for the folder.
189 */
190 public static final String NAME = "name";
191 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800192 * This int column represents the capabilities of the folder specified by
193 * FolderCapabilities flags.
194 */
195 public static String CAPABILITIES = "capabilities";
196 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800197 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800198 * child folders.
199 */
200 public static String HAS_CHILDREN = "hasChildren";
201 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800202 * This int column represents how often the folder should be synced.
203 */
204 public static String SYNC_FREQUENCY = "syncFrequency";
205 /**
206 * This int column represents how large the sync window is.
207 */
208 public static String SYNC_WINDOW = "syncWindow";
209 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800210 * This string column contains the content provider uri to return the
211 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800212 */
213 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800214 /**
215 * This string column contains the content provider uri to return the
216 * list of child folders of this folder.
217 */
218 public static String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800219
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800220 public static String UNREAD_COUNT = "unreadCount";
221
222 public static String TOTAL_COUNT = "totalCount";
223
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800224 public FolderColumns() {};
Mindy Pereira6f92de62011-12-19 11:31:48 -0800225 }
226
Mindy Pereiraa1406072011-12-22 10:54:06 -0800227 // We define a "folder" as anything that contains a list of conversations.
228 public static final String CONVERSATION_LIST_TYPE =
229 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
230 public static final String CONVERSATION_TYPE =
231 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
232
233 public static final String[] CONVERSATION_PROJECTION = {
234 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800235 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800236 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800237 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800238 ConversationColumns.SNIPPET,
239 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800240 ConversationColumns.DATE_RECEIVED_MS,
241 ConversationColumns.HAS_ATTACHMENTS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800242 };
243
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800244 // These column indexes only work when the caller uses the
245 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800246 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800247 public static final int CONVERSATION_URI_COLUMN = 1;
248 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
249 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
250 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
251 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
252 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
253 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800254
Mindy Pereiraa1406072011-12-22 10:54:06 -0800255 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800256 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800257 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800258 * This string column contains the content provider uri to return the
259 * list of messages for this conversation.
260 */
261 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800262 /**
263 * This string column contains the subject string for a conversation.
264 */
265 public static final String SUBJECT = "subject";
266 /**
267 * This string column contains the snippet string for a conversation.
268 */
269 public static final String SNIPPET = "snippet";
270 /**
271 * This string column contains the sender info string for a
272 * conversation.
273 */
274 public static final String SENDER_INFO = "senderInfo";
275 /**
276 * This long column contains the time in ms of the latest update to a
277 * conversation.
278 */
279 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
280
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800281 /**
282 * This boolean column contains whether any messages in this conversation
283 * have attachments.
284 */
285 public static final String HAS_ATTACHMENTS = "hasAttachments";
286
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800287 public ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800288 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800289 }
290
Mindy Pereira6f92de62011-12-19 11:31:48 -0800291 /**
292 * Returns a uri that, when queried, will return a cursor with a list of information for the
293 * list of configured accounts.
294 * @return
295 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800296 // TODO: create a static registry for the starting point for the UI provider.
297// public static Uri getAccountsUri() {
298// return Uri.parse(BASE_URI_STRING + "/");
299// }
300
301 public static final class DraftType {
302 public static final String COMPOSE = "compose";
303 public static final String REPLY = "reply";
304 public static final String REPLY_ALL = "replyAll";
305 public static final String FORWARD = "forward";
306
307 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800308 }
309
Mindy Pereiraa1406072011-12-22 10:54:06 -0800310 public static final String[] MESSAGE_PROJECTION = {
311 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800312 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800313 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800314 MessageColumns.CONVERSATION_ID,
315 MessageColumns.SUBJECT,
316 MessageColumns.SNIPPET,
317 MessageColumns.FROM,
318 MessageColumns.TO,
319 MessageColumns.CC,
320 MessageColumns.BCC,
321 MessageColumns.REPLY_TO,
322 MessageColumns.DATE_RECEIVED_MS,
323 MessageColumns.BODY_HTML,
324 MessageColumns.BODY_TEXT,
325 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
326 MessageColumns.REF_MESSAGE_ID,
327 MessageColumns.DRAFT_TYPE,
328 MessageColumns.INCLUDE_QUOTED_TEXT,
329 MessageColumns.QUOTE_START_POS,
330 MessageColumns.CLIENT_CREATED,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800331 MessageColumns.CUSTOM_FROM_ADDRESS,
332 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800333 MessageColumns.ATTACHMENT_LIST_URI,
334 MessageColumns.MESSAGE_FLAGS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800335 };
336
Mindy Pereiraa1406072011-12-22 10:54:06 -0800337 public static final String MESSAGE_LIST_TYPE =
338 "vnd.android.cursor.dir/vnd.com.android.mail.message";
339 public static final String MESSAGE_TYPE =
340 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800341
Mindy Pereira6349a042012-01-04 11:25:01 -0800342 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800343 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
344 public static final int MESSAGE_URI_COLUMN = 2;
345 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
346 public static final int MESSAGE_SUBJECT_COLUMN = 4;
347 public static final int MESSAGE_SNIPPET_COLUMN = 5;
348 public static final int MESSAGE_FROM_COLUMN = 6;
349 public static final int MESSAGE_TO_COLUMN = 7;
350 public static final int MESSAGE_CC_COLUMN = 8;
351 public static final int MESSAGE_BCC_COLUMN = 9;
352 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
353 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
354 public static final int MESSAGE_BODY_HTML = 12;
355 public static final int MESSAGE_BODY_TEXT = 13;
356 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
357 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
358 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
359 public static final int MESSAGE_INCLUDE_QUOTED_TEXT_COLUMN = 17;
360 public static final int MESSAGE_QUOTE_START_POS_COLUMN = 18;
361 public static final int MESSAGE_CLIENT_CREATED_COLUMN = 19;
362 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 20;
363 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 21;
364 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 22;
365 public static final int MESSAGE_FLAGS_COLUMN = 23;
Mindy Pereira6349a042012-01-04 11:25:01 -0800366
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800367 public static final class MessageFlags {
368 public static final int SYNCABLE = 0x0001;
369 public static final int PARENT = 0x0002;
370 public static final int CAN_HOLD_MAIL = 0x0004;
371 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Mindy Pereira326c6602012-01-04 15:32:42 -0800372 public static final int STARRED = 0x0012;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800373 }
374
Mindy Pereira6f92de62011-12-19 11:31:48 -0800375 public static final class MessageColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800376 public static final String URI = "messageUri";
Mindy Pereira326c6602012-01-04 15:32:42 -0800377 public static final String SERVER_ID = "localMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800378 public static final String CONVERSATION_ID = "conversationId";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800379 public static final String SUBJECT = "subject";
380 public static final String SNIPPET = "snippet";
381 public static final String FROM = "fromAddress";
382 public static final String TO = "toAddresses";
383 public static final String CC = "ccAddresses";
384 public static final String BCC = "bccAddresses";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800385 public static final String REPLY_TO = "replyToAddress";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800386 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800387 public static final String BODY_HTML = "bodyHtml";
388 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800389 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
390 public static final String REF_MESSAGE_ID = "refMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800391 public static final String DRAFT_TYPE = "draftType";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800392 public static final String INCLUDE_QUOTED_TEXT = "includeQuotedText";
393 public static final String QUOTE_START_POS = "quoteStartPos";
394 public static final String CLIENT_CREATED = "clientCreated";
395 public static final String CUSTOM_FROM_ADDRESS = "customFromAddress";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800396 public static final String HAS_ATTACHMENTS = "hasAttachments";
397 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huang732600e2012-01-10 17:47:17 -0800398 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800399
400 private MessageColumns() {}
401 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800402
403 // We define a "folder" as anything that contains a list of conversations.
404 public static final String ATTACHMENT_LIST_TYPE =
405 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
406 public static final String ATTACHMENT_TYPE =
407 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
408
409 public static final String[] ATTACHMENT_PROJECTION = {
410 BaseColumns._ID,
411 AttachmentColumns.NAME,
412 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800413 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800414 AttachmentColumns.ORIGIN_EXTRAS,
415 AttachmentColumns.CONTENT_TYPE,
416 AttachmentColumns.SYNCED
417 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800418 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800419 public static final int ATTACHMENT_ID_COLUMN = 0;
420 public static final int ATTACHMENT_NAME_COLUMN = 1;
421 public static final int ATTACHMENT_SIZE_COLUMN = 2;
422 public static final int ATTACHMENT_URI_COLUMN = 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800423
424 public static final class AttachmentColumns {
425 public static final String NAME = "name";
426 public static final String SIZE = "size";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800427 public static final String URI = "uri";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800428 public static final String ORIGIN_EXTRAS = "originExtras";
429 public static final String CONTENT_TYPE = "contentType";
430 public static final String SYNCED = "synced";
431 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800432
433 public static int getMailMaxAttachmentSize(String account) {
434 // TODO: query the account to see what the max attachment size is?
435 return 5 * 1024 * 1024;
436 }
437
438 public static String getAttachmentTypeSetting() {
439 // TODO: query the account to see what kinds of attachments it supports?
440 return "com.google.android.gm.allowAddAnyAttachment";
441 }
Mindy Pereira82cc5662012-01-09 17:29:30 -0800442
443 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
444 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
445 ArrayList<String> recipients = new ArrayList<String>();
446 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
447 for (String address : addresses) {
448 recipients.add(address);
449 }
450 statsUpdater.updateWithAddress(recipients);
451 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800452}