blob: 2aab5f476ee509b00fce581eb9977843106933d3 [file] [log] [blame]
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08001/*******************************************************************************
2 * Copyright (C) 2011 Google Inc.
3 * Licensed to The Android Open Source Project.
Mindy Pereira6f92de62011-12-19 11:31:48 -08004 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Mindy Pereira6f92de62011-12-19 11:31:48 -08008 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08009 * http://www.apache.org/licenses/LICENSE-2.0
Mindy Pereira6f92de62011-12-19 11:31:48 -080010 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -080011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
Mindy Pereira6f92de62011-12-19 11:31:48 -080017
Andy Huang30e2c242012-01-06 18:14:30 -080018package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080019
Paul Westbrook334e64a2012-02-23 13:26:35 -080020import android.content.ContentProvider;
21import android.content.ContentValues;
Mindy Pereira82cc5662012-01-09 17:29:30 -080022import android.content.Context;
Mindy Pereira6f92de62011-12-19 11:31:48 -080023import android.provider.BaseColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080024import android.text.TextUtils;
Paul Westbrook334e64a2012-02-23 13:26:35 -080025import android.net.Uri;
Mindy Pereira82cc5662012-01-09 17:29:30 -080026
27import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080028
Paul Westbrook334e64a2012-02-23 13:26:35 -080029import java.lang.String;
Mindy Pereira82cc5662012-01-09 17:29:30 -080030import java.util.ArrayList;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080031
Mindy Pereira6f92de62011-12-19 11:31:48 -080032public class UIProvider {
Mindy Pereira82cc5662012-01-09 17:29:30 -080033 public static final String EMAIL_SEPARATOR = "\n";
Mindy Pereira326c6602012-01-04 15:32:42 -080034 public static final long INVALID_CONVERSATION_ID = -1;
35 public static final long INVALID_MESSAGE_ID = -1;
36
Marc Blank9ace18a2012-02-21 16:34:07 -080037 /**
38 * Values for the current state of a Folder/Account; note that it's possible that more than one
39 * sync is in progress
40 */
41 public static final class SyncStatus {
42 // No sync in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080043 public static final int NO_SYNC = 0;
Marc Blank9ace18a2012-02-21 16:34:07 -080044 // A user-requested sync/refresh is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080045 public static final int USER_REFRESH = 1<<0;
Marc Blank9ace18a2012-02-21 16:34:07 -080046 // A user-requested query is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080047 public static final int USER_QUERY = 1<<1;
Marc Blank9ace18a2012-02-21 16:34:07 -080048 // A user request for additional results is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080049 public static final int USER_MORE_RESULTS = 1<<2;
Marc Blank9ace18a2012-02-21 16:34:07 -080050 // A background sync is in progress
Paul Westbrookc808fac2012-02-22 16:42:18 -080051 public static final int BACKGROUND_SYNC = 1<<3;
Marc Blank9ace18a2012-02-21 16:34:07 -080052 }
53
54 /**
55 * Values for the result of the last attempted sync of a Folder/Account
56 */
57 public static final class LastSyncResult {
58 // The sync completed successfully
59 public static final int SUCCESS = 0;
60 // The sync wasn't completed due to a connection error
61 public static final int CONNECTION_ERROR = 1;
62 // The sync wasn't completed due to an authentication error
63 public static final int AUTH_ERROR = 2;
64 // The sync wasn't completed due to a security error
65 public static final int SECURITY_ERROR = 3;
66 // The sync wasn't completed due to a low memory condition
67 public static final int STORAGE_ERROR = 4;
68 // The sync wasn't completed due to an internal error/exception
69 public static final int INTERNAL_ERROR = 5;
70 }
71
Paul Westbrook82ea6da2011-12-15 11:03:51 -080072 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -080073 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080074
75 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080076 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080077 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080078 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080079
80 public static final String[] ACCOUNTS_PROJECTION = {
81 BaseColumns._ID,
82 AccountColumns.NAME,
83 AccountColumns.PROVIDER_VERSION,
84 AccountColumns.URI,
85 AccountColumns.CAPABILITIES,
86 AccountColumns.FOLDER_LIST_URI,
87 AccountColumns.SEARCH_URI,
88 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Mindy Pereira33fe9082012-01-09 16:24:30 -080089 AccountColumns.SAVE_DRAFT_URI,
Mindy Pereira7ed1c112012-01-18 10:59:25 -080090 AccountColumns.SEND_MAIL_URI,
Mindy Pereira96b5c352012-02-01 11:33:40 -080091 AccountColumns.EXPUNGE_MESSAGE_URI,
Mindy Pereira9600dac2012-02-17 15:59:25 -080092 AccountColumns.UNDO_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -080093 AccountColumns.SETTINGS_INTENT_URI,
Paul Westbrook63eef792012-02-27 14:01:06 -080094 AccountColumns.SETTINGS_QUERY_URI,
Paul Westbrook94e440d2012-02-24 11:03:47 -080095 AccountColumns.SYNC_STATUS,
Mindy Pereira23755e22012-02-27 13:58:04 -080096 AccountColumns.HELP_INTENT_URI,
Mindy Pereira898cd382012-03-06 08:42:47 -080097 AccountColumns.COMPOSE_URI,
98 AccountColumns.MIME_TYPE
Mindy Pereira6f92de62011-12-19 11:31:48 -080099 };
100
Mindy Pereira33fe9082012-01-09 16:24:30 -0800101 public static final int ACCOUNT_ID_COLUMN = 0;
102 public static final int ACCOUNT_NAME_COLUMN = 1;
103 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
104 public static final int ACCOUNT_URI_COLUMN = 3;
105 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
106 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
107 public static final int ACCOUNT_SEARCH_URI_COLUMN = 6;
108 public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7;
109 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8;
110 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9;
Mindy Pereira82cc5662012-01-09 17:29:30 -0800111 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10;
Mindy Pereira96b5c352012-02-01 11:33:40 -0800112 public static final int ACCOUNT_UNDO_URI_COLUMN = 11;
Marc Blank9ace18a2012-02-21 16:34:07 -0800113 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12;
Paul Westbrook63eef792012-02-27 14:01:06 -0800114 public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13;
115 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
116 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
117 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16;
Mindy Pereira898cd382012-03-06 08:42:47 -0800118 public static final int ACCOUNT_MIME_TYPE_COLUMN = 17;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800119
Mindy Pereira6f92de62011-12-19 11:31:48 -0800120 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800121 /**
122 * Whether folders can be synchronized back to the server.
123 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800124 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800125 /**
126 * Whether the server allows reporting spam back.
127 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800128 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800129 /**
130 * Whether the server supports a concept of Archive: removing mail from the Inbox but
131 * keeping it around.
132 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800133 public static final int ARCHIVE = 0x0004;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800134 /**
135 * Whether the server will stop notifying on updates to this thread? This requires
136 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
137 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800138 public static final int MUTE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800139 /**
140 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
141 * to be true, otherwise it should be ignored.
142 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800143 public static final int SERVER_SEARCH = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800144 /**
145 * Whether the server supports constraining search to a single folder. Requires
146 * SYNCABLE_FOLDERS, otherwise it should be ignored.
147 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800148 public static final int FOLDER_SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800149 /**
150 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
151 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800152 public static final int SANITIZED_HTML = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800153 /**
154 * Whether the server allows synchronization of draft messages. This does NOT require
155 * SYNCABLE_FOLDERS to be set.
156 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800157 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800158 /**
159 * Does the server allow the user to compose mails (and reply) using addresses other than
160 * their account name? For instance, GMail allows users to set FROM addresses that are
161 * different from account@gmail.com address. For instance, user@gmail.com could have another
162 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
163 * can compose (and reply) using either address.
164 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800165 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800166 /**
167 * Whether the server allows the original message to be included in the reply by setting a
168 * flag on the reply. If we can avoid including the entire previous message, we save on
169 * bandwidth (replies are shorter).
170 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800171 public static final int SMART_REPLY = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800172 /**
173 * Does this account support searching locally, on the device? This requires the backend
174 * storage to support a mechanism for searching.
175 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800176 public static final int LOCAL_SEARCH = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800177 /**
178 * Whether the server supports a notion of threaded conversations: where replies to messages
179 * are tagged to keep conversations grouped. This could be full threading (each message
180 * lists its parent) or conversation-level threading (each message lists one conversation
181 * which it belongs to)
182 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800183 public static final int THREADED_CONVERSATIONS = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800184 /**
185 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
186 * multiple labels on a single conversation, since labels and folders are interchangeable
187 * in this application.)
188 */
Mindy Pereira84648892012-02-03 08:29:55 -0800189 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800190 /**
191 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
192 */
193 public static final int UNDO = 0x2000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800194 /**
195 * Whether the account provides help content.
196 */
197 public static final int HELP_CONTENT = 0x4000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800198 /**
199 * Whether the account provides a mechanism for marking conversations as important.
200 */
201 public static final int MARK_IMPORTANT = 0x8000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800202 }
203
204 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800205 /**
206 * This string column contains the human visible name for the account.
207 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800208 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800209
210 /**
211 * This integer column returns the version of the UI provider schema from which this
212 * account provider will return results.
213 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800214 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800215
216 /**
217 * This string column contains the uri to directly access the information for this account.
218 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800219 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800220
221 /**
222 * This integer column contains a bit field of the possible cabibilities that this account
223 * supports.
224 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800225 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800226
227 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800228 * This string column contains the content provider uri to return the
229 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800230 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800231 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800232
233 /**
234 * This string column contains the content provider uri that can be queried for search
235 * results.
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800236 * The supported query parameters are limited to those listed
237 * in {@link #SearchQueryParameters}
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800238 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800239 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800240
241 /**
242 * This string column contains the content provider uri that can be queried to access the
243 * from addresses for this account.
244 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800245 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800246
247 /**
248 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800249 * new draft messages for this account. NOTE: This might be better to
250 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800251 */
Mindy Pereira33fe9082012-01-09 16:24:30 -0800252 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800253
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800254 /**
255 * This string column contains the content provider uri that can be used to send
256 * a message for this account.
257 * NOTE: This might be better to be an update operation on the messageUri.
258 */
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800259 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800260
261 /**
262 * This string column contains the content provider uri that can be used
263 * to expunge a message from this account. NOTE: This might be better to
264 * be an update operation on the messageUri.
265 */
266 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800267
268 /**
269 * This string column contains the content provider uri that can be used
270 * to undo the last committed action.
271 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800272 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800273
274 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800275 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800276 * shown.
277 * TODO: When we want to support a heterogeneous set of account types, this value may need
278 * to be moved to a global content provider.
279 */
280 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800281
282 /**
Paul Westbrook63eef792012-02-27 14:01:06 -0800283 * This string column contains the content provider uri that can be used to query user
284 * settings/preferences.
285 *
286 * The cursor returned by this query support columnms declared in {@link #SettingsColumns}
287 */
288 public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri";
289
290 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800291 * Uri for VIEW intent that will cause the help screens for this account type to be
292 * shown.
293 * TODO: When we want to support a heterogeneous set of account types, this value may need
294 * to be moved to a global content provider.
295 */
296 public static String HELP_INTENT_URI = "helpIntentUri";
297
298 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800299 * This int column contains the current sync status of the account (the logical AND of the
300 * sync status of folders in this account)
301 */
302 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800303 /**
304 * Uri for VIEW intent that will cause the compose screens for this type
305 * of account to be shown.
306 */
307 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800308 /**
309 * Mime-type defining this account.
310 */
311 public static final String MIME_TYPE = "mimeType";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800312 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800313
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800314 public static final class SearchQueryParameters {
315 /**
316 * Parameter used to specify the search query.
317 */
318 public static final String QUERY = "query";
319
320 /**
321 * If specified, the query results will be limited to this folder.
322 */
323 public static final String FOLDER = "folder";
324
325 private SearchQueryParameters() {}
326 }
327
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800328 // We define a "folder" as anything that contains a list of conversations.
329 public static final String FOLDER_LIST_TYPE =
330 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
331 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800332 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800333
334 public static final String[] FOLDERS_PROJECTION = {
335 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800336 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800337 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800338 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800339 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800340 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800341 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800342 FolderColumns.CHILD_FOLDERS_LIST_URI,
343 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800344 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800345 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800346 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800347 FolderColumns.LAST_SYNC_RESULT,
348 FolderColumns.TYPE,
349 FolderColumns.ICON_RES_ID
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800350 };
351
Mindy Pereira818143e2012-01-11 13:59:49 -0800352 public static final int FOLDER_ID_COLUMN = 0;
353 public static final int FOLDER_URI_COLUMN = 1;
354 public static final int FOLDER_NAME_COLUMN = 2;
355 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
356 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
Mindy Pereira621b4bd2012-02-23 13:48:50 -0800357 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
358 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
359 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
360 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
361 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
362 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
363 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
364 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
Mindy Pereira78664722012-03-05 13:53:07 -0800365 public static final int FOLDER_TYPE_COLUMN = 13;
366 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
367
368 public static final class FolderType {
369 public static final int DEFAULT = 0;
370 public static final int INBOX = 1;
371 public static final int DRAFT = 2;
372 public static final int OUTBOX = 3;
373 public static final int SENT = 4;
374 public static final int TRASH = 5;
375 public static final int SPAM = 6;
376 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800377
Mindy Pereira0973b202011-12-21 15:48:12 -0800378 public static final class FolderCapabilities {
379 public static final int SYNCABLE = 0x0001;
380 public static final int PARENT = 0x0002;
381 public static final int CAN_HOLD_MAIL = 0x0004;
382 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800383 /**
384 * For accounts that support archive, this will indicate that this folder supports
385 * the archive functionality.
386 */
387 public static final int ARCHIVE = 0x0010;
388
389 /**
390 * For accounts that support report spam, this will indicate that this folder supports
391 * the report spam functionality.
392 */
393 public static final int REPORT_SPAM = 0x0020;
394
395 /**
396 * For accounts that support mute, this will indicate if a mute is performed from within
397 * this folder, the action is destructive.
398 */
399 public static final int DESTRUCTIVE_MUTE = 0x0040;
Mindy Pereira0973b202011-12-21 15:48:12 -0800400 }
401
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800402 public static final class FolderColumns {
Mindy Pereira77528642012-02-17 15:51:10 -0800403 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800404 /**
405 * This string column contains the human visible name for the folder.
406 */
407 public static final String NAME = "name";
408 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800409 * This int column represents the capabilities of the folder specified by
410 * FolderCapabilities flags.
411 */
412 public static String CAPABILITIES = "capabilities";
413 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800414 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800415 * child folders.
416 */
417 public static String HAS_CHILDREN = "hasChildren";
418 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800419 * This int column represents how large the sync window is.
420 */
421 public static String SYNC_WINDOW = "syncWindow";
422 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800423 * This string column contains the content provider uri to return the
424 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800425 */
426 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800427 /**
428 * This string column contains the content provider uri to return the
429 * list of child folders of this folder.
430 */
Mindy Pereira77528642012-02-17 15:51:10 -0800431 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800432
Mindy Pereira77528642012-02-17 15:51:10 -0800433 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800434
Mindy Pereira77528642012-02-17 15:51:10 -0800435 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800436 /**
437 * This string column contains the content provider uri to force a
438 * refresh of this folder.
439 */
Mindy Pereira77528642012-02-17 15:51:10 -0800440 public static final String REFRESH_URI = "refreshUri";
441 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800442 * This int column contains current sync status of the folder; some combination of the
443 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800444 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800445 public static final String SYNC_STATUS = "syncStatus";
446 /**
447 * This int column contains the sync status of the last sync attempt; one of the
448 * LastSyncStatus values defined above
449 */
450 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800451 /**
452 * This long column contains the icon res id for this folder, or 0 if there is none.
453 */
454 public static final String ICON_RES_ID = "iconResId";
455 /**
456 * This int column contains the type of the folder. Zero is default.
457 */
458 public static final String TYPE = "type";
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800459 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800460 }
461
Mindy Pereiraa1406072011-12-22 10:54:06 -0800462 // We define a "folder" as anything that contains a list of conversations.
463 public static final String CONVERSATION_LIST_TYPE =
464 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
465 public static final String CONVERSATION_TYPE =
466 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
467
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800468
Mindy Pereiraa1406072011-12-22 10:54:06 -0800469 public static final String[] CONVERSATION_PROJECTION = {
470 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800471 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800472 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800473 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800474 ConversationColumns.SNIPPET,
475 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800476 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800477 ConversationColumns.HAS_ATTACHMENTS,
478 ConversationColumns.NUM_MESSAGES,
479 ConversationColumns.NUM_DRAFTS,
480 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800481 ConversationColumns.PRIORITY,
482 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800483 ConversationColumns.STARRED,
484 ConversationColumns.FOLDER_LIST
Mindy Pereiraa1406072011-12-22 10:54:06 -0800485 };
486
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800487 // These column indexes only work when the caller uses the
488 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800489 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800490 public static final int CONVERSATION_URI_COLUMN = 1;
491 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
492 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
493 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
494 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
495 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
496 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800497 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
498 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
499 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
500 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -0800501 public static final int CONVERSATION_READ_COLUMN = 12;
502 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800503 public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800504
505 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -0800506 public static final int OTHER = 0;
507 public static final int SENDING = 1;
508 public static final int SENT = 2;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800509 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800510 }
Mindy Pereira4db59c52012-01-12 09:45:13 -0800511
512 public static final class ConversationPriority {
513 public static final int LOW = 0;
514 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800515 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800516
Marc Blankc8a99422012-01-19 14:27:47 -0800517 public static final class ConversationFlags {
518 public static final int READ = 1<<0;
519 public static final int STARRED = 1<<1;
520 public static final int REPLIED = 1<<2;
521 public static final int FORWARDED = 1<<3;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800522 }
Marc Blankc8a99422012-01-19 14:27:47 -0800523
Mindy Pereiraa1406072011-12-22 10:54:06 -0800524 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800525 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800526 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800527 * This string column contains the content provider uri to return the
528 * list of messages for this conversation.
529 */
530 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800531 /**
532 * This string column contains the subject string for a conversation.
533 */
534 public static final String SUBJECT = "subject";
535 /**
536 * This string column contains the snippet string for a conversation.
537 */
538 public static final String SNIPPET = "snippet";
539 /**
540 * This string column contains the sender info string for a
541 * conversation.
542 */
543 public static final String SENDER_INFO = "senderInfo";
544 /**
545 * This long column contains the time in ms of the latest update to a
546 * conversation.
547 */
548 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
549
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800550 /**
551 * This boolean column contains whether any messages in this conversation
552 * have attachments.
553 */
554 public static final String HAS_ATTACHMENTS = "hasAttachments";
555
Mindy Pereira4db59c52012-01-12 09:45:13 -0800556 /**
557 * This int column contains the number of messages in this conversation.
558 * For unthreaded, this will always be 1.
559 */
560 public static String NUM_MESSAGES = "numMessages";
561
562 /**
563 * This int column contains the number of drafts associated with this
564 * conversation.
565 */
566 public static String NUM_DRAFTS = "numDrafts";
567
568 /**
569 * This int column contains the state of drafts and replies associated
570 * with this conversation. Use ConversationSendingState to interpret
571 * this field.
572 */
573 public static String SENDING_STATE = "sendingState";
574
575 /**
576 * This int column contains the priority of this conversation. Use
577 * ConversationPriority to interpret this field.
578 */
579 public static String PRIORITY = "priority";
580
Marc Blankc8a99422012-01-19 14:27:47 -0800581 /**
582 * This boolean column indicates whether the conversation has been read
583 */
584 public static String READ = "read";
585
586 /**
587 * This boolean column indicates whether the conversation has been read
588 */
589 public static String STARRED = "starred";
590
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800591 /**
592 * This string column contains a csv of all folders associated with this
593 * conversation
594 */
595 public static final String FOLDER_LIST = "folderList";
596
Paul Westbrook334e64a2012-02-23 13:26:35 -0800597 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -0800598 }
Mindy Pereiraa1406072011-12-22 10:54:06 -0800599 }
600
Mindy Pereira6f92de62011-12-19 11:31:48 -0800601 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800602 * List of operations that can can be performed on a conversation. These operations are applied
603 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
604 * where the conversation uri is specified, and the ContentValues specifies the operation to
605 * be performed.
606 * <p/>
607 * The operation to be performed is specified in the ContentValues by
608 * the {@link ConversationOperations#OPERATION_KEY}
609 * <p/>
610 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
611 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -0800612 */
Paul Westbrook334e64a2012-02-23 13:26:35 -0800613 public static final class ConversationOperations {
614 /**
615 * ContentValues key used to specify the operation to be performed
616 */
617 public static final String OPERATION_KEY = "operation";
618
619 /**
620 * Archive operation
621 */
622 public static final String ARCHIVE = "archive";
623
624 /**
625 * Mute operation
626 */
627 public static final String MUTE = "mute";
628
629 /**
630 * Report spam operation
631 */
632 public static final String REPORT_SPAM = "report_spam";
633
634 private ConversationOperations() {
635 }
636 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800637
638 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -0800639 public static final int NOT_A_DRAFT = 0;
640 public static final int COMPOSE = 1;
641 public static final int REPLY = 2;
642 public static final int REPLY_ALL = 3;
643 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800644
645 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800646 }
647
Mindy Pereiraa1406072011-12-22 10:54:06 -0800648 public static final String[] MESSAGE_PROJECTION = {
649 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800650 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800651 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800652 MessageColumns.CONVERSATION_ID,
653 MessageColumns.SUBJECT,
654 MessageColumns.SNIPPET,
655 MessageColumns.FROM,
656 MessageColumns.TO,
657 MessageColumns.CC,
658 MessageColumns.BCC,
659 MessageColumns.REPLY_TO,
660 MessageColumns.DATE_RECEIVED_MS,
661 MessageColumns.BODY_HTML,
662 MessageColumns.BODY_TEXT,
663 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
664 MessageColumns.REF_MESSAGE_ID,
665 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800666 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800667 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800668 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -0800669 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800670 MessageColumns.JOINED_ATTACHMENT_INFOS,
671 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -0800672 MessageColumns.SEND_MESSAGE_URI,
673 MessageColumns.ALWAYS_SHOW_IMAGES
Mindy Pereiraa1406072011-12-22 10:54:06 -0800674 };
675
Mindy Pereiraf944e962012-01-17 11:43:36 -0800676 /** Separates attachment info parts in strings in a message. */
677 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800678 public static final String MESSAGE_LIST_TYPE =
679 "vnd.android.cursor.dir/vnd.com.android.mail.message";
680 public static final String MESSAGE_TYPE =
681 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800682
Mindy Pereira6349a042012-01-04 11:25:01 -0800683 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800684 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
685 public static final int MESSAGE_URI_COLUMN = 2;
686 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
687 public static final int MESSAGE_SUBJECT_COLUMN = 4;
688 public static final int MESSAGE_SNIPPET_COLUMN = 5;
689 public static final int MESSAGE_FROM_COLUMN = 6;
690 public static final int MESSAGE_TO_COLUMN = 7;
691 public static final int MESSAGE_CC_COLUMN = 8;
692 public static final int MESSAGE_BCC_COLUMN = 9;
693 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
694 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -0800695 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
696 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -0800697 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
698 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
699 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800700 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
701 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
702 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
703 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800704 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800705 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
706 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Paul Westbrook104f7292012-02-28 16:07:07 -0800707 public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24;
Mindy Pereira6349a042012-01-04 11:25:01 -0800708
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800709 public static final class MessageFlags {
Andy Huangdb977472012-01-11 19:53:25 -0800710 public static final int STARRED = 1 << 0;
711 public static final int UNREAD = 1 << 1;
712 public static final int REPLIED = 1 << 2;
713 public static final int FORWARDED = 1 << 3;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800714 }
715
Mindy Pereira6f92de62011-12-19 11:31:48 -0800716 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -0800717 /**
718 * This string column contains a content provider URI that points to this single message.
719 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800720 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -0800721 /**
722 * This string column contains a server-assigned ID for this message.
723 */
724 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800725 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -0800726 /**
727 * This string column contains the subject of a message.
728 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800729 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -0800730 /**
731 * This string column contains a snippet of the message body.
732 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800733 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -0800734 /**
735 * This string column contains the single email address (and optionally name) of the sender.
736 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800737 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800738 /**
739 * This string column contains a comma-delimited list of "To:" recipient email addresses.
740 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800741 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800742 /**
743 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
744 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800745 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800746 /**
747 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
748 * This value will be null for incoming messages.
749 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800750 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -0800751 /**
752 * This string column contains the single email address (and optionally name) of the
753 * sender's reply-to address.
754 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800755 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -0800756 /**
757 * This long column contains the timestamp (in millis) of receipt of the message.
758 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800759 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -0800760 /**
761 * This string column contains the HTML form of the message body, if available. If not,
762 * a provider must populate BODY_TEXT.
763 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800764 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -0800765 /**
766 * This string column contains the plaintext form of the message body, if HTML is not
767 * otherwise available. If HTML is available, this value should be left empty (null).
768 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800769 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800770 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800771 /**
772 * This string column contains an opaque string used by the sendMessage api.
773 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800774 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -0800775 /**
Andy Huang97c25be2012-01-12 15:12:09 -0800776 * This integer column contains the type of this draft, or zero (0) if this message is not a
777 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -0800778 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800779 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -0800780 /**
781 * This boolean column indicates whether an outgoing message should trigger special quoted
782 * text processing upon send. The value should default to zero (0) for protocols that do
783 * not support or require this flag, and for all incoming messages.
784 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -0800785 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -0800786 /**
787 * This boolean column indicates whether a message has attachments. The list of attachments
788 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
789 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800790 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -0800791 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800792 * This string column contains the content provider URI for the list of
793 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -0800794 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800795 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -0800796 /**
797 * This long column is a bit field of flags defined in {@link MessageFlags}.
798 */
Andy Huang732600e2012-01-10 17:47:17 -0800799 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -0800800 /**
801 * This string column contains a specially formatted string representing all
802 * attachments that we added to a message that is being sent or saved.
803 */
Mindy Pereira84554ec2012-01-17 14:44:44 -0800804 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800805 /**
806 * This string column contains the content provider URI for saving this
807 * message.
808 */
809 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
810 /**
811 * This string column contains content provider URI for sending this
812 * message.
813 */
814 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800815
Paul Westbrook104f7292012-02-28 16:07:07 -0800816 /**
817 * This integer column represents whether the user has specified that images should always
818 * be shown. The value of "1" indicates that the user has specified that images should be
819 * shown, while the value of "0" indicates that the user should be prompted before loading
820 * any external images.
821 */
822 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
823
Mindy Pereira6f92de62011-12-19 11:31:48 -0800824 private MessageColumns() {}
825 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800826
827 // We define a "folder" as anything that contains a list of conversations.
828 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 = {
834 BaseColumns._ID,
835 AttachmentColumns.NAME,
836 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800837 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800838 AttachmentColumns.ORIGIN_EXTRAS,
839 AttachmentColumns.CONTENT_TYPE,
840 AttachmentColumns.SYNCED
841 };
Mindy Pereira82cc5662012-01-09 17:29:30 -0800842 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800843 public static final int ATTACHMENT_ID_COLUMN = 0;
844 public static final int ATTACHMENT_NAME_COLUMN = 1;
845 public static final int ATTACHMENT_SIZE_COLUMN = 2;
846 public static final int ATTACHMENT_URI_COLUMN = 3;
Mindy Pereiraf944e962012-01-17 11:43:36 -0800847 public static final int ATTACHMENT_ORIGIN_EXTRAS_COLUMN = 4;
848 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 5;
849 public static final int ATTACHMENT_SYNCED_COLUMN = 6;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800850
851 public static final class AttachmentColumns {
852 public static final String NAME = "name";
853 public static final String SIZE = "size";
Mindy Pereira7a07fb42012-01-11 10:32:48 -0800854 public static final String URI = "uri";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800855 public static final String ORIGIN_EXTRAS = "originExtras";
856 public static final String CONTENT_TYPE = "contentType";
857 public static final String SYNCED = "synced";
858 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800859
860 public static int getMailMaxAttachmentSize(String account) {
861 // TODO: query the account to see what the max attachment size is?
862 return 5 * 1024 * 1024;
863 }
864
865 public static String getAttachmentTypeSetting() {
866 // TODO: query the account to see what kinds of attachments it supports?
867 return "com.google.android.gm.allowAddAnyAttachment";
868 }
Mindy Pereira82cc5662012-01-09 17:29:30 -0800869
870 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
871 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
872 ArrayList<String> recipients = new ArrayList<String>();
873 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
874 for (String address : addresses) {
875 recipients.add(address);
876 }
877 statsUpdater.updateWithAddress(recipients);
878 }
Marc Blankb31ab5a2012-02-01 12:28:29 -0800879
880 public static final String[] UNDO_PROJECTION = {
881 ConversationColumns.MESSAGE_LIST_URI
882 };
883 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -0800884
885 // Parameter used to indicate the sequence number for an undoable operation
886 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -0800887
888
889 public static final String[] SETTINGS_PROJECTION = {
890 SettingsColumns.SIGNATURE,
891 SettingsColumns.AUTO_ADVANCE,
892 SettingsColumns.MESSAGE_TEXT_SIZE,
893 SettingsColumns.SNAP_HEADERS,
894 SettingsColumns.REPLY_BEHAVIOR,
895 SettingsColumns.HIDE_CHECKBOXES,
896 SettingsColumns.CONFIRM_DELETE,
897 SettingsColumns.CONFIRM_ARCHIVE,
898 SettingsColumns.CONFIRM_SEND,
Mindy Pereira9783a742012-03-01 09:13:07 -0800899 SettingsColumns.DEFAULT_INBOX
Paul Westbrook63eef792012-02-27 14:01:06 -0800900 };
901
Mindy Pereira8bd82152012-03-01 10:06:35 -0800902 public static final int SETTINGS_SIGNATURE_COLUMN = 0;
903 public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
904 public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
905 public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
906 public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
907 public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
908 public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
909 public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
910 public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
911 public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
912
Paul Westbrook63eef792012-02-27 14:01:06 -0800913 public static final class AutoAdvance {
914 public static final int UNSET = 0;
915 public static final int OLDER = 1;
916 public static final int NEWER = 2;
917 public static final int LIST = 3;
918 }
919
920 public static final class SnapHeaderValue {
921 public static final int ALWAYS = 0;
922 public static final int PORTRAIT_ONLY = 1;
923 public static final int NEVER = 2;
924 }
925
926 public static final class MessageTextSize {
927 public static final int TINY = -2;
928 public static final int SMALL = -1;
929 public static final int NORMAL = 0;
930 public static final int LARGE = 1;
931 public static final int HUGE = 2;
932 }
933
934 public static final class DefaultReplyBehavior {
935 public static final int REPLY = 0;
936 public static final int REPLY_ALL = 1;
937 }
938
939 public static final class SettingsColumns {
940 /**
941 * String column containing the contents of the signature for this account. If no
942 * signature has been specified, the value will be null.
943 */
944 public static final String SIGNATURE = "signature";
945
946 /**
947 * Integer column containing the user's specified auto-advance policy. This value will be
948 * one of the values in {@link UIProvider.AutoAdvance}
949 */
950 public static final String AUTO_ADVANCE = "auto_advance";
951
952 /**
953 * Integer column containing the user's specified message text size preference. This value
954 * will be one of the values in {@link UIProvider.MessageTextSize}
955 */
956 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
957
958 /**
959 * Integer column contaning the user's specified snap header preference. This value
960 * will be one of the values in {@link UIProvider.SnapHeaderValue}
961 */
962 public static final String SNAP_HEADERS = "snap_headers";
963
964 /**
965 * Integer column containing the user's specified default reply behavior. This value will
966 * be one of the values in {@link UIProvider.DefaultReplyBehavior}
967 */
968 public static final String REPLY_BEHAVIOR = "reply_behavior";
969
970 /**
Mindy Pereira8bd82152012-03-01 10:06:35 -0800971 * Integer column containing the user's specified checkbox preference. A
972 * non zero value means to hide checkboxes.
Paul Westbrook63eef792012-02-27 14:01:06 -0800973 */
974 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
975
976 /**
977 * Integer column containing the user's specified confirm delete preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800978 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800979 * be shown when a delete action is performed.
980 */
981 public static final String CONFIRM_DELETE = "confirm_delete";
982
983 /**
984 * Integer column containing the user's specified confirm archive preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800985 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800986 * be shown when an archive action is performed.
987 */
988 public static final String CONFIRM_ARCHIVE = "confirm_archive";
989
990 /**
991 * Integer column containing the user's specified confirm send preference value.
Mindy Pereira8bd82152012-03-01 10:06:35 -0800992 * A non zero value indicates that the user has indicated that a confirmation should
Paul Westbrook63eef792012-02-27 14:01:06 -0800993 * be shown when a send action is performed.
994 */
995 public static final String CONFIRM_SEND = "confirm_send";
Mindy Pereira9783a742012-03-01 09:13:07 -0800996 /**
997 * String folder containing the serialized default inbox folder for an account.
998 */
999 public static final String DEFAULT_INBOX = "default_inbox";
Paul Westbrook63eef792012-02-27 14:01:06 -08001000 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001001}