blob: 4458fefc3f44a72fc30c2305dfd6c11f64ef20f1 [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,
99 AccountColumns.MIME_TYPE
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;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800120
Mindy Pereira6f92de62011-12-19 11:31:48 -0800121 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800122 /**
123 * Whether folders can be synchronized back to the server.
124 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800125 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800126 /**
127 * Whether the server allows reporting spam back.
128 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800129 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800130 /**
131 * Whether the server supports a concept of Archive: removing mail from the Inbox but
132 * keeping it around.
133 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800134 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800135 /**
136 * Whether the server will stop notifying on updates to this thread? This requires
137 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
138 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800139 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800140 /**
141 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
142 * to be true, otherwise it should be ignored.
143 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800144 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800145 /**
146 * Whether the server supports constraining search to a single folder. Requires
147 * SYNCABLE_FOLDERS, otherwise it should be ignored.
148 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800149 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800150 /**
151 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
152 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800153 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800154 /**
155 * Whether the server allows synchronization of draft messages. This does NOT require
156 * SYNCABLE_FOLDERS to be set.
157 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800158 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800159 /**
160 * Does the server allow the user to compose mails (and reply) using addresses other than
161 * their account name? For instance, GMail allows users to set FROM addresses that are
162 * different from account@gmail.com address. For instance, user@gmail.com could have another
163 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
164 * can compose (and reply) using either address.
165 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800166 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800167 /**
168 * Whether the server allows the original message to be included in the reply by setting a
169 * flag on the reply. If we can avoid including the entire previous message, we save on
170 * bandwidth (replies are shorter).
171 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800172 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800173 /**
174 * Does this account support searching locally, on the device? This requires the backend
175 * storage to support a mechanism for searching.
176 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800177 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800178 /**
179 * Whether the server supports a notion of threaded conversations: where replies to messages
180 * are tagged to keep conversations grouped. This could be full threading (each message
181 * lists its parent) or conversation-level threading (each message lists one conversation
182 * which it belongs to)
183 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800184 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800185 /**
186 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
187 * multiple labels on a single conversation, since labels and folders are interchangeable
188 * in this application.)
189 */
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 Westbrook82ea6da2011-12-15 11:03:51 -0800239 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800240 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800241
242 /**
243 * This string column contains the content provider uri that can be queried to access the
244 * from addresses for this account.
245 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800246 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800247
248 /**
249 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800250 * new draft messages for this account. NOTE: This might be better to
251 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800252 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800253 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800254
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800255 /**
256 * This string column contains the content provider uri that can be used to send
257 * a message for this account.
258 * NOTE: This might be better to be an update operation on the messageUri.
259 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800260 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800261
262 /**
263 * This string column contains the content provider uri that can be used
264 * to expunge a message from this account. NOTE: This might be better to
265 * be an update operation on the messageUri.
266 */
267 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800268
269 /**
270 * This string column contains the content provider uri that can be used
271 * to undo the last committed action.
272 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800273 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800274
275 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800276 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800277 * shown.
278 * TODO: When we want to support a heterogeneous set of account types, this value may need
279 * to be moved to a global content provider.
280 */
281 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800282
283 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800284 * This string column contains the content provider uri that can be used to query user
285 * settings/preferences.
286 *
287 * The cursor returned by this query support columnms declared in {@link #SettingsColumns}
288 */
289 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
290
291 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800292 * Uri for VIEW intent that will cause the help screens for this account type to be
293 * shown.
294 * TODO: When we want to support a heterogeneous set of account types, this value may need
295 * to be moved to a global content provider.
296 */
297 public static String HELP_INTENT_URI = "helpIntentUri";
298
299 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800300 * This int column contains the current sync status of the account (the logical AND of the
301 * sync status of folders in this account)
302 */
303 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800304 /**
305 * Uri for VIEW intent that will cause the compose screens for this type
306 * of account to be shown.
307 */
308 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800309 /**
310 * Mime-type defining this account.
311 */
312 public static final String MIME_TYPE = "mimeType";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800313 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800314
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800315 public static final class SearchQueryParameters {
316 /**
317 * Parameter used to specify the search query.
318 */
319 public static final String QUERY = "query";
320
321 /**
322 * If specified, the query results will be limited to this folder.
323 */
324 public static final String FOLDER = "folder";
325
326 private SearchQueryParameters() {}
327 }
328
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800329 // We define a "folder" as anything that contains a list of conversations.
330 public static final String FOLDER_LIST_TYPE =
331 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
332 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800333 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800334
335 public static final String[] FOLDERS_PROJECTION = {
336 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800337 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800338 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800339 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800340 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800341 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800342 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800343 FolderColumns.CHILD_FOLDERS_LIST_URI,
344 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800345 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800346 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800347 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800348 FolderColumns.LAST_SYNC_RESULT,
349 FolderColumns.TYPE,
350 FolderColumns.ICON_RES_ID
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800351 };
352
Mindy Pereira818143e2012-01-11 13:59:49 -0800353 public static final int FOLDER_ID_COLUMN = 0;
354 public static final int FOLDER_URI_COLUMN = 1;
355 public static final int FOLDER_NAME_COLUMN = 2;
356 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
357 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800358 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
359 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
360 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
361 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
362 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
363 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
364 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
365 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800366 public static final int FOLDER_TYPE_COLUMN = 13;
367 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
368
369 public static final class FolderType {
370 public static final int DEFAULT = 0;
371 public static final int INBOX = 1;
372 public static final int DRAFT = 2;
373 public static final int OUTBOX = 3;
374 public static final int SENT = 4;
375 public static final int TRASH = 5;
376 public static final int SPAM = 6;
377 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800378
Mindy Pereira0973b202011-12-21 15:48:12 -0800379 public static final class FolderCapabilities {
380 public static final int SYNCABLE = 0x0001;
381 public static final int PARENT = 0x0002;
382 public static final int CAN_HOLD_MAIL = 0x0004;
383 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800384 /**
385 * For accounts that support archive, this will indicate that this folder supports
386 * the archive functionality.
387 */
388 public static final int ARCHIVE = 0x0010;
389
390 /**
391 * For accounts that support report spam, this will indicate that this folder supports
392 * the report spam functionality.
393 */
394 public static final int REPORT_SPAM = 0x0020;
395
396 /**
397 * For accounts that support mute, this will indicate if a mute is performed from within
398 * this folder, the action is destructive.
399 */
400 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800401 }
402
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800403 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800404 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800405 /**
406 * This string column contains the human visible name for the folder.
407 */
408 public static final String NAME = "name";
409 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800410 * This int column represents the capabilities of the folder specified by
411 * FolderCapabilities flags.
412 */
413 public static String CAPABILITIES = "capabilities";
414 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800415 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800416 * child folders.
417 */
418 public static String HAS_CHILDREN = "hasChildren";
419 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800420 * This int column represents how large the sync window is.
421 */
422 public static String SYNC_WINDOW = "syncWindow";
423 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800424 * This string column contains the content provider uri to return the
425 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800426 */
427 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800428 /**
429 * This string column contains the content provider uri to return the
430 * list of child folders of this folder.
431 */
Mindy Pereira77528642012-02-17 15:51:10 -0800432 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800433
Mindy Pereira77528642012-02-17 15:51:10 -0800434 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800435
Mindy Pereira77528642012-02-17 15:51:10 -0800436 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800437 /**
438 * This string column contains the content provider uri to force a
439 * refresh of this folder.
440 */
Mindy Pereira77528642012-02-17 15:51:10 -0800441 public static final String REFRESH_URI = "refreshUri";
442 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800443 * This int column contains current sync status of the folder; some combination of the
444 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800445 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800446 public static final String SYNC_STATUS = "syncStatus";
447 /**
448 * This int column contains the sync status of the last sync attempt; one of the
449 * LastSyncStatus values defined above
450 */
451 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800452 /**
453 * This long column contains the icon res id for this folder, or 0 if there is none.
454 */
455 public static final String ICON_RES_ID = "iconResId";
456 /**
457 * This int column contains the type of the folder. Zero is default.
458 */
459 public static final String TYPE = "type";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800460 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800461 }
462
Mindy Pereiraa1406072011-12-22 10:54:06 -0800463 // We define a "folder" as anything that contains a list of conversations.
464 public static final String CONVERSATION_LIST_TYPE =
465 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
466 public static final String CONVERSATION_TYPE =
467 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
468
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800469
Mindy Pereiraa1406072011-12-22 10:54:06 -0800470 public static final String[] CONVERSATION_PROJECTION = {
471 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800472 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800473 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800474 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800475 ConversationColumns.SNIPPET,
476 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800477 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800478 ConversationColumns.HAS_ATTACHMENTS,
479 ConversationColumns.NUM_MESSAGES,
480 ConversationColumns.NUM_DRAFTS,
481 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800482 ConversationColumns.PRIORITY,
483 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800484 ConversationColumns.STARRED,
485 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800486 };
487
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800488 // These column indexes only work when the caller uses the
489 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800490 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800491 public static final int CONVERSATION_URI_COLUMN = 1;
492 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
493 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
494 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
495 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
496 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
497 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800498 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
499 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
500 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
501 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800502 public static final int CONVERSATION_READ_COLUMN = 12;
503 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800504 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800505
506 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800507 public static final int OTHER = 0;
508 public static final int SENDING = 1;
509 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800510 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800511 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800512
513 public static final class ConversationPriority {
514 public static final int LOW = 0;
515 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800516 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800517
Marc Blankc8a99422012-01-19 14:27:47 -0800518 public static final class ConversationFlags {
519 public static final int READ = 1<<0;
520 public static final int STARRED = 1<<1;
521 public static final int REPLIED = 1<<2;
522 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800523 }
Marc Blankc8a99422012-01-19 14:27:47 -0800524
Mindy Pereiraa1406072011-12-22 10:54:06 -0800525 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800526 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800527 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800528 * This string column contains the content provider uri to return the
529 * list of messages for this conversation.
530 */
531 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800532 /**
533 * This string column contains the subject string for a conversation.
534 */
535 public static final String SUBJECT = "subject";
536 /**
537 * This string column contains the snippet string for a conversation.
538 */
539 public static final String SNIPPET = "snippet";
540 /**
541 * This string column contains the sender info string for a
542 * conversation.
543 */
544 public static final String SENDER_INFO = "senderInfo";
545 /**
546 * This long column contains the time in ms of the latest update to a
547 * conversation.
548 */
549 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
550
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800551 /**
552 * This boolean column contains whether any messages in this conversation
553 * have attachments.
554 */
555 public static final String HAS_ATTACHMENTS = "hasAttachments";
556
Mindy Pereira4db59c52012-01-12 09:45:13 -0800557 /**
558 * This int column contains the number of messages in this conversation.
559 * For unthreaded, this will always be 1.
560 */
561 public static String NUM_MESSAGES = "numMessages";
562
563 /**
564 * This int column contains the number of drafts associated with this
565 * conversation.
566 */
567 public static String NUM_DRAFTS = "numDrafts";
568
569 /**
570 * This int column contains the state of drafts and replies associated
571 * with this conversation. Use ConversationSendingState to interpret
572 * this field.
573 */
574 public static String SENDING_STATE = "sendingState";
575
576 /**
577 * This int column contains the priority of this conversation. Use
578 * ConversationPriority to interpret this field.
579 */
580 public static String PRIORITY = "priority";
581
Marc Blankc8a99422012-01-19 14:27:47 -0800582 /**
583 * This boolean column indicates whether the conversation has been read
584 */
585 public static String READ = "read";
586
587 /**
588 * This boolean column indicates whether the conversation has been read
589 */
590 public static String STARRED = "starred";
591
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800592 /**
593 * This string column contains a csv of all folders associated with this
594 * conversation
595 */
596 public static final String FOLDER_LIST = "folderList";
597
Paul Westbrook334e64a2012-02-23 13:26:35 -0800598 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800599 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800600 }
601
Mindy Pereira6f92de62011-12-19 11:31:48 -0800602 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800603 * List of operations that can can be performed on a conversation. These operations are applied
604 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
605 * where the conversation uri is specified, and the ContentValues specifies the operation to
606 * be performed.
607 * <p/>
608 * The operation to be performed is specified in the ContentValues by
609 * the {@link ConversationOperations#OPERATION_KEY}
610 * <p/>
611 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
612 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800613 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800614 public static final class ConversationOperations {
615 /**
616 * ContentValues key used to specify the operation to be performed
617 */
618 public static final String OPERATION_KEY = "operation";
619
620 /**
621 * Archive operation
622 */
623 public static final String ARCHIVE = "archive";
624
625 /**
626 * Mute operation
627 */
628 public static final String MUTE = "mute";
629
630 /**
631 * Report spam operation
632 */
633 public static final String REPORT_SPAM = "report_spam";
634
635 private ConversationOperations() {
636 }
637 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800638
639 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800640 public static final int NOT_A_DRAFT = 0;
641 public static final int COMPOSE = 1;
642 public static final int REPLY = 2;
643 public static final int REPLY_ALL = 3;
644 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800645
646 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800647 }
648
Mindy Pereiraa1406072011-12-22 10:54:06 -0800649 public static final String[] MESSAGE_PROJECTION = {
650 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800651 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800652 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800653 MessageColumns.CONVERSATION_ID,
654 MessageColumns.SUBJECT,
655 MessageColumns.SNIPPET,
656 MessageColumns.FROM,
657 MessageColumns.TO,
658 MessageColumns.CC,
659 MessageColumns.BCC,
660 MessageColumns.REPLY_TO,
661 MessageColumns.DATE_RECEIVED_MS,
662 MessageColumns.BODY_HTML,
663 MessageColumns.BODY_TEXT,
664 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
665 MessageColumns.REF_MESSAGE_ID,
666 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800667 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800668 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800669 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800670 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800671 MessageColumns.JOINED_ATTACHMENT_INFOS,
672 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800673 MessageColumns.SEND_MESSAGE_URI,
674 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800675 };
676
Mindy Pereiraf944e962012-01-17 11:43:36 -0800677 /** Separates attachment info parts in strings in a message. */
678 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800679 public static final String MESSAGE_LIST_TYPE =
680 "vnd.android.cursor.dir/vnd.com.android.mail.message";
681 public static final String MESSAGE_TYPE =
682 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800683
Mindy Pereira6349a042012-01-04 11:25:01 -0800684 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800685 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
686 public static final int MESSAGE_URI_COLUMN = 2;
687 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
688 public static final int MESSAGE_SUBJECT_COLUMN = 4;
689 public static final int MESSAGE_SNIPPET_COLUMN = 5;
690 public static final int MESSAGE_FROM_COLUMN = 6;
691 public static final int MESSAGE_TO_COLUMN = 7;
692 public static final int MESSAGE_CC_COLUMN = 8;
693 public static final int MESSAGE_BCC_COLUMN = 9;
694 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
695 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800696 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
697 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800698 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
699 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
700 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800701 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
702 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
703 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
704 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800705 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800706 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
707 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800708 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800709
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800710 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800711 public static final int STARRED = 1 << 0;
712 public static final int UNREAD = 1 << 1;
713 public static final int REPLIED = 1 << 2;
714 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800715 }
716
Mindy Pereira6f92de62011-12-19 11:31:48 -0800717 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800718 /**
719 * This string column contains a content provider URI that points to this single message.
720 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800721 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800722 /**
723 * This string column contains a server-assigned ID for this message.
724 */
725 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800726 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800727 /**
728 * This string column contains the subject of a message.
729 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800730 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800731 /**
732 * This string column contains a snippet of the message body.
733 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800734 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800735 /**
736 * This string column contains the single email address (and optionally name) of the sender.
737 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800738 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800739 /**
740 * This string column contains a comma-delimited list of "To:" recipient email addresses.
741 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800742 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800743 /**
744 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
745 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800746 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800747 /**
748 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
749 * This value will be null for incoming messages.
750 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800751 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800752 /**
753 * This string column contains the single email address (and optionally name) of the
754 * sender's reply-to address.
755 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800756 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800757 /**
758 * This long column contains the timestamp (in millis) of receipt of the message.
759 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800760 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800761 /**
762 * This string column contains the HTML form of the message body, if available. If not,
763 * a provider must populate BODY_TEXT.
764 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800765 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800766 /**
767 * This string column contains the plaintext form of the message body, if HTML is not
768 * otherwise available. If HTML is available, this value should be left empty (null).
769 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800770 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800771 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800772 /**
773 * This string column contains an opaque string used by the sendMessage api.
774 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800775 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800776 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800777 * This integer column contains the type of this draft, or zero (0) if this message is not a
778 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800779 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800780 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800781 /**
782 * This boolean column indicates whether an outgoing message should trigger special quoted
783 * text processing upon send. The value should default to zero (0) for protocols that do
784 * not support or require this flag, and for all incoming messages.
785 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800786 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800787 /**
788 * This boolean column indicates whether a message has attachments. The list of attachments
789 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
790 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800791 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800792 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800793 * This string column contains the content provider URI for the list of
794 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800795 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800796 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800797 /**
798 * This long column is a bit field of flags defined in {@link MessageFlags}.
799 */
Andy Huang732600e2012-01-10 17:47:17 -0800800 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800801 /**
802 * This string column contains a specially formatted string representing all
803 * attachments that we added to a message that is being sent or saved.
804 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800805 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800806 /**
807 * This string column contains the content provider URI for saving this
808 * message.
809 */
810 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
811 /**
812 * This string column contains content provider URI for sending this
813 * message.
814 */
815 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800816
Paul Westbrook104f7292012-02-28 16:07:07 -0800817 /**
818 * This integer column represents whether the user has specified that images should always
819 * be shown. The value of "1" indicates that the user has specified that images should be
820 * shown, while the value of "0" indicates that the user should be prompted before loading
821 * any external images.
822 */
823 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
824
Mindy Pereira6f92de62011-12-19 11:31:48 -0800825 private MessageColumns() {}
826 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800827
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800828 public static final String ATTACHMENT_LIST_TYPE =
829 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
830 public static final String ATTACHMENT_TYPE =
831 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
832
833 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800834 AttachmentColumns.NAME,
835 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800836 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800837 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -0800838 AttachmentColumns.STATE,
839 AttachmentColumns.DESTINATION,
840 AttachmentColumns.DOWNLOADED_SIZE,
841 AttachmentColumns.CONTENT_URI,
842 AttachmentColumns.THUMBNAIL_URI,
843 AttachmentColumns.PREVIEW_INTENT
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800844 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800845 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -0800846 public static final int ATTACHMENT_NAME_COLUMN = 0;
847 public static final int ATTACHMENT_SIZE_COLUMN = 1;
848 public static final int ATTACHMENT_URI_COLUMN = 2;
849 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
850 public static final int ATTACHMENT_STATE_COLUMN = 4;
851 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
852 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
853 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
854 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
855 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800856
Andy Huange0b83b82012-03-06 19:57:04 -0800857 /**
858 * Valid states for the {@link AttachmentColumns#STATE} column.
859 *
860 */
861 public static final class AttachmentState {
862 /**
863 * The full attachment is not present on device. When used as a command,
864 * setting this state will tell the provider to cancel a download in
865 * progress.
866 * <p>
867 * Valid next states: {@link #DOWNLOADING}
868 */
869 public static final int NOT_SAVED = 0;
870 /**
871 * The most recent attachment download attempt failed. The current UI
872 * design does not require providers to persist this state, but
873 * providers must return this state at least once after a download
874 * failure occurs. This state may not be used as a command.
875 * <p>
876 * Valid next states: {@link #DOWNLOADING}
877 */
878 public static final int FAILED = 1;
879 /**
880 * The attachment is currently being downloaded by the provider.
881 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
882 * download progress while in this state. When used as a command,
883 * setting this state will tell the provider to initiate a download to
884 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
885 * .
886 * <p>
887 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
888 * {@link #SAVED}
889 */
890 public static final int DOWNLOADING = 2;
891 /**
892 * The attachment was successfully downloaded to the destination in
893 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
894 * that a download is missing, it should reset the state to
895 * {@link #NOT_SAVED}. This state may not be used as a command on its
896 * own. To move a file from cache to external, update
897 * {@link AttachmentColumns#DESTINATION}.
898 * <p>
899 * Valid next states: {@link #NOT_SAVED}
900 */
901 public static final int SAVED = 3;
902
903 private AttachmentState() {}
904 }
905
906 public static final class AttachmentDestination {
907
908 /**
909 * The attachment will be or is already saved to the app-private cache partition.
910 */
911 public static final int CACHE = 0;
912 /**
913 * The attachment will be or is already saved to external shared device storage.
914 */
915 public static final int EXTERNAL = 1;
916
917 private AttachmentDestination() {}
918 }
919
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800920 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -0800921 /**
922 * This string column is the attachment's file name, intended for display in UI. It is not
923 * the full path of the file.
924 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800925 public static final String NAME = "name";
Andy Huange0b83b82012-03-06 19:57:04 -0800926 /**
927 * This integer column is the file size of the attachment, in bytes.
928 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800929 public static final String SIZE = "size";
Andy Huange0b83b82012-03-06 19:57:04 -0800930 /**
931 * This column is a {@link Uri} that can be queried to monitor download state and progress
932 * for this individual attachment (resulting cursor has one single row for this attachment).
933 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800934 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -0800935 /**
936 * This string column is the MIME type of the attachment.
937 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800938 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -0800939 /**
940 * This integer column is the current downloading state of the
941 * attachment as defined in {@link AttachmentState}.
942 * <p>
943 * Providers must accept updates to {@link URI} with new values of
944 * this column to initiate or cancel downloads.
945 */
946 public static final String STATE = "state";
947 /**
948 * This integer column is the file destination for the current download
949 * in progress (when {@link #STATE} is
950 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
951 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
952 * in {@link AttachmentDestination}. This value is undefined in any
953 * other state.
954 * <p>
955 * Providers must accept updates to {@link URI} with new values of
956 * this column to move an existing downloaded file.
957 */
958 public static final String DESTINATION = "destination";
959 /**
960 * This integer column is the current number of bytes downloaded when
961 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
962 * undefined in any other state.
963 */
964 public static final String DOWNLOADED_SIZE = "downloadedSize";
965 /**
966 * This column is a {@link Uri} that points to the downloaded local file
967 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
968 * undefined in any other state.
969 */
970 public static final String CONTENT_URI = "contentUri";
971 /**
972 * This column is a {@link Uri} that points to a local thumbnail file
973 * for the attachment. Providers that do not support downloading
974 * attachment thumbnails may leave this null.
975 */
976 public static final String THUMBNAIL_URI = "thumbnailUri";
977 /**
978 * This column is an {@link Intent} to launch a preview activity that
979 * allows the user to efficiently view an attachment without having to
980 * first download the entire file. Providers that do not support
981 * previewing attachments may leave this null. The intent is represented
982 * as a byte-array blob generated by writing an Intent to a parcel and
983 * then marshaling that parcel.
984 */
985 public static final String PREVIEW_INTENT = "previewIntent";
986
987 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800988 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800989
990 public static int getMailMaxAttachmentSize(String account) {
991 // TODO: query the account to see what the max attachment size is?
992 return 5 * 1024 * 1024;
993 }
994
995 public static String getAttachmentTypeSetting() {
996 // TODO: query the account to see what kinds of attachments it supports?
997 return "com.google.android.gm.allowAddAnyAttachment";
998 }
Mindy Pereira82cc5662012-01-09 17:29:30 -0800999
1000 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1001 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1002 ArrayList<String> recipients = new ArrayList<String>();
1003 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1004 for (String address : addresses) {
1005 recipients.add(address);
1006 }
1007 statsUpdater.updateWithAddress(recipients);
1008 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001009
1010 public static final String[] UNDO_PROJECTION = {
1011 ConversationColumns.MESSAGE_LIST_URI
1012 };
1013 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001014
1015 // Parameter used to indicate the sequence number for an undoable operation
1016 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001017
1018
1019 public static final String[] SETTINGS_PROJECTION = {
1020 SettingsColumns.SIGNATURE,
1021 SettingsColumns.AUTO_ADVANCE,
1022 SettingsColumns.MESSAGE_TEXT_SIZE,
1023 SettingsColumns.SNAP_HEADERS,
1024 SettingsColumns.REPLY_BEHAVIOR,
1025 SettingsColumns.HIDE_CHECKBOXES,
1026 SettingsColumns.CONFIRM_DELETE,
1027 SettingsColumns.CONFIRM_ARCHIVE,
1028 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -08001029 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -08001030 };
1031
Mindy Pereira8bd82152012-03-01 10:06:35 -08001032 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
1033 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
1034 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
1035 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
1036 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
1037 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
1038 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
1039 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
1040 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
1041 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
1042
Paul Westbrook63eef792012-02-27 14:01:06 -08001043 public static final class AutoAdvance {
1044 public static final int UNSET = 0;
1045 public static final int OLDER = 1;
1046 public static final int NEWER = 2;
1047 public static final int LIST = 3;
1048 }
1049
1050 public static final class SnapHeaderValue {
1051 public static final int ALWAYS = 0;
1052 public static final int PORTRAIT_ONLY = 1;
1053 public static final int NEVER = 2;
1054 }
1055
1056 public static final class MessageTextSize {
1057 public static final int TINY = -2;
1058 public static final int SMALL = -1;
1059 public static final int NORMAL = 0;
1060 public static final int LARGE = 1;
1061 public static final int HUGE = 2;
1062 }
1063
1064 public static final class DefaultReplyBehavior {
1065 public static final int REPLY = 0;
1066 public static final int REPLY_ALL = 1;
1067 }
1068
1069 public static final class SettingsColumns {
1070 /**
1071 * String column containing the contents of the signature for this account. If no
1072 * signature has been specified, the value will be null.
1073 */
1074 public static final String SIGNATURE = "signature";
1075
1076 /**
1077 * Integer column containing the user's specified auto-advance policy. This value will be
1078 * one of the values in {@link UIProvider.AutoAdvance}
1079 */
1080 public static final String AUTO_ADVANCE = "auto_advance";
1081
1082 /**
1083 * Integer column containing the user's specified message text size preference. This value
1084 * will be one of the values in {@link UIProvider.MessageTextSize}
1085 */
1086 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
1087
1088 /**
1089 * Integer column contaning the user's specified snap header preference. This value
1090 * will be one of the values in {@link UIProvider.SnapHeaderValue}
1091 */
1092 public static final String SNAP_HEADERS = "snap_headers";
1093
1094 /**
1095 * Integer column containing the user's specified default reply behavior. This value will
1096 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
1097 */
1098 public static final String REPLY_BEHAVIOR = "reply_behavior";
1099
1100 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -08001101 * Integer column containing the user's specified checkbox preference. A
1102 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -08001103 */
1104 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
1105
1106 /**
1107 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001108 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001109 * be shown when a delete action is performed.
1110 */
1111 public static final String CONFIRM_DELETE = "confirm_delete";
1112
1113 /**
1114 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001115 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001116 * be shown when an archive action is performed.
1117 */
1118 public static final String CONFIRM_ARCHIVE = "confirm_archive";
1119
1120 /**
1121 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -08001122 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -08001123 * be shown when a send action is performed.
1124 */
1125 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -08001126 /**
1127 * String folder containing the serialized default inbox folder for an account.
1128 */
1129 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001130 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001131}