blob: 428c4b09ee1922b9548bdad0b527f2a491431929 [file] [log] [blame]
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08001/*******************************************************************************
2 * Copyright (C) 2011 Google Inc.
3 * Licensed to The Android Open Source Project.
Mindy Pereira6f92de62011-12-19 11:31:48 -08004 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Mindy Pereira6f92de62011-12-19 11:31:48 -08008 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08009 * http://www.apache.org/licenses/LICENSE-2.0
Mindy Pereira6f92de62011-12-19 11:31:48 -080010 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -080011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
Mindy Pereira6f92de62011-12-19 11:31:48 -080017
Andy Huang30e2c242012-01-06 18:14:30 -080018package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080019
Paul Westbrook334e64a2012-02-23 13:26:35 -080020import android.content.ContentProvider;
21import android.content.ContentValues;
Mindy Pereira82cc5662012-01-09 17:29:30 -080022import android.content.Context;
Andy Huange0b83b82012-03-06 19:57:04 -080023import android.content.Intent;
Mindy Pereira6f92de62011-12-19 11:31:48 -080024import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080025import android.text.TextUtils;
Paul Westbrook334e64a2012-02-23 13:26:35 -080026import android.net.Uri;
Mindy Pereira82cc5662012-01-09 17:29:30 -080027
28import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080029
Paul Westbrook334e64a2012-02-23 13:26:35 -080030import java.lang.String;
Mindy Pereira82cc5662012-01-09 17:29:30 -080031import java.util.ArrayList;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080032
Mindy Pereira6f92de62011-12-19 11:31:48 -080033public class UIProvider {
Mindy Pereira82cc5662012-01-09 17:29:30 -080034 public static final String EMAIL_SEPARATOR = "\n";
Mindy Pereira326c6602012-01-04 15:32:42 -080035 public static final long INVALID_CONVERSATION_ID = -1;
36 public static final long INVALID_MESSAGE_ID = -1;
37
Marc Blank9ace18a2012-02-21 16:34:07 -080038 /**
39 * Values for the current state of a Folder/Account; note that it's possible that more than one
40 * sync is in progress
41 */
42 public static final class SyncStatus {
43 // No sync in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080044 public static final int NO_SYNC = 0;
Marc Blank9ace18a2012-02-21 16:34:07 -080045 // A user-requested sync/refresh is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080046 public static final int USER_REFRESH = 1<<0;
Marc Blank9ace18a2012-02-21 16:34:07 -080047 // A user-requested query is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080048 public static final int USER_QUERY = 1<<1;
Marc Blank9ace18a2012-02-21 16:34:07 -080049 // A user request for additional results is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080050 public static final int USER_MORE_RESULTS = 1<<2;
Marc Blank9ace18a2012-02-21 16:34:07 -080051 // A background sync is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080052 public static final int BACKGROUND_SYNC = 1<<3;
Marc Blank9ace18a2012-02-21 16:34:07 -080053 }
54
55 /**
56 * Values for the result of the last attempted sync of a Folder/Account
57 */
58 public static final class LastSyncResult {
59 // The sync completed successfully
60 public static final int SUCCESS = 0;
61 // The sync wasn't completed due to a connection error
62 public static final int CONNECTION_ERROR = 1;
63 // The sync wasn't completed due to an authentication error
64 public static final int AUTH_ERROR = 2;
65 // The sync wasn't completed due to a security error
66 public static final int SECURITY_ERROR = 3;
67 // The sync wasn't completed due to a low memory condition
68 public static final int STORAGE_ERROR = 4;
69 // The sync wasn't completed due to an internal error/exception
70 public static final int INTERNAL_ERROR = 5;
71 }
72
Paul Westbrook82ea6da2011-12-15 11:03:51 -080073 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -080074 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080075
76 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080077 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080078 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080079 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080080
81 public static final String[] ACCOUNTS_PROJECTION = {
82 BaseColumns._ID,
83 AccountColumns.NAME,
84 AccountColumns.PROVIDER_VERSION,
85 AccountColumns.URI,
86 AccountColumns.CAPABILITIES,
87 AccountColumns.FOLDER_LIST_URI,
88 AccountColumns.SEARCH_URI,
89 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Mindy Pereira33fe9082012-01-09 16:24:30 -080090 AccountColumns.SAVE_DRAFT_URI,
Mindy Pereira7ed1c112012-01-18 10:59:25 -080091 AccountColumns.SEND_MAIL_URI,
Mindy Pereira96b5c352012-02-01 11:33:40 -080092 AccountColumns.EXPUNGE_MESSAGE_URI,
Mindy Pereira9600dac2012-02-17 15:59:25 -080093 AccountColumns.UNDO_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -080094 AccountColumns.SETTINGS_INTENT_URI,
Paul Westbrook63eef792012-02-27 14:01:06 -080095 AccountColumns.SETTINGS_QUERY_URI,
Paul Westbrook94e440d2012-02-24 11:03:47 -080096 AccountColumns.SYNC_STATUS,
Mindy Pereira23755e22012-02-27 13:58:04 -080097 AccountColumns.HELP_INTENT_URI,
Mindy Pereira898cd382012-03-06 08:42:47 -080098 AccountColumns.COMPOSE_URI,
Vikram Aggarwal27e85f22012-03-05 16:29:17 -080099 AccountColumns.MIME_TYPE,
100 AccountColumns.RECENT_FOLDER_LIST_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -0800101 };
102
Mindy Pereira33fe9082012-01-09 16:24:30 -0800103 public static final int ACCOUNT_ID_COLUMN = 0;
104 public static final int ACCOUNT_NAME_COLUMN = 1;
105 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
106 public static final int ACCOUNT_URI_COLUMN = 3;
107 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
108 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
109 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
110 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
111 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
112 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800113 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800114 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800115 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800116 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
117 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
118 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
119 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira898cd382012-03-06 08:42:47 -0800120 public static final int ACCOUNT_MIME_TYPE_COLUMN = 17;
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800121 public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 18;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800122
Mindy Pereira6f92de62011-12-19 11:31:48 -0800123 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800124 /**
125 * Whether folders can be synchronized back to the server.
126 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800127 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800128 /**
129 * Whether the server allows reporting spam back.
130 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800131 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800132 /**
133 * Whether the server supports a concept of Archive: removing mail from the Inbox but
134 * keeping it around.
135 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800136 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800137 /**
138 * Whether the server will stop notifying on updates to this thread? This requires
139 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
140 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800141 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800142 /**
143 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
144 * to be true, otherwise it should be ignored.
145 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800146 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800147 /**
148 * Whether the server supports constraining search to a single folder. Requires
149 * SYNCABLE_FOLDERS, otherwise it should be ignored.
150 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800151 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800152 /**
153 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
154 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800155 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800156 /**
157 * Whether the server allows synchronization of draft messages. This does NOT require
158 * SYNCABLE_FOLDERS to be set.
159 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800160 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800161 /**
162 * Does the server allow the user to compose mails (and reply) using addresses other than
163 * their account name? For instance, GMail allows users to set FROM addresses that are
164 * different from account@gmail.com address. For instance, user@gmail.com could have another
165 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
166 * can compose (and reply) using either address.
167 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800168 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800169 /**
170 * Whether the server allows the original message to be included in the reply by setting a
171 * flag on the reply. If we can avoid including the entire previous message, we save on
172 * bandwidth (replies are shorter).
173 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800174 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800175 /**
176 * Does this account support searching locally, on the device? This requires the backend
177 * storage to support a mechanism for searching.
178 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800179 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800180 /**
181 * Whether the server supports a notion of threaded conversations: where replies to messages
182 * are tagged to keep conversations grouped. This could be full threading (each message
183 * lists its parent) or conversation-level threading (each message lists one conversation
184 * which it belongs to)
185 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800186 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800187 /**
188 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
189 * multiple labels on a single conversation, since labels and folders are interchangeable
190 * in this application.)
191 */
Mindy Pereira84648892012-02-03 08:29:55 -0800192 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800193 /**
194 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
195 */
196 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800197 /**
198 * Whether the account provides help content.
199 */
200 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800201 /**
202 * Whether the account provides a mechanism for marking conversations as important.
203 */
204 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800205 }
206
207 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800208 /**
209 * This string column contains the human visible name for the account.
210 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800211 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800212
213 /**
214 * This integer column returns the version of the UI provider schema from which this
215 * account provider will return results.
216 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800217 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800218
219 /**
220 * This string column contains the uri to directly access the information for this account.
221 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800222 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800223
224 /**
Andy Huange0b83b82012-03-06 19:57:04 -0800225 * This integer column contains a bit field of the possible capabilities that this account
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800226 * supports.
227 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800228 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800229
230 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800231 * This string column contains the content provider uri to return the
232 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800233 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800234 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800235
236 /**
237 * This string column contains the content provider uri that can be queried for search
238 * results.
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800239 * The supported query parameters are limited to those listed
240 * in {@link #SearchQueryParameters}
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800241 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800242 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800243
244 /**
245 * This string column contains the content provider uri that can be queried to access the
246 * from addresses for this account.
247 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800248 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800249
250 /**
251 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800252 * new draft messages for this account. NOTE: This might be better to
253 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800254 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800255 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800256
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800257 /**
258 * This string column contains the content provider uri that can be used to send
259 * a message for this account.
260 * NOTE: This might be better to be an update operation on the messageUri.
261 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800262 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800263
264 /**
265 * This string column contains the content provider uri that can be used
266 * to expunge a message from this account. NOTE: This might be better to
267 * be an update operation on the messageUri.
268 */
269 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800270
271 /**
272 * This string column contains the content provider uri that can be used
273 * to undo the last committed action.
274 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800275 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800276
277 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800278 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800279 * shown.
280 * TODO: When we want to support a heterogeneous set of account types, this value may need
281 * to be moved to a global content provider.
282 */
283 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800284
285 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800286 * This string column contains the content provider uri that can be used to query user
287 * settings/preferences.
288 *
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800289 * The cursor returned by this query support columns declared in {@link #SettingsColumns}
Paul Westbrook63eef792012-02-27 14:01:06 -0800290 */
291 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
292
293 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800294 * Uri for VIEW intent that will cause the help screens for this account type to be
295 * shown.
296 * TODO: When we want to support a heterogeneous set of account types, this value may need
297 * to be moved to a global content provider.
298 */
299 public static String HELP_INTENT_URI = "helpIntentUri";
300
301 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800302 * This int column contains the current sync status of the account (the logical AND of the
303 * sync status of folders in this account)
304 */
305 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800306 /**
307 * Uri for VIEW intent that will cause the compose screens for this type
308 * of account to be shown.
309 */
310 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800311 /**
312 * Mime-type defining this account.
313 */
314 public static final String MIME_TYPE = "mimeType";
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800315 /**
316 * URI for location of recent folders viewed on this account.
317 */
318 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800319 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800320
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800321 public static final class SearchQueryParameters {
322 /**
323 * Parameter used to specify the search query.
324 */
325 public static final String QUERY = "query";
326
327 /**
328 * If specified, the query results will be limited to this folder.
329 */
330 public static final String FOLDER = "folder";
331
332 private SearchQueryParameters() {}
333 }
334
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800335 // We define a "folder" as anything that contains a list of conversations.
336 public static final String FOLDER_LIST_TYPE =
337 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
338 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800339 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800340
341 public static final String[] FOLDERS_PROJECTION = {
342 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800343 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800344 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800345 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800346 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800347 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800348 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800349 FolderColumns.CHILD_FOLDERS_LIST_URI,
350 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800351 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800352 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800353 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800354 FolderColumns.LAST_SYNC_RESULT,
355 FolderColumns.TYPE,
Mindy Pereira9275a062012-03-08 15:12:14 -0800356 FolderColumns.ICON_RES_ID,
357 FolderColumns.BG_COLOR,
358 FolderColumns.FG_COLOR
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800359 };
360
Mindy Pereira818143e2012-01-11 13:59:49 -0800361 public static final int FOLDER_ID_COLUMN = 0;
362 public static final int FOLDER_URI_COLUMN = 1;
363 public static final int FOLDER_NAME_COLUMN = 2;
364 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
365 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800366 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
367 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
368 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
369 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
370 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
371 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
372 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
373 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800374 public static final int FOLDER_TYPE_COLUMN = 13;
375 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
Mindy Pereira9275a062012-03-08 15:12:14 -0800376 public static final int FOLDER_BG_COLOR_COLUMN = 15;
377 public static final int FOLDER_FG_COLOR_COLUMN = 16;
Mindy Pereira78664722012-03-05 13:53:07 -0800378
379 public static final class FolderType {
380 public static final int DEFAULT = 0;
381 public static final int INBOX = 1;
382 public static final int DRAFT = 2;
383 public static final int OUTBOX = 3;
384 public static final int SENT = 4;
385 public static final int TRASH = 5;
386 public static final int SPAM = 6;
387 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800388
Mindy Pereira0973b202011-12-21 15:48:12 -0800389 public static final class FolderCapabilities {
390 public static final int SYNCABLE = 0x0001;
391 public static final int PARENT = 0x0002;
392 public static final int CAN_HOLD_MAIL = 0x0004;
393 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800394 /**
395 * For accounts that support archive, this will indicate that this folder supports
396 * the archive functionality.
397 */
398 public static final int ARCHIVE = 0x0010;
399
400 /**
401 * For accounts that support report spam, this will indicate that this folder supports
402 * the report spam functionality.
403 */
404 public static final int REPORT_SPAM = 0x0020;
405
406 /**
407 * For accounts that support mute, this will indicate if a mute is performed from within
408 * this folder, the action is destructive.
409 */
410 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800411 }
412
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800413 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800414 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800415 /**
416 * This string column contains the human visible name for the folder.
417 */
418 public static final String NAME = "name";
419 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800420 * This int column represents the capabilities of the folder specified by
421 * FolderCapabilities flags.
422 */
423 public static String CAPABILITIES = "capabilities";
424 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800425 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800426 * child folders.
427 */
428 public static String HAS_CHILDREN = "hasChildren";
429 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800430 * This int column represents how large the sync window is.
431 */
432 public static String SYNC_WINDOW = "syncWindow";
433 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800434 * This string column contains the content provider uri to return the
435 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800436 */
437 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800438 /**
439 * This string column contains the content provider uri to return the
440 * list of child folders of this folder.
441 */
Mindy Pereira77528642012-02-17 15:51:10 -0800442 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800443
Mindy Pereira77528642012-02-17 15:51:10 -0800444 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800445
Mindy Pereira77528642012-02-17 15:51:10 -0800446 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800447 /**
448 * This string column contains the content provider uri to force a
449 * refresh of this folder.
450 */
Mindy Pereira77528642012-02-17 15:51:10 -0800451 public static final String REFRESH_URI = "refreshUri";
452 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800453 * This int column contains current sync status of the folder; some combination of the
454 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800455 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800456 public static final String SYNC_STATUS = "syncStatus";
457 /**
458 * This int column contains the sync status of the last sync attempt; one of the
459 * LastSyncStatus values defined above
460 */
461 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800462 /**
463 * This long column contains the icon res id for this folder, or 0 if there is none.
464 */
465 public static final String ICON_RES_ID = "iconResId";
466 /**
467 * This int column contains the type of the folder. Zero is default.
468 */
469 public static final String TYPE = "type";
Mindy Pereira9275a062012-03-08 15:12:14 -0800470 /**
471 * String representing the integer background color associated with this
472 * folder, or null.
473 */
474 public static final String BG_COLOR = "bgColor";
475 /**
476 * String representing the integer of the foreground color associated
477 * with this folder, or null.
478 */
479 public static final String FG_COLOR = "fgColor";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800480 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800481 }
482
Mindy Pereiraa1406072011-12-22 10:54:06 -0800483 // We define a "folder" as anything that contains a list of conversations.
484 public static final String CONVERSATION_LIST_TYPE =
485 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
486 public static final String CONVERSATION_TYPE =
487 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
488
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800489
Mindy Pereiraa1406072011-12-22 10:54:06 -0800490 public static final String[] CONVERSATION_PROJECTION = {
491 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800492 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800493 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800494 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800495 ConversationColumns.SNIPPET,
496 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800497 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800498 ConversationColumns.HAS_ATTACHMENTS,
499 ConversationColumns.NUM_MESSAGES,
500 ConversationColumns.NUM_DRAFTS,
501 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800502 ConversationColumns.PRIORITY,
503 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800504 ConversationColumns.STARRED,
505 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800506 };
507
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800508 // These column indexes only work when the caller uses the
509 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800510 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800511 public static final int CONVERSATION_URI_COLUMN = 1;
512 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
513 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
514 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
515 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
516 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
517 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800518 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
519 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
520 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
521 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800522 public static final int CONVERSATION_READ_COLUMN = 12;
523 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800524 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800525
526 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800527 public static final int OTHER = 0;
528 public static final int SENDING = 1;
529 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800530 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800531 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800532
533 public static final class ConversationPriority {
534 public static final int LOW = 0;
535 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800536 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800537
Marc Blankc8a99422012-01-19 14:27:47 -0800538 public static final class ConversationFlags {
539 public static final int READ = 1<<0;
540 public static final int STARRED = 1<<1;
541 public static final int REPLIED = 1<<2;
542 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800543 }
Marc Blankc8a99422012-01-19 14:27:47 -0800544
Mindy Pereiraa1406072011-12-22 10:54:06 -0800545 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800546 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800547 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800548 * This string column contains the content provider uri to return the
549 * list of messages for this conversation.
550 */
551 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800552 /**
553 * This string column contains the subject string for a conversation.
554 */
555 public static final String SUBJECT = "subject";
556 /**
557 * This string column contains the snippet string for a conversation.
558 */
559 public static final String SNIPPET = "snippet";
560 /**
561 * This string column contains the sender info string for a
562 * conversation.
563 */
564 public static final String SENDER_INFO = "senderInfo";
565 /**
566 * This long column contains the time in ms of the latest update to a
567 * conversation.
568 */
569 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
570
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800571 /**
572 * This boolean column contains whether any messages in this conversation
573 * have attachments.
574 */
575 public static final String HAS_ATTACHMENTS = "hasAttachments";
576
Mindy Pereira4db59c52012-01-12 09:45:13 -0800577 /**
578 * This int column contains the number of messages in this conversation.
579 * For unthreaded, this will always be 1.
580 */
581 public static String NUM_MESSAGES = "numMessages";
582
583 /**
584 * This int column contains the number of drafts associated with this
585 * conversation.
586 */
587 public static String NUM_DRAFTS = "numDrafts";
588
589 /**
590 * This int column contains the state of drafts and replies associated
591 * with this conversation. Use ConversationSendingState to interpret
592 * this field.
593 */
594 public static String SENDING_STATE = "sendingState";
595
596 /**
597 * This int column contains the priority of this conversation. Use
598 * ConversationPriority to interpret this field.
599 */
600 public static String PRIORITY = "priority";
601
Marc Blankc8a99422012-01-19 14:27:47 -0800602 /**
603 * This boolean column indicates whether the conversation has been read
604 */
605 public static String READ = "read";
606
607 /**
608 * This boolean column indicates whether the conversation has been read
609 */
610 public static String STARRED = "starred";
611
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800612 /**
613 * This string column contains a csv of all folders associated with this
614 * conversation
615 */
616 public static final String FOLDER_LIST = "folderList";
617
Paul Westbrook334e64a2012-02-23 13:26:35 -0800618 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800619 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800620 }
621
Mindy Pereira6f92de62011-12-19 11:31:48 -0800622 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800623 * List of operations that can can be performed on a conversation. These operations are applied
624 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
625 * where the conversation uri is specified, and the ContentValues specifies the operation to
626 * be performed.
627 * <p/>
628 * The operation to be performed is specified in the ContentValues by
629 * the {@link ConversationOperations#OPERATION_KEY}
630 * <p/>
631 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
632 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800633 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800634 public static final class ConversationOperations {
635 /**
636 * ContentValues key used to specify the operation to be performed
637 */
638 public static final String OPERATION_KEY = "operation";
639
640 /**
641 * Archive operation
642 */
643 public static final String ARCHIVE = "archive";
644
645 /**
646 * Mute operation
647 */
648 public static final String MUTE = "mute";
649
650 /**
651 * Report spam operation
652 */
653 public static final String REPORT_SPAM = "report_spam";
654
655 private ConversationOperations() {
656 }
657 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800658
659 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800660 public static final int NOT_A_DRAFT = 0;
661 public static final int COMPOSE = 1;
662 public static final int REPLY = 2;
663 public static final int REPLY_ALL = 3;
664 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800665
666 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800667 }
668
Mindy Pereiraa1406072011-12-22 10:54:06 -0800669 public static final String[] MESSAGE_PROJECTION = {
670 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800671 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800672 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800673 MessageColumns.CONVERSATION_ID,
674 MessageColumns.SUBJECT,
675 MessageColumns.SNIPPET,
676 MessageColumns.FROM,
677 MessageColumns.TO,
678 MessageColumns.CC,
679 MessageColumns.BCC,
680 MessageColumns.REPLY_TO,
681 MessageColumns.DATE_RECEIVED_MS,
682 MessageColumns.BODY_HTML,
683 MessageColumns.BODY_TEXT,
684 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
685 MessageColumns.REF_MESSAGE_ID,
686 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800687 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800688 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800689 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800690 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800691 MessageColumns.JOINED_ATTACHMENT_INFOS,
692 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800693 MessageColumns.SEND_MESSAGE_URI,
694 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800695 };
696
Mindy Pereiraf944e962012-01-17 11:43:36 -0800697 /** Separates attachment info parts in strings in a message. */
698 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800699 public static final String MESSAGE_LIST_TYPE =
700 "vnd.android.cursor.dir/vnd.com.android.mail.message";
701 public static final String MESSAGE_TYPE =
702 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800703
Mindy Pereira6349a042012-01-04 11:25:01 -0800704 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800705 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
706 public static final int MESSAGE_URI_COLUMN = 2;
707 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
708 public static final int MESSAGE_SUBJECT_COLUMN = 4;
709 public static final int MESSAGE_SNIPPET_COLUMN = 5;
710 public static final int MESSAGE_FROM_COLUMN = 6;
711 public static final int MESSAGE_TO_COLUMN = 7;
712 public static final int MESSAGE_CC_COLUMN = 8;
713 public static final int MESSAGE_BCC_COLUMN = 9;
714 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
715 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800716 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
717 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800718 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
719 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
720 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800721 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
722 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
723 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
724 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800725 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800726 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
727 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800728 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800729
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800730 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800731 public static final int STARRED = 1 << 0;
732 public static final int UNREAD = 1 << 1;
733 public static final int REPLIED = 1 << 2;
734 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800735 }
736
Mindy Pereira6f92de62011-12-19 11:31:48 -0800737 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800738 /**
739 * This string column contains a content provider URI that points to this single message.
740 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800741 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800742 /**
743 * This string column contains a server-assigned ID for this message.
744 */
745 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800746 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800747 /**
748 * This string column contains the subject of a message.
749 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800750 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800751 /**
752 * This string column contains a snippet of the message body.
753 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800754 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800755 /**
756 * This string column contains the single email address (and optionally name) of the sender.
757 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800758 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800759 /**
760 * This string column contains a comma-delimited list of "To:" recipient email addresses.
761 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800762 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800763 /**
764 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
765 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800766 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800767 /**
768 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
769 * This value will be null for incoming messages.
770 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800771 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800772 /**
773 * This string column contains the single email address (and optionally name) of the
774 * sender's reply-to address.
775 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800776 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800777 /**
778 * This long column contains the timestamp (in millis) of receipt of the message.
779 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800780 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800781 /**
782 * This string column contains the HTML form of the message body, if available. If not,
783 * a provider must populate BODY_TEXT.
784 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800785 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800786 /**
787 * This string column contains the plaintext form of the message body, if HTML is not
788 * otherwise available. If HTML is available, this value should be left empty (null).
789 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800790 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800791 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800792 /**
793 * This string column contains an opaque string used by the sendMessage api.
794 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800795 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800796 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800797 * This integer column contains the type of this draft, or zero (0) if this message is not a
798 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800799 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800800 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800801 /**
802 * This boolean column indicates whether an outgoing message should trigger special quoted
803 * text processing upon send. The value should default to zero (0) for protocols that do
804 * not support or require this flag, and for all incoming messages.
805 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800806 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800807 /**
808 * This boolean column indicates whether a message has attachments. The list of attachments
809 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
810 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800811 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800812 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800813 * This string column contains the content provider URI for the list of
814 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800815 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800816 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800817 /**
818 * This long column is a bit field of flags defined in {@link MessageFlags}.
819 */
Andy Huang732600e2012-01-10 17:47:17 -0800820 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800821 /**
822 * This string column contains a specially formatted string representing all
823 * attachments that we added to a message that is being sent or saved.
824 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800825 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800826 /**
827 * This string column contains the content provider URI for saving this
828 * message.
829 */
830 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
831 /**
832 * This string column contains content provider URI for sending this
833 * message.
834 */
835 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800836
Paul Westbrook104f7292012-02-28 16:07:07 -0800837 /**
838 * This integer column represents whether the user has specified that images should always
839 * be shown. The value of "1" indicates that the user has specified that images should be
840 * shown, while the value of "0" indicates that the user should be prompted before loading
841 * any external images.
842 */
843 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
844
Mindy Pereira6f92de62011-12-19 11:31:48 -0800845 private MessageColumns() {}
846 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800847
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800848 public static final String ATTACHMENT_LIST_TYPE =
849 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
850 public static final String ATTACHMENT_TYPE =
851 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
852
853 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800854 AttachmentColumns.NAME,
855 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800856 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800857 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -0800858 AttachmentColumns.STATE,
859 AttachmentColumns.DESTINATION,
860 AttachmentColumns.DOWNLOADED_SIZE,
861 AttachmentColumns.CONTENT_URI,
862 AttachmentColumns.THUMBNAIL_URI,
863 AttachmentColumns.PREVIEW_INTENT
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800864 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800865 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -0800866 public static final int ATTACHMENT_NAME_COLUMN = 0;
867 public static final int ATTACHMENT_SIZE_COLUMN = 1;
868 public static final int ATTACHMENT_URI_COLUMN = 2;
869 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
870 public static final int ATTACHMENT_STATE_COLUMN = 4;
871 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
872 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
873 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
874 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
875 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800876
Andy Huange0b83b82012-03-06 19:57:04 -0800877 /**
878 * Valid states for the {@link AttachmentColumns#STATE} column.
879 *
880 */
881 public static final class AttachmentState {
882 /**
883 * The full attachment is not present on device. When used as a command,
884 * setting this state will tell the provider to cancel a download in
885 * progress.
886 * <p>
887 * Valid next states: {@link #DOWNLOADING}
888 */
889 public static final int NOT_SAVED = 0;
890 /**
891 * The most recent attachment download attempt failed. The current UI
892 * design does not require providers to persist this state, but
893 * providers must return this state at least once after a download
894 * failure occurs. This state may not be used as a command.
895 * <p>
896 * Valid next states: {@link #DOWNLOADING}
897 */
898 public static final int FAILED = 1;
899 /**
900 * The attachment is currently being downloaded by the provider.
901 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
902 * download progress while in this state. When used as a command,
903 * setting this state will tell the provider to initiate a download to
904 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
905 * .
906 * <p>
907 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
908 * {@link #SAVED}
909 */
910 public static final int DOWNLOADING = 2;
911 /**
912 * The attachment was successfully downloaded to the destination in
913 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
914 * that a download is missing, it should reset the state to
915 * {@link #NOT_SAVED}. This state may not be used as a command on its
916 * own. To move a file from cache to external, update
917 * {@link AttachmentColumns#DESTINATION}.
918 * <p>
919 * Valid next states: {@link #NOT_SAVED}
920 */
921 public static final int SAVED = 3;
922
923 private AttachmentState() {}
924 }
925
926 public static final class AttachmentDestination {
927
928 /**
929 * The attachment will be or is already saved to the app-private cache partition.
930 */
931 public static final int CACHE = 0;
932 /**
933 * The attachment will be or is already saved to external shared device storage.
934 */
935 public static final int EXTERNAL = 1;
936
937 private AttachmentDestination() {}
938 }
939
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800940 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -0800941 /**
942 * This string column is the attachment's file name, intended for display in UI. It is not
943 * the full path of the file.
944 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800945 public static final String NAME = "name";
Andy Huange0b83b82012-03-06 19:57:04 -0800946 /**
947 * This integer column is the file size of the attachment, in bytes.
948 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800949 public static final String SIZE = "size";
Andy Huange0b83b82012-03-06 19:57:04 -0800950 /**
951 * This column is a {@link Uri} that can be queried to monitor download state and progress
952 * for this individual attachment (resulting cursor has one single row for this attachment).
953 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800954 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -0800955 /**
956 * This string column is the MIME type of the attachment.
957 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800958 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -0800959 /**
960 * This integer column is the current downloading state of the
961 * attachment as defined in {@link AttachmentState}.
962 * <p>
963 * Providers must accept updates to {@link URI} with new values of
964 * this column to initiate or cancel downloads.
965 */
966 public static final String STATE = "state";
967 /**
968 * This integer column is the file destination for the current download
969 * in progress (when {@link #STATE} is
970 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
971 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
972 * in {@link AttachmentDestination}. This value is undefined in any
973 * other state.
974 * <p>
975 * Providers must accept updates to {@link URI} with new values of
976 * this column to move an existing downloaded file.
977 */
978 public static final String DESTINATION = "destination";
979 /**
980 * This integer column is the current number of bytes downloaded when
981 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
982 * undefined in any other state.
983 */
984 public static final String DOWNLOADED_SIZE = "downloadedSize";
985 /**
986 * This column is a {@link Uri} that points to the downloaded local file
987 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
988 * undefined in any other state.
989 */
990 public static final String CONTENT_URI = "contentUri";
991 /**
992 * This column is a {@link Uri} that points to a local thumbnail file
993 * for the attachment. Providers that do not support downloading
994 * attachment thumbnails may leave this null.
995 */
996 public static final String THUMBNAIL_URI = "thumbnailUri";
997 /**
998 * This column is an {@link Intent} to launch a preview activity that
999 * allows the user to efficiently view an attachment without having to
1000 * first download the entire file. Providers that do not support
1001 * previewing attachments may leave this null. The intent is represented
1002 * as a byte-array blob generated by writing an Intent to a parcel and
1003 * then marshaling that parcel.
1004 */
1005 public static final String PREVIEW_INTENT = "previewIntent";
1006
1007 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001008 }
Mindy Pereira013194c2012-01-06 15:09:33 -08001009
1010 public static int getMailMaxAttachmentSize(String account) {
1011 // TODO: query the account to see what the max attachment size is?
1012 return 5 * 1024 * 1024;
1013 }
1014
1015 public static String getAttachmentTypeSetting() {
1016 // TODO: query the account to see what kinds of attachments it supports?
1017 return "com.google.android.gm.allowAddAnyAttachment";
1018 }
Mindy Pereira82cc5662012-01-09 17:29:30 -08001019
1020 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1021 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1022 ArrayList<String> recipients = new ArrayList<String>();
1023 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1024 for (String address : addresses) {
1025 recipients.add(address);
1026 }
1027 statsUpdater.updateWithAddress(recipients);
1028 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001029
1030 public static final String[] UNDO_PROJECTION = {
1031 ConversationColumns.MESSAGE_LIST_URI
1032 };
1033 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001034
1035 // Parameter used to indicate the sequence number for an undoable operation
1036 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001037
1038
1039 public static final String[] SETTINGS_PROJECTION = {
1040 SettingsColumns.SIGNATURE,
1041 SettingsColumns.AUTO_ADVANCE,
1042 SettingsColumns.MESSAGE_TEXT_SIZE,
1043 SettingsColumns.SNAP_HEADERS,
1044 SettingsColumns.REPLY_BEHAVIOR,
1045 SettingsColumns.HIDE_CHECKBOXES,
1046 SettingsColumns.CONFIRM_DELETE,
1047 SettingsColumns.CONFIRM_ARCHIVE,
1048 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -08001049 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -08001050 };
1051
Mindy Pereira8bd82152012-03-01 10:06:35 -08001052 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
1053 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
1054 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
1055 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
1056 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
1057 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
1058 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
1059 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
1060 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
1061 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
1062
Paul Westbrook63eef792012-02-27 14:01:06 -08001063 public static final class AutoAdvance {
1064 public static final int UNSET = 0;
1065 public static final int OLDER = 1;
1066 public static final int NEWER = 2;
1067 public static final int LIST = 3;
1068 }
1069
1070 public static final class SnapHeaderValue {
1071 public static final int ALWAYS = 0;
1072 public static final int PORTRAIT_ONLY = 1;
1073 public static final int NEVER = 2;
1074 }
1075
1076 public static final class MessageTextSize {
1077 public static final int TINY = -2;
1078 public static final int SMALL = -1;
1079 public static final int NORMAL = 0;
1080 public static final int LARGE = 1;
1081 public static final int HUGE = 2;
1082 }
1083
1084 public static final class DefaultReplyBehavior {
1085 public static final int REPLY = 0;
1086 public static final int REPLY_ALL = 1;
1087 }
1088
1089 public static final class SettingsColumns {
1090 /**
1091 * String column containing the contents of the signature for this account. If no
1092 * signature has been specified, the value will be null.
1093 */
1094 public static final String SIGNATURE = "signature";
1095
1096 /**
1097 * Integer column containing the user's specified auto-advance policy. This value will be
1098 * one of the values in {@link UIProvider.AutoAdvance}
1099 */
1100 public static final String AUTO_ADVANCE = "auto_advance";
1101
1102 /**
1103 * Integer column containing the user's specified message text size preference. This value
1104 * will be one of the values in {@link UIProvider.MessageTextSize}
1105 */
1106 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
1107
1108 /**
1109 * Integer column contaning the user's specified snap header preference. This value
1110 * will be one of the values in {@link UIProvider.SnapHeaderValue}
1111 */
1112 public static final String SNAP_HEADERS = "snap_headers";
1113
1114 /**
1115 * Integer column containing the user's specified default reply behavior. This value will
1116 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
1117 */
1118 public static final String REPLY_BEHAVIOR = "reply_behavior";
1119
1120 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -08001121 * Integer column containing the user's specified checkbox preference. A
1122 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -08001123 */
1124 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
1125
1126 /**
1127 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001128 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001129 * be shown when a delete action is performed.
1130 */
1131 public static final String CONFIRM_DELETE = "confirm_delete";
1132
1133 /**
1134 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001135 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001136 * be shown when an archive action is performed.
1137 */
1138 public static final String CONFIRM_ARCHIVE = "confirm_archive";
1139
1140 /**
1141 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001142 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001143 * be shown when a send action is performed.
1144 */
1145 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -08001146 /**
1147 * String folder containing the serialized default inbox folder for an account.
1148 */
1149 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001150 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001151}