blob: 5f2d86581aee9ec3c5cafdbda876b90d016f8783 [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;
Marc Blank48a4aed2012-03-10 14:07:00 -080024import android.net.Uri;
Mindy Pereira6f92de62011-12-19 11:31:48 -080025import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080026import android.text.TextUtils;
27
28import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080029
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,
Vikram Aggarwal27e85f22012-03-05 16:29:17 -080098 AccountColumns.MIME_TYPE,
99 AccountColumns.RECENT_FOLDER_LIST_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -0800100 };
101
Mindy Pereira33fe9082012-01-09 16:24:30 -0800102 public static final int ACCOUNT_ID_COLUMN = 0;
103 public static final int ACCOUNT_NAME_COLUMN = 1;
104 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
105 public static final int ACCOUNT_URI_COLUMN = 3;
106 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
107 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
108 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
109 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
110 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
111 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800112 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800113 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800114 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800115 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
116 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
117 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
118 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira898cd382012-03-06 08:42:47 -0800119 public static final int ACCOUNT_MIME_TYPE_COLUMN = 17;
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800120 public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 18;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800121
Mindy Pereira6f92de62011-12-19 11:31:48 -0800122 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800123 /**
124 * Whether folders can be synchronized back to the server.
125 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800126 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800127 /**
128 * Whether the server allows reporting spam back.
129 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800130 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800131 /**
132 * Whether the server supports a concept of Archive: removing mail from the Inbox but
133 * keeping it around.
134 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800135 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800136 /**
137 * Whether the server will stop notifying on updates to this thread? This requires
138 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
139 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800140 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800141 /**
142 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
143 * to be true, otherwise it should be ignored.
144 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800145 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800146 /**
147 * Whether the server supports constraining search to a single folder. Requires
148 * SYNCABLE_FOLDERS, otherwise it should be ignored.
149 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800150 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800151 /**
152 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
153 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800154 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800155 /**
156 * Whether the server allows synchronization of draft messages. This does NOT require
157 * SYNCABLE_FOLDERS to be set.
158 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800159 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800160 /**
161 * Does the server allow the user to compose mails (and reply) using addresses other than
162 * their account name? For instance, GMail allows users to set FROM addresses that are
163 * different from account@gmail.com address. For instance, user@gmail.com could have another
164 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
165 * can compose (and reply) using either address.
166 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800167 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800168 /**
169 * Whether the server allows the original message to be included in the reply by setting a
170 * flag on the reply. If we can avoid including the entire previous message, we save on
171 * bandwidth (replies are shorter).
172 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800173 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800174 /**
175 * Does this account support searching locally, on the device? This requires the backend
176 * storage to support a mechanism for searching.
177 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800178 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800179 /**
180 * Whether the server supports a notion of threaded conversations: where replies to messages
181 * are tagged to keep conversations grouped. This could be full threading (each message
182 * lists its parent) or conversation-level threading (each message lists one conversation
183 * which it belongs to)
184 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800185 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800186 /**
187 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
Mindy Pereira30fd47b2012-03-09 09:24:00 -0800188 * multiple folders on a single conversation)
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800189 */
Mindy Pereira84648892012-02-03 08:29:55 -0800190 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800191 /**
192 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
193 */
194 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800195 /**
196 * Whether the account provides help content.
197 */
198 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800199 /**
200 * Whether the account provides a mechanism for marking conversations as important.
201 */
202 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800203 }
204
205 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800206 /**
207 * This string column contains the human visible name for the account.
208 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800209 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800210
211 /**
212 * This integer column returns the version of the UI provider schema from which this
213 * account provider will return results.
214 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800215 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800216
217 /**
218 * This string column contains the uri to directly access the information for this account.
219 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800220 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800221
222 /**
Andy Huange0b83b82012-03-06 19:57:04 -0800223 * This integer column contains a bit field of the possible capabilities that this account
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800224 * supports.
225 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800226 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800227
228 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800229 * This string column contains the content provider uri to return the
230 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800231 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800232 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800233
234 /**
235 * This string column contains the content provider uri that can be queried for search
236 * results.
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800237 * The supported query parameters are limited to those listed
238 * in {@link #SearchQueryParameters}
Paul Westbrook1475a7a2012-03-08 15:06:27 -0800239 * The cursor returned from this query is expected have one row, where the columnm are a
240 * subset of the columns specified in {@link #FolderColumns}
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,
Marc Blank48a4aed2012-03-10 14:07:00 -0800358 FolderColumns.FG_COLOR,
359 FolderColumns.LOAD_MORE_URI
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800360 };
361
Mindy Pereira818143e2012-01-11 13:59:49 -0800362 public static final int FOLDER_ID_COLUMN = 0;
363 public static final int FOLDER_URI_COLUMN = 1;
364 public static final int FOLDER_NAME_COLUMN = 2;
365 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
366 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800367 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
368 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
369 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
370 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
371 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
372 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
373 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
374 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800375 public static final int FOLDER_TYPE_COLUMN = 13;
376 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
Mindy Pereira9275a062012-03-08 15:12:14 -0800377 public static final int FOLDER_BG_COLOR_COLUMN = 15;
378 public static final int FOLDER_FG_COLOR_COLUMN = 16;
Marc Blank48a4aed2012-03-10 14:07:00 -0800379 public static final int FOLDER_LOAD_MORE_URI_COLUMN = 17;
Mindy Pereira78664722012-03-05 13:53:07 -0800380
381 public static final class FolderType {
382 public static final int DEFAULT = 0;
383 public static final int INBOX = 1;
384 public static final int DRAFT = 2;
385 public static final int OUTBOX = 3;
386 public static final int SENT = 4;
387 public static final int TRASH = 5;
388 public static final int SPAM = 6;
389 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800390
Mindy Pereira0973b202011-12-21 15:48:12 -0800391 public static final class FolderCapabilities {
392 public static final int SYNCABLE = 0x0001;
393 public static final int PARENT = 0x0002;
394 public static final int CAN_HOLD_MAIL = 0x0004;
395 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800396 /**
397 * For accounts that support archive, this will indicate that this folder supports
398 * the archive functionality.
399 */
400 public static final int ARCHIVE = 0x0010;
401
402 /**
403 * For accounts that support report spam, this will indicate that this folder supports
404 * the report spam functionality.
405 */
406 public static final int REPORT_SPAM = 0x0020;
407
408 /**
409 * For accounts that support mute, this will indicate if a mute is performed from within
410 * this folder, the action is destructive.
411 */
412 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800413 }
414
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800415 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800416 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800417 /**
418 * This string column contains the human visible name for the folder.
419 */
420 public static final String NAME = "name";
421 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800422 * This int column represents the capabilities of the folder specified by
423 * FolderCapabilities flags.
424 */
425 public static String CAPABILITIES = "capabilities";
426 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800427 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800428 * child folders.
429 */
430 public static String HAS_CHILDREN = "hasChildren";
431 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800432 * This int column represents how large the sync window is.
433 */
434 public static String SYNC_WINDOW = "syncWindow";
435 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800436 * This string column contains the content provider uri to return the
437 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800438 */
439 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800440 /**
441 * This string column contains the content provider uri to return the
442 * list of child folders of this folder.
443 */
Mindy Pereira77528642012-02-17 15:51:10 -0800444 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800445
Mindy Pereira77528642012-02-17 15:51:10 -0800446 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800447
Mindy Pereira77528642012-02-17 15:51:10 -0800448 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800449 /**
450 * This string column contains the content provider uri to force a
451 * refresh of this folder.
452 */
Mindy Pereira77528642012-02-17 15:51:10 -0800453 public static final String REFRESH_URI = "refreshUri";
454 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800455 * This int column contains current sync status of the folder; some combination of the
456 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800457 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800458 public static final String SYNC_STATUS = "syncStatus";
459 /**
460 * This int column contains the sync status of the last sync attempt; one of the
461 * LastSyncStatus values defined above
462 */
463 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800464 /**
465 * This long column contains the icon res id for this folder, or 0 if there is none.
466 */
467 public static final String ICON_RES_ID = "iconResId";
468 /**
469 * This int column contains the type of the folder. Zero is default.
470 */
471 public static final String TYPE = "type";
Mindy Pereira9275a062012-03-08 15:12:14 -0800472 /**
473 * String representing the integer background color associated with this
474 * folder, or null.
475 */
476 public static final String BG_COLOR = "bgColor";
477 /**
478 * String representing the integer of the foreground color associated
479 * with this folder, or null.
480 */
481 public static final String FG_COLOR = "fgColor";
Marc Blank48a4aed2012-03-10 14:07:00 -0800482 /**
483 * String with the content provider Uri used to request more items in the folder, or null.
484 */
485 public static final String LOAD_MORE_URI = "loadMoreUri";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800486 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800487 }
488
Mindy Pereiraa1406072011-12-22 10:54:06 -0800489 // We define a "folder" as anything that contains a list of conversations.
490 public static final String CONVERSATION_LIST_TYPE =
491 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
492 public static final String CONVERSATION_TYPE =
493 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
494
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800495
Mindy Pereiraa1406072011-12-22 10:54:06 -0800496 public static final String[] CONVERSATION_PROJECTION = {
497 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800498 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800499 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800500 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800501 ConversationColumns.SNIPPET,
502 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800503 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800504 ConversationColumns.HAS_ATTACHMENTS,
505 ConversationColumns.NUM_MESSAGES,
506 ConversationColumns.NUM_DRAFTS,
507 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800508 ConversationColumns.PRIORITY,
509 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800510 ConversationColumns.STARRED,
Mindy Pereiracc8211d2012-03-12 10:35:37 -0700511 ConversationColumns.FOLDER_LIST,
512 ConversationColumns.RAW_FOLDERS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800513 };
514
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800515 // These column indexes only work when the caller uses the
516 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800517 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800518 public static final int CONVERSATION_URI_COLUMN = 1;
519 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
520 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
521 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
522 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
523 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
524 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800525 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
526 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
527 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
528 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800529 public static final int CONVERSATION_READ_COLUMN = 12;
530 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800531 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereiracc8211d2012-03-12 10:35:37 -0700532 public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 15;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800533
534 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800535 public static final int OTHER = 0;
536 public static final int SENDING = 1;
537 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800538 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800539 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800540
541 public static final class ConversationPriority {
542 public static final int LOW = 0;
543 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800544 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800545
Marc Blankc8a99422012-01-19 14:27:47 -0800546 public static final class ConversationFlags {
547 public static final int READ = 1<<0;
548 public static final int STARRED = 1<<1;
549 public static final int REPLIED = 1<<2;
550 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800551 }
Marc Blankc8a99422012-01-19 14:27:47 -0800552
Mindy Pereiraa1406072011-12-22 10:54:06 -0800553 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800554 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800555 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800556 * This string column contains the content provider uri to return the
557 * list of messages for this conversation.
558 */
559 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800560 /**
561 * This string column contains the subject string for a conversation.
562 */
563 public static final String SUBJECT = "subject";
564 /**
565 * This string column contains the snippet string for a conversation.
566 */
567 public static final String SNIPPET = "snippet";
568 /**
569 * This string column contains the sender info string for a
570 * conversation.
571 */
572 public static final String SENDER_INFO = "senderInfo";
573 /**
574 * This long column contains the time in ms of the latest update to a
575 * conversation.
576 */
577 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
578
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800579 /**
580 * This boolean column contains whether any messages in this conversation
581 * have attachments.
582 */
583 public static final String HAS_ATTACHMENTS = "hasAttachments";
584
Mindy Pereira4db59c52012-01-12 09:45:13 -0800585 /**
586 * This int column contains the number of messages in this conversation.
587 * For unthreaded, this will always be 1.
588 */
589 public static String NUM_MESSAGES = "numMessages";
590
591 /**
592 * This int column contains the number of drafts associated with this
593 * conversation.
594 */
595 public static String NUM_DRAFTS = "numDrafts";
596
597 /**
598 * This int column contains the state of drafts and replies associated
599 * with this conversation. Use ConversationSendingState to interpret
600 * this field.
601 */
602 public static String SENDING_STATE = "sendingState";
603
604 /**
605 * This int column contains the priority of this conversation. Use
606 * ConversationPriority to interpret this field.
607 */
608 public static String PRIORITY = "priority";
609
Marc Blankc8a99422012-01-19 14:27:47 -0800610 /**
611 * This boolean column indicates whether the conversation has been read
612 */
613 public static String READ = "read";
614
615 /**
616 * This boolean column indicates whether the conversation has been read
617 */
618 public static String STARRED = "starred";
619
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800620 /**
Mindy Pereiracc8211d2012-03-12 10:35:37 -0700621 * This string column contains a csv of all folder uris associated with this
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800622 * conversation
623 */
624 public static final String FOLDER_LIST = "folderList";
625
Mindy Pereiracc8211d2012-03-12 10:35:37 -0700626 /**
627 * This string column contains a serialized list of all folders
Mindy Pereirab5080d52012-03-09 11:26:44 -0800628 * separated by a Folder.FOLDER_SEPARATOR that are associated with this
629 * conversation. The folders should be only those that the provider
630 * wants to have displayed.
Mindy Pereiracc8211d2012-03-12 10:35:37 -0700631 */
Mindy Pereira183718b2012-03-12 11:00:14 -0700632 public static final String RAW_FOLDERS = "rawFolders";
Paul Westbrook334e64a2012-02-23 13:26:35 -0800633 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800634 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800635 }
636
Mindy Pereira6f92de62011-12-19 11:31:48 -0800637 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800638 * List of operations that can can be performed on a conversation. These operations are applied
639 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
640 * where the conversation uri is specified, and the ContentValues specifies the operation to
641 * be performed.
642 * <p/>
643 * The operation to be performed is specified in the ContentValues by
644 * the {@link ConversationOperations#OPERATION_KEY}
645 * <p/>
646 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
647 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800648 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800649 public static final class ConversationOperations {
650 /**
651 * ContentValues key used to specify the operation to be performed
652 */
653 public static final String OPERATION_KEY = "operation";
654
655 /**
656 * Archive operation
657 */
658 public static final String ARCHIVE = "archive";
659
660 /**
661 * Mute operation
662 */
663 public static final String MUTE = "mute";
664
665 /**
666 * Report spam operation
667 */
668 public static final String REPORT_SPAM = "report_spam";
669
670 private ConversationOperations() {
671 }
672 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800673
674 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800675 public static final int NOT_A_DRAFT = 0;
676 public static final int COMPOSE = 1;
677 public static final int REPLY = 2;
678 public static final int REPLY_ALL = 3;
679 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800680
681 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800682 }
683
Mindy Pereiraa1406072011-12-22 10:54:06 -0800684 public static final String[] MESSAGE_PROJECTION = {
685 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800686 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800687 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800688 MessageColumns.CONVERSATION_ID,
689 MessageColumns.SUBJECT,
690 MessageColumns.SNIPPET,
691 MessageColumns.FROM,
692 MessageColumns.TO,
693 MessageColumns.CC,
694 MessageColumns.BCC,
695 MessageColumns.REPLY_TO,
696 MessageColumns.DATE_RECEIVED_MS,
697 MessageColumns.BODY_HTML,
698 MessageColumns.BODY_TEXT,
699 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
700 MessageColumns.REF_MESSAGE_ID,
701 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800702 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800703 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800704 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800705 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800706 MessageColumns.JOINED_ATTACHMENT_INFOS,
707 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800708 MessageColumns.SEND_MESSAGE_URI,
709 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800710 };
711
Mindy Pereiraf944e962012-01-17 11:43:36 -0800712 /** Separates attachment info parts in strings in a message. */
713 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800714 public static final String MESSAGE_LIST_TYPE =
715 "vnd.android.cursor.dir/vnd.com.android.mail.message";
716 public static final String MESSAGE_TYPE =
717 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800718
Mindy Pereira6349a042012-01-04 11:25:01 -0800719 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800720 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
721 public static final int MESSAGE_URI_COLUMN = 2;
722 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
723 public static final int MESSAGE_SUBJECT_COLUMN = 4;
724 public static final int MESSAGE_SNIPPET_COLUMN = 5;
725 public static final int MESSAGE_FROM_COLUMN = 6;
726 public static final int MESSAGE_TO_COLUMN = 7;
727 public static final int MESSAGE_CC_COLUMN = 8;
728 public static final int MESSAGE_BCC_COLUMN = 9;
729 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
730 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800731 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
732 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800733 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
734 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
735 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800736 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
737 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
738 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
739 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800740 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800741 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
742 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800743 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800744
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800745 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800746 public static final int STARRED = 1 << 0;
747 public static final int UNREAD = 1 << 1;
748 public static final int REPLIED = 1 << 2;
749 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800750 }
751
Mindy Pereira6f92de62011-12-19 11:31:48 -0800752 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800753 /**
754 * This string column contains a content provider URI that points to this single message.
755 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800756 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800757 /**
758 * This string column contains a server-assigned ID for this message.
759 */
760 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800761 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800762 /**
763 * This string column contains the subject of a message.
764 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800765 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800766 /**
767 * This string column contains a snippet of the message body.
768 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800769 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800770 /**
771 * This string column contains the single email address (and optionally name) of the sender.
772 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800773 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800774 /**
775 * This string column contains a comma-delimited list of "To:" recipient email addresses.
776 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800777 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800778 /**
779 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
780 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800781 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800782 /**
783 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
784 * This value will be null for incoming messages.
785 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800786 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800787 /**
788 * This string column contains the single email address (and optionally name) of the
789 * sender's reply-to address.
790 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800791 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800792 /**
793 * This long column contains the timestamp (in millis) of receipt of the message.
794 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800795 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800796 /**
797 * This string column contains the HTML form of the message body, if available. If not,
798 * a provider must populate BODY_TEXT.
799 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800800 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800801 /**
802 * This string column contains the plaintext form of the message body, if HTML is not
803 * otherwise available. If HTML is available, this value should be left empty (null).
804 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800805 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800806 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800807 /**
808 * This string column contains an opaque string used by the sendMessage api.
809 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800810 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800811 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800812 * This integer column contains the type of this draft, or zero (0) if this message is not a
813 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800814 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800815 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800816 /**
817 * This boolean column indicates whether an outgoing message should trigger special quoted
818 * text processing upon send. The value should default to zero (0) for protocols that do
819 * not support or require this flag, and for all incoming messages.
820 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800821 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800822 /**
823 * This boolean column indicates whether a message has attachments. The list of attachments
824 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
825 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800826 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800827 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800828 * This string column contains the content provider URI for the list of
829 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800830 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800831 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800832 /**
833 * This long column is a bit field of flags defined in {@link MessageFlags}.
834 */
Andy Huang732600e2012-01-10 17:47:17 -0800835 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800836 /**
837 * This string column contains a specially formatted string representing all
838 * attachments that we added to a message that is being sent or saved.
839 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800840 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800841 /**
842 * This string column contains the content provider URI for saving this
843 * message.
844 */
845 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
846 /**
847 * This string column contains content provider URI for sending this
848 * message.
849 */
850 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800851
Paul Westbrook104f7292012-02-28 16:07:07 -0800852 /**
853 * This integer column represents whether the user has specified that images should always
854 * be shown. The value of "1" indicates that the user has specified that images should be
855 * shown, while the value of "0" indicates that the user should be prompted before loading
856 * any external images.
857 */
858 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
859
Mindy Pereira6f92de62011-12-19 11:31:48 -0800860 private MessageColumns() {}
861 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800862
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800863 public static final String ATTACHMENT_LIST_TYPE =
864 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
865 public static final String ATTACHMENT_TYPE =
866 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
867
868 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800869 AttachmentColumns.NAME,
870 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800871 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800872 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -0800873 AttachmentColumns.STATE,
874 AttachmentColumns.DESTINATION,
875 AttachmentColumns.DOWNLOADED_SIZE,
876 AttachmentColumns.CONTENT_URI,
877 AttachmentColumns.THUMBNAIL_URI,
878 AttachmentColumns.PREVIEW_INTENT
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800879 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800880 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -0800881 public static final int ATTACHMENT_NAME_COLUMN = 0;
882 public static final int ATTACHMENT_SIZE_COLUMN = 1;
883 public static final int ATTACHMENT_URI_COLUMN = 2;
884 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
885 public static final int ATTACHMENT_STATE_COLUMN = 4;
886 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
887 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
888 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
889 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
890 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800891
Andy Huange0b83b82012-03-06 19:57:04 -0800892 /**
893 * Valid states for the {@link AttachmentColumns#STATE} column.
894 *
895 */
896 public static final class AttachmentState {
897 /**
898 * The full attachment is not present on device. When used as a command,
899 * setting this state will tell the provider to cancel a download in
900 * progress.
901 * <p>
902 * Valid next states: {@link #DOWNLOADING}
903 */
904 public static final int NOT_SAVED = 0;
905 /**
906 * The most recent attachment download attempt failed. The current UI
907 * design does not require providers to persist this state, but
908 * providers must return this state at least once after a download
909 * failure occurs. This state may not be used as a command.
910 * <p>
911 * Valid next states: {@link #DOWNLOADING}
912 */
913 public static final int FAILED = 1;
914 /**
915 * The attachment is currently being downloaded by the provider.
916 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
917 * download progress while in this state. When used as a command,
918 * setting this state will tell the provider to initiate a download to
919 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
920 * .
921 * <p>
922 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
923 * {@link #SAVED}
924 */
925 public static final int DOWNLOADING = 2;
926 /**
927 * The attachment was successfully downloaded to the destination in
928 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
929 * that a download is missing, it should reset the state to
930 * {@link #NOT_SAVED}. This state may not be used as a command on its
931 * own. To move a file from cache to external, update
932 * {@link AttachmentColumns#DESTINATION}.
933 * <p>
934 * Valid next states: {@link #NOT_SAVED}
935 */
936 public static final int SAVED = 3;
937
938 private AttachmentState() {}
939 }
940
941 public static final class AttachmentDestination {
942
943 /**
944 * The attachment will be or is already saved to the app-private cache partition.
945 */
946 public static final int CACHE = 0;
947 /**
948 * The attachment will be or is already saved to external shared device storage.
949 */
950 public static final int EXTERNAL = 1;
951
952 private AttachmentDestination() {}
953 }
954
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800955 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -0800956 /**
957 * This string column is the attachment's file name, intended for display in UI. It is not
958 * the full path of the file.
959 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800960 public static final String NAME = "name";
Andy Huange0b83b82012-03-06 19:57:04 -0800961 /**
962 * This integer column is the file size of the attachment, in bytes.
963 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800964 public static final String SIZE = "size";
Andy Huange0b83b82012-03-06 19:57:04 -0800965 /**
966 * This column is a {@link Uri} that can be queried to monitor download state and progress
967 * for this individual attachment (resulting cursor has one single row for this attachment).
968 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800969 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -0800970 /**
971 * This string column is the MIME type of the attachment.
972 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800973 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -0800974 /**
975 * This integer column is the current downloading state of the
976 * attachment as defined in {@link AttachmentState}.
977 * <p>
978 * Providers must accept updates to {@link URI} with new values of
979 * this column to initiate or cancel downloads.
980 */
981 public static final String STATE = "state";
982 /**
983 * This integer column is the file destination for the current download
984 * in progress (when {@link #STATE} is
985 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
986 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
987 * in {@link AttachmentDestination}. This value is undefined in any
988 * other state.
989 * <p>
990 * Providers must accept updates to {@link URI} with new values of
991 * this column to move an existing downloaded file.
992 */
993 public static final String DESTINATION = "destination";
994 /**
995 * This integer column is the current number of bytes downloaded when
996 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
997 * undefined in any other state.
998 */
999 public static final String DOWNLOADED_SIZE = "downloadedSize";
1000 /**
1001 * This column is a {@link Uri} that points to the downloaded local file
1002 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
1003 * undefined in any other state.
1004 */
1005 public static final String CONTENT_URI = "contentUri";
1006 /**
1007 * This column is a {@link Uri} that points to a local thumbnail file
1008 * for the attachment. Providers that do not support downloading
1009 * attachment thumbnails may leave this null.
1010 */
1011 public static final String THUMBNAIL_URI = "thumbnailUri";
1012 /**
1013 * This column is an {@link Intent} to launch a preview activity that
1014 * allows the user to efficiently view an attachment without having to
1015 * first download the entire file. Providers that do not support
1016 * previewing attachments may leave this null. The intent is represented
1017 * as a byte-array blob generated by writing an Intent to a parcel and
1018 * then marshaling that parcel.
1019 */
1020 public static final String PREVIEW_INTENT = "previewIntent";
1021
1022 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001023 }
Mindy Pereira013194c2012-01-06 15:09:33 -08001024
1025 public static int getMailMaxAttachmentSize(String account) {
1026 // TODO: query the account to see what the max attachment size is?
1027 return 5 * 1024 * 1024;
1028 }
1029
1030 public static String getAttachmentTypeSetting() {
1031 // TODO: query the account to see what kinds of attachments it supports?
1032 return "com.google.android.gm.allowAddAnyAttachment";
1033 }
Mindy Pereira82cc5662012-01-09 17:29:30 -08001034
1035 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1036 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1037 ArrayList<String> recipients = new ArrayList<String>();
1038 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1039 for (String address : addresses) {
1040 recipients.add(address);
1041 }
1042 statsUpdater.updateWithAddress(recipients);
1043 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001044
1045 public static final String[] UNDO_PROJECTION = {
1046 ConversationColumns.MESSAGE_LIST_URI
1047 };
1048 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001049
1050 // Parameter used to indicate the sequence number for an undoable operation
1051 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001052
1053
1054 public static final String[] SETTINGS_PROJECTION = {
1055 SettingsColumns.SIGNATURE,
1056 SettingsColumns.AUTO_ADVANCE,
1057 SettingsColumns.MESSAGE_TEXT_SIZE,
1058 SettingsColumns.SNAP_HEADERS,
1059 SettingsColumns.REPLY_BEHAVIOR,
1060 SettingsColumns.HIDE_CHECKBOXES,
1061 SettingsColumns.CONFIRM_DELETE,
1062 SettingsColumns.CONFIRM_ARCHIVE,
1063 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -08001064 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -08001065 };
1066
Mindy Pereira8bd82152012-03-01 10:06:35 -08001067 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
1068 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
1069 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
1070 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
1071 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
1072 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
1073 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
1074 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
1075 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
1076 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
1077
Paul Westbrook63eef792012-02-27 14:01:06 -08001078 public static final class AutoAdvance {
1079 public static final int UNSET = 0;
1080 public static final int OLDER = 1;
1081 public static final int NEWER = 2;
1082 public static final int LIST = 3;
1083 }
1084
1085 public static final class SnapHeaderValue {
1086 public static final int ALWAYS = 0;
1087 public static final int PORTRAIT_ONLY = 1;
1088 public static final int NEVER = 2;
1089 }
1090
1091 public static final class MessageTextSize {
1092 public static final int TINY = -2;
1093 public static final int SMALL = -1;
1094 public static final int NORMAL = 0;
1095 public static final int LARGE = 1;
1096 public static final int HUGE = 2;
1097 }
1098
1099 public static final class DefaultReplyBehavior {
1100 public static final int REPLY = 0;
1101 public static final int REPLY_ALL = 1;
1102 }
1103
1104 public static final class SettingsColumns {
1105 /**
1106 * String column containing the contents of the signature for this account. If no
1107 * signature has been specified, the value will be null.
1108 */
1109 public static final String SIGNATURE = "signature";
1110
1111 /**
1112 * Integer column containing the user's specified auto-advance policy. This value will be
1113 * one of the values in {@link UIProvider.AutoAdvance}
1114 */
1115 public static final String AUTO_ADVANCE = "auto_advance";
1116
1117 /**
1118 * Integer column containing the user's specified message text size preference. This value
1119 * will be one of the values in {@link UIProvider.MessageTextSize}
1120 */
1121 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
1122
1123 /**
1124 * Integer column contaning the user's specified snap header preference. This value
1125 * will be one of the values in {@link UIProvider.SnapHeaderValue}
1126 */
1127 public static final String SNAP_HEADERS = "snap_headers";
1128
1129 /**
1130 * Integer column containing the user's specified default reply behavior. This value will
1131 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
1132 */
1133 public static final String REPLY_BEHAVIOR = "reply_behavior";
1134
1135 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -08001136 * Integer column containing the user's specified checkbox preference. A
1137 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -08001138 */
1139 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
1140
1141 /**
1142 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001143 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001144 * be shown when a delete action is performed.
1145 */
1146 public static final String CONFIRM_DELETE = "confirm_delete";
1147
1148 /**
1149 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001150 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001151 * be shown when an archive action is performed.
1152 */
1153 public static final String CONFIRM_ARCHIVE = "confirm_archive";
1154
1155 /**
1156 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001157 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001158 * be shown when a send action is performed.
1159 */
1160 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -08001161 /**
1162 * String folder containing the serialized default inbox folder for an account.
1163 */
1164 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001165 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001166}