UIProvider.java revision 4880b5dea0335c887e6e6e5535365c3a313b96b7
1/*******************************************************************************
2 *      Copyright (C) 2011 Google Inc.
3 *      Licensed to The Android Open Source Project.
4 *
5 *      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
8 *
9 *           http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *      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 *******************************************************************************/
17
18package com.android.mail.providers;
19
20import android.content.ContentProvider;
21import android.content.ContentValues;
22import android.content.Context;
23import android.content.Intent;
24import android.net.Uri;
25import android.provider.BaseColumns;
26import android.provider.OpenableColumns;
27import android.text.TextUtils;
28
29import com.android.common.contacts.DataUsageStatUpdater;
30
31import java.util.ArrayList;
32
33public class UIProvider {
34    public static final String EMAIL_SEPARATOR = ",";
35    public static final long INVALID_CONVERSATION_ID = -1;
36    public static final long INVALID_MESSAGE_ID = -1;
37
38    /**
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
44        public static final int NO_SYNC = 0;
45        // A user-requested sync/refresh is in progress
46        public static final int USER_REFRESH = 1<<0;
47        // A user-requested query is in progress
48        public static final int USER_QUERY = 1<<1;
49        // A user request for additional results is in progress
50        public static final int USER_MORE_RESULTS = 1<<2;
51        // A background sync is in progress
52        public static final int BACKGROUND_SYNC = 1<<3;
53        // An initial sync is needed for this Account/Folder to be used
54        public static final int INITIAL_SYNC_NEEDED = 1<<4;
55        // Manual sync is required
56        public static final int MANUAL_SYNC_REQUIRED = 1<<5;
57    }
58
59    /**
60     * Values for the result of the last attempted sync of a Folder/Account
61     */
62    public static final class LastSyncResult {
63        // The sync completed successfully
64        public static final int SUCCESS = 0;
65        // The sync wasn't completed due to a connection error
66        public static final int CONNECTION_ERROR = 1;
67        // The sync wasn't completed due to an authentication error
68        public static final int AUTH_ERROR = 2;
69        // The sync wasn't completed due to a security error
70        public static final int SECURITY_ERROR = 3;
71        // The sync wasn't completed due to a low memory condition
72        public static final int STORAGE_ERROR = 4;
73        // The sync wasn't completed due to an internal error/exception
74        public static final int INTERNAL_ERROR = 5;
75    }
76
77    // The actual content provider should define its own authority
78    public static final String AUTHORITY = "com.android.mail.providers";
79
80    public static final String ACCOUNT_LIST_TYPE =
81            "vnd.android.cursor.dir/vnd.com.android.mail.account";
82    public static final String ACCOUNT_TYPE =
83            "vnd.android.cursor.item/vnd.com.android.mail.account";
84
85    /**
86     * Query parameter key that can be used to control the behavior of list queries.  The value
87     * must be a serialized {@link ListParams} object.  UIProvider implementations are not
88     * required to respect this query parameter
89     */
90    public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams";
91
92    public static final String[] ACCOUNTS_PROJECTION = {
93            BaseColumns._ID,
94            AccountColumns.NAME,
95            AccountColumns.PROVIDER_VERSION,
96            AccountColumns.URI,
97            AccountColumns.CAPABILITIES,
98            AccountColumns.FOLDER_LIST_URI,
99            AccountColumns.FULL_FOLDER_LIST_URI,
100            AccountColumns.SEARCH_URI,
101            AccountColumns.ACCOUNT_FROM_ADDRESSES,
102            AccountColumns.SAVE_DRAFT_URI,
103            AccountColumns.SEND_MAIL_URI,
104            AccountColumns.EXPUNGE_MESSAGE_URI,
105            AccountColumns.UNDO_URI,
106            AccountColumns.SETTINGS_INTENT_URI,
107            AccountColumns.SYNC_STATUS,
108            AccountColumns.HELP_INTENT_URI,
109            AccountColumns.SEND_FEEDBACK_INTENT_URI,
110            AccountColumns.COMPOSE_URI,
111            AccountColumns.MIME_TYPE,
112            AccountColumns.RECENT_FOLDER_LIST_URI,
113            AccountColumns.COLOR,
114            AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI,
115            AccountColumns.MANUAL_SYNC_URI,
116            AccountColumns.SettingsColumns.SIGNATURE,
117            AccountColumns.SettingsColumns.AUTO_ADVANCE,
118            AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE,
119            AccountColumns.SettingsColumns.SNAP_HEADERS,
120            AccountColumns.SettingsColumns.REPLY_BEHAVIOR,
121            AccountColumns.SettingsColumns.HIDE_CHECKBOXES,
122            AccountColumns.SettingsColumns.CONFIRM_DELETE,
123            AccountColumns.SettingsColumns.CONFIRM_ARCHIVE,
124            AccountColumns.SettingsColumns.CONFIRM_SEND,
125            AccountColumns.SettingsColumns.DEFAULT_INBOX,
126            AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME,
127            AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT,
128            AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE
129    };
130
131    public static final int ACCOUNT_ID_COLUMN = 0;
132    public static final int ACCOUNT_NAME_COLUMN = 1;
133    public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
134    public static final int ACCOUNT_URI_COLUMN = 3;
135    public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
136    public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
137    public static final int ACCOUNT_FULL_FOLDER_LIST_URI_COLUMN = 6;
138    public static final int ACCOUNT_SEARCH_URI_COLUMN = 7;
139    public static final int ACCOUNT_FROM_ADDRESSES_COLUMN = 8;
140    public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 9;
141    public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 10;
142    public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 11;
143    public static final int ACCOUNT_UNDO_URI_COLUMN = 12;
144    public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 13;
145    public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
146    public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
147    public static final int ACCOUNT_SEND_FEEDBACK_INTENT_URI_COLUMN = 16;
148    public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 17;
149    public static final int ACCOUNT_MIME_TYPE_COLUMN = 18;
150    public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 19;
151    public static final int ACCOUNT_COLOR_COLUMN = 20;
152    public static final int ACCOUNT_DEFAULT_RECENT_FOLDER_LIST_URI_COLUMN = 21;
153    public static final int ACCOUNT_MANUAL_SYNC_URI_COLUMN = 22;
154
155    public static final int ACCOUNT_SETTINGS_SIGNATURE_COLUMN = 23;
156    public static final int ACCOUNT_SETTINGS_AUTO_ADVANCE_COLUMN = 24;
157    public static final int ACCOUNT_SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 25;
158    public static final int ACCOUNT_SETTINGS_SNAP_HEADERS_COLUMN = 26;
159    public static final int ACCOUNT_SETTINGS_REPLY_BEHAVIOR_COLUMN = 27;
160    public static final int ACCOUNT_SETTINGS_HIDE_CHECKBOXES_COLUMN = 28;
161    public static final int ACCOUNT_SETTINGS_CONFIRM_DELETE_COLUMN = 29;
162    public static final int ACCOUNT_SETTINGS_CONFIRM_ARCHIVE_COLUMN = 30;
163    public static final int ACCOUNT_SETTINGS_CONFIRM_SEND_COLUMN = 31;
164    public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_COLUMN = 32;
165    public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_NAME_COLUMN = 33;
166    public static final int ACCOUNT_SETTINGS_FORCE_REPLY_FROM_DEFAULT_COLUMN = 34;
167    public static final int ACCOUNT_SETTINGS_MAX_ATTACHMENT_SIZE_COLUMN = 35;
168
169    public static final class AccountCapabilities {
170        /**
171         * Whether folders can be synchronized back to the server.
172         */
173        public static final int SYNCABLE_FOLDERS = 0x0001;
174        /**
175         * Whether the server allows reporting spam back.
176         */
177        public static final int REPORT_SPAM = 0x0002;
178        /**
179         * Whether the server allows reporting phishing back.
180         */
181        public static final int REPORT_PHISHING = 0x0004;
182        /**
183         * Whether the server supports a concept of Archive: removing mail from the Inbox but
184         * keeping it around.
185         */
186        public static final int ARCHIVE = 0x0008;
187        /**
188         * Whether the server will stop notifying on updates to this thread? This requires
189         * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
190         */
191        public static final int MUTE = 0x0010;
192        /**
193         * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
194         * to be true, otherwise it should be ignored.
195         */
196        public static final int SERVER_SEARCH = 0x0020;
197        /**
198         * Whether the server supports constraining search to a single folder. Requires
199         * SYNCABLE_FOLDERS, otherwise it should be ignored.
200         */
201        public static final int FOLDER_SERVER_SEARCH = 0x0040;
202        /**
203         * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
204         */
205        public static final int SANITIZED_HTML = 0x0080;
206        /**
207         * Whether the server allows synchronization of draft messages. This does NOT require
208         * SYNCABLE_FOLDERS to be set.
209         */
210        public static final int DRAFT_SYNCHRONIZATION = 0x0100;
211        /**
212         * Does the server allow the user to compose mails (and reply) using addresses other than
213         * their account name? For instance, GMail allows users to set FROM addresses that are
214         * different from account@gmail.com address. For instance, user@gmail.com could have another
215         * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
216         * can compose (and reply) using either address.
217         */
218        public static final int MULTIPLE_FROM_ADDRESSES = 0x0200;
219        /**
220         * Whether the server allows the original message to be included in the reply by setting a
221         * flag on the reply. If we can avoid including the entire previous message, we save on
222         * bandwidth (replies are shorter).
223         */
224        public static final int SMART_REPLY = 0x0400;
225        /**
226         * Does this account support searching locally, on the device? This requires the backend
227         * storage to support a mechanism for searching.
228         */
229        public static final int LOCAL_SEARCH = 0x0800;
230        /**
231         * Whether the server supports a notion of threaded conversations: where replies to messages
232         * are tagged to keep conversations grouped. This could be full threading (each message
233         * lists its parent) or conversation-level threading (each message lists one conversation
234         * which it belongs to)
235         */
236        public static final int THREADED_CONVERSATIONS = 0x1000;
237        /**
238         * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
239         * multiple folders on a single conversation)
240         */
241        public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000;
242        /**
243         * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
244         */
245        public static final int UNDO = 0x4000;
246        /**
247         * Whether the account provides help content.
248         */
249        public static final int HELP_CONTENT = 0x8000;
250        /**
251         * Whether the account provides a way to send feedback content.
252         */
253        public static final int SEND_FEEDBACK = 0x10000;
254        /**
255         * Whether the account provides a mechanism for marking conversations as important.
256         */
257        public static final int MARK_IMPORTANT = 0x20000;
258        /**
259         * Whether initial conversation queries should use a limit parameter
260         */
261        public static final int INITIAL_CONVERSATION_LIMIT = 0x40000;
262        /**
263         * Whether the account cannot be used for sending
264         */
265        public static final int SENDING_UNAVAILABLE = 0x80000;
266    }
267
268    public static final class AccountColumns {
269        /**
270         * This string column contains the human visible name for the account.
271         */
272        public static final String NAME = "name";
273
274        /**
275         * This integer contains the type of the account: Google versus non google. This is not
276         * returned by the UIProvider, rather this is a notion in the system.
277         */
278        public static final String TYPE = "type";
279
280        /**
281         * This integer column returns the version of the UI provider schema from which this
282         * account provider will return results.
283         */
284        public static final String PROVIDER_VERSION = "providerVersion";
285
286        /**
287         * This string column contains the uri to directly access the information for this account.
288         */
289        public static final String URI = "accountUri";
290
291        /**
292         * This integer column contains a bit field of the possible capabilities that this account
293         * supports.
294         */
295        public static final String CAPABILITIES = "capabilities";
296
297        /**
298         * This string column contains the content provider uri to return the
299         * list of top level folders for this account.
300         */
301        public static final String FOLDER_LIST_URI = "folderListUri";
302
303        /**
304         * This string column contains the content provider uri to return the
305         * list of all folders for this account.
306         */
307        public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri";
308
309        /**
310         * This string column contains the content provider uri that can be queried for search
311         * results.
312         * The supported query parameters are limited to those listed
313         * in {@link SearchQueryParameters}
314         * The cursor returned from this query is expected have one row, where the columnm are a
315         * subset of the columns specified in {@link FolderColumns}
316         */
317        public static final String SEARCH_URI = "searchUri";
318
319        /**
320         * This string column contains a json array of json objects representing
321         * custom from addresses for this account or null if there are none.
322         */
323        public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses";
324
325        /**
326         * This string column contains the content provider uri that can be used to save (insert)
327         * new draft messages for this account. NOTE: This might be better to
328         * be an update operation on the messageUri.
329         */
330        public static final String SAVE_DRAFT_URI = "saveDraftUri";
331
332        /**
333         * This string column contains the content provider uri that can be used to send
334         * a message for this account.
335         * NOTE: This might be better to be an update operation on the messageUri.
336         */
337        public static final String SEND_MAIL_URI = "sendMailUri";
338
339        /**
340         * This string column contains the content provider uri that can be used
341         * to expunge a message from this account. NOTE: This might be better to
342         * be an update operation on the messageUri.
343         * When {@link android.content.ContentResolver#update()} is called with this uri, the
344         * {@link ContentValues} object is expected to have {@link BaseColumns._ID} specified with
345         * the local message id of the message.
346         */
347        public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
348
349        /**
350         * This string column contains the content provider uri that can be used
351         * to undo the last committed action.
352         */
353        public static final String UNDO_URI = "undoUri";
354
355        /**
356         * Uri for EDIT intent that will cause the settings screens for this account type to be
357         * shown.
358         * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate
359         * which settings the user wants to edit.
360         * TODO: When we want to support a heterogeneous set of account types, this value may need
361         * to be moved to a global content provider.
362         */
363        public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
364
365        /**
366         * Uri for VIEW intent that will cause the help screens for this account type to be
367         * shown.
368         * TODO: When we want to support a heterogeneous set of account types, this value may need
369         * to be moved to a global content provider.
370         */
371        public static String HELP_INTENT_URI = "helpIntentUri";
372
373        /**
374         * Uri for VIEW intent that will cause the send feedback for this account type to be
375         * shown.
376         * TODO: When we want to support a heterogeneous set of account types, this value may need
377         * to be moved to a global content provider.
378         */
379        public static String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri";
380
381        /**
382         * This int column contains the current sync status of the account (the logical AND of the
383         * sync status of folders in this account)
384         */
385        public static final String SYNC_STATUS = "syncStatus";
386        /**
387         * Uri for VIEW intent that will cause the compose screens for this type
388         * of account to be shown.
389         */
390        public static final String COMPOSE_URI = "composeUri";
391        /**
392         * Mime-type defining this account.
393         */
394        public static final String MIME_TYPE = "mimeType";
395        /**
396         * URI for location of recent folders viewed on this account.
397         */
398        public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
399        /**
400         * URI for default recent folders for this account, if any.
401         */
402        public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri";
403        /**
404         * Color used for this account (for Email/Combined view)
405         */
406        public static final String COLOR = "color";
407        /**
408         * URI for forcing a manual sync of this account.
409         */
410        public static final String MANUAL_SYNC_URI = "manualSyncUri";
411
412        public static final class SettingsColumns {
413            /**
414             * String column containing the contents of the signature for this account.  If no
415             * signature has been specified, the value will be null.
416             */
417            public static final String SIGNATURE = "signature";
418
419            /**
420             * Integer column containing the user's specified auto-advance policy.  This value will
421             * be one of the values in {@link UIProvider.AutoAdvance}
422             */
423            public static final String AUTO_ADVANCE = "auto_advance";
424
425            /**
426             * Integer column containing the user's specified message text size preference.  This
427             * value will be one of the values in {@link UIProvider.MessageTextSize}
428             */
429            public static final String MESSAGE_TEXT_SIZE = "message_text_size";
430
431            /**
432             * Integer column contaning the user's specified snap header preference.  This value
433             * will be one of the values in {@link UIProvider.SnapHeaderValue}
434             */
435            public static final String SNAP_HEADERS = "snap_headers";
436
437            /**
438             * Integer column containing the user's specified default reply behavior.  This value
439             * will be one of the values in {@link UIProvider.DefaultReplyBehavior}
440             */
441            public static final String REPLY_BEHAVIOR = "reply_behavior";
442
443            /**
444             * Integer column containing the user's specified checkbox preference. A
445             * non zero value means to hide checkboxes.
446             */
447            public static final String HIDE_CHECKBOXES = "hide_checkboxes";
448
449            /**
450             * Integer column containing the user's specified confirm delete preference value.
451             * A non zero value indicates that the user has indicated that a confirmation should
452             * be shown when a delete action is performed.
453             */
454            public static final String CONFIRM_DELETE = "confirm_delete";
455
456            /**
457             * Integer column containing the user's specified confirm archive preference value.
458             * A non zero value indicates that the user has indicated that a confirmation should
459             * be shown when an archive action is performed.
460             */
461            public static final String CONFIRM_ARCHIVE = "confirm_archive";
462
463            /**
464             * Integer column containing the user's specified confirm send preference value.
465             * A non zero value indicates that the user has indicated that a confirmation should
466             * be shown when a send action is performed.
467             */
468            public static final String CONFIRM_SEND = "confirm_send";
469            /**
470             * String containing the URI for the default inbox for this account.
471             */
472            public static final String DEFAULT_INBOX = "default_inbox";
473            /**
474             * String containing the name of the default Inbox for this account
475             */
476            public static final String DEFAULT_INBOX_NAME = "default_inbox_name";
477            /**
478             * Integer column containing a non zero value if replies should always be sent from
479             * a default address instead of a recipient.
480             */
481            public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default";
482            /**
483             * Integer column containing the max attachment size in kb.
484             */
485            public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size";
486        }
487    }
488
489    public static final class SearchQueryParameters {
490        /**
491         * Parameter used to specify the search query.
492         */
493        public static final String QUERY = "query";
494
495        /**
496         * If specified, the query results will be limited to this folder.
497         */
498        public static final String FOLDER = "folder";
499
500        private SearchQueryParameters() {}
501    }
502
503    public static final class ConversationListQueryParameters {
504        public static final String DEFAULT_LIMIT = "50";
505        /**
506         * Parameter used to limit the number of rows returned by a conversation list query
507         */
508        public static final String LIMIT = "limit";
509
510        /**
511         * Parameter used to control whether the this query a remote server.
512         */
513        public static final String USE_NETWORK = "use_network";
514
515        /**
516         * Parameter used to allow the caller to indicate desire to receive all notifications.
517         * (Including ones for user initiated actions)
518         */
519        public static final String ALL_NOTIFICATIONS = "all_notifications";
520
521        private ConversationListQueryParameters() {}
522    }
523
524    // We define a "folder" as anything that contains a list of conversations.
525    public static final String FOLDER_LIST_TYPE =
526            "vnd.android.cursor.dir/vnd.com.android.mail.folder";
527    public static final String FOLDER_TYPE =
528            "vnd.android.cursor.item/vnd.com.android.mail.folder";
529
530    public static final String[] FOLDERS_PROJECTION = {
531        BaseColumns._ID,
532        FolderColumns.URI,
533        FolderColumns.NAME,
534        FolderColumns.HAS_CHILDREN,
535        FolderColumns.CAPABILITIES,
536        FolderColumns.SYNC_WINDOW,
537        FolderColumns.CONVERSATION_LIST_URI,
538        FolderColumns.CHILD_FOLDERS_LIST_URI,
539        FolderColumns.UNREAD_COUNT,
540        FolderColumns.TOTAL_COUNT,
541        FolderColumns.REFRESH_URI,
542        FolderColumns.SYNC_STATUS,
543        FolderColumns.LAST_SYNC_RESULT,
544        FolderColumns.TYPE,
545        FolderColumns.ICON_RES_ID,
546        FolderColumns.BG_COLOR,
547        FolderColumns.FG_COLOR,
548        FolderColumns.LOAD_MORE_URI,
549        FolderColumns.HIERARCHICAL_DESC
550    };
551
552    public static final int FOLDER_ID_COLUMN = 0;
553    public static final int FOLDER_URI_COLUMN = 1;
554    public static final int FOLDER_NAME_COLUMN = 2;
555    public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
556    public static final int FOLDER_CAPABILITIES_COLUMN = 4;
557    public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
558    public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
559    public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
560    public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
561    public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
562    public static final int FOLDER_REFRESH_URI_COLUMN = 10;
563    public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
564    public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
565    public static final int FOLDER_TYPE_COLUMN = 13;
566    public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
567    public static final int FOLDER_BG_COLOR_COLUMN = 15;
568    public static final int FOLDER_FG_COLOR_COLUMN = 16;
569    public static final int FOLDER_LOAD_MORE_URI_COLUMN = 17;
570    public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 18;
571
572    public static final class FolderType {
573        public static final int DEFAULT = 0;
574        public static final int INBOX = 1;
575        public static final int DRAFT = 2;
576        public static final int OUTBOX = 3;
577        public static final int SENT = 4;
578        public static final int TRASH = 5;
579        public static final int SPAM = 6;
580        public static final int STARRED = 7;
581    }
582
583    public static final class FolderCapabilities {
584        public static final int SYNCABLE = 0x0001;
585        public static final int PARENT = 0x0002;
586        public static final int CAN_HOLD_MAIL = 0x0004;
587        public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
588         /**
589         * For accounts that support archive, this will indicate that this folder supports
590         * the archive functionality.
591         */
592        public static final int ARCHIVE = 0x0010;
593
594        /**
595         * For accounts that support report spam, this will indicate that this folder supports
596         * the report spam functionality.
597         */
598        public static final int REPORT_SPAM = 0x0020;
599
600        /**
601         * For accounts that support report spam, this will indicate that this folder supports
602         * the mark not spam functionality.
603         */
604        public static final int MARK_NOT_SPAM = 0x0040;
605
606        /**
607         * For accounts that support mute, this will indicate if a mute is performed from within
608         * this folder, the action is destructive.
609         */
610        public static final int DESTRUCTIVE_MUTE = 0x0080;
611
612        /**
613         * Indicates that a folder supports settings (sync lookback, etc.)
614         */
615        public static final int SUPPORTS_SETTINGS = 0x0100;
616        /**
617         * All the messages in this folder are important.
618         */
619        public static final int ONLY_IMPORTANT = 0x0200;
620        /**
621         * Deletions in this folder can't be undone (could include archive if desirable)
622         */
623        public static final int DELETE_ACTION_FINAL = 0x0400;
624        /**
625         * This folder is virtual, i.e. contains conversations potentially pulled from other
626         * folders, potentially even from different accounts.  Examples might be a "starred"
627         * folder, or an "unread" folder (per account or provider-wide)
628         */
629        public static final int IS_VIRTUAL = 0x0800;
630
631        /**
632         * For accounts that support report phishing, this will indicate that this folder supports
633         * the report phishing functionality.
634         */
635        public static final int REPORT_PHISHING = 0x1000;
636    }
637
638    public static final class FolderColumns {
639        /**
640         * This string column contains the uri of the folder.
641         */
642        public static final String URI = "folderUri";
643        /**
644         * This string column contains the human visible name for the folder.
645         */
646        public static final String NAME = "name";
647        /**
648         * This int column represents the capabilities of the folder specified by
649         * FolderCapabilities flags.
650         */
651        public static String CAPABILITIES = "capabilities";
652        /**
653         * This int column represents whether or not this folder has any
654         * child folders.
655         */
656        public static String HAS_CHILDREN = "hasChildren";
657        /**
658         * This int column represents how large the sync window is.
659         */
660        public static String SYNC_WINDOW = "syncWindow";
661        /**
662         * This string column contains the content provider uri to return the
663         * list of conversations for this folder.
664         */
665        public static final String CONVERSATION_LIST_URI = "conversationListUri";
666        /**
667         * This string column contains the content provider uri to return the
668         * list of child folders of this folder.
669         */
670        public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
671
672        public static final String UNREAD_COUNT = "unreadCount";
673
674        public static final String TOTAL_COUNT = "totalCount";
675        /**
676         * This string column contains the content provider uri to force a
677         * refresh of this folder.
678         */
679        public static final  String REFRESH_URI = "refreshUri";
680        /**
681         * This int column contains current sync status of the folder; some combination of the
682         * SyncStatus bits defined above
683         */
684        public static final String SYNC_STATUS  = "syncStatus";
685        /**
686         * This int column contains the sync status of the last sync attempt; one of the
687         * LastSyncStatus values defined above
688         */
689        public static final String LAST_SYNC_RESULT  = "lastSyncResult";
690        /**
691         * This long column contains the icon res id for this folder, or 0 if there is none.
692         */
693        public static final String ICON_RES_ID = "iconResId";
694        /**
695         * This int column contains the type of the folder. Zero is default.
696         */
697        public static final String TYPE = "type";
698        /**
699         * String representing the integer background color associated with this
700         * folder, or null.
701         */
702        public static final String BG_COLOR = "bgColor";
703        /**
704         * String representing the integer of the foreground color associated
705         * with this folder, or null.
706         */
707        public static final String FG_COLOR = "fgColor";
708        /**
709         * String with the content provider Uri used to request more items in the folder, or null.
710         */
711        public static final String LOAD_MORE_URI = "loadMoreUri";
712
713        /**
714         * Possibly empty string that describes the full hierarchy of a folder
715         * along with its name.
716         */
717        public static final String HIERARCHICAL_DESC = "hierarchicalDesc";
718
719        public FolderColumns() {}
720    }
721
722    // We define a "folder" as anything that contains a list of conversations.
723    public static final String CONVERSATION_LIST_TYPE =
724            "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
725    public static final String CONVERSATION_TYPE =
726            "vnd.android.cursor.item/vnd.com.android.mail.conversation";
727
728
729    public static final String[] CONVERSATION_PROJECTION = {
730        BaseColumns._ID,
731        ConversationColumns.URI,
732        ConversationColumns.MESSAGE_LIST_URI,
733        ConversationColumns.SUBJECT,
734        ConversationColumns.SNIPPET,
735        ConversationColumns.CONVERSATION_INFO,
736        ConversationColumns.DATE_RECEIVED_MS,
737        ConversationColumns.HAS_ATTACHMENTS,
738        ConversationColumns.NUM_MESSAGES,
739        ConversationColumns.NUM_DRAFTS,
740        ConversationColumns.SENDING_STATE,
741        ConversationColumns.PRIORITY,
742        ConversationColumns.READ,
743        ConversationColumns.STARRED,
744        ConversationColumns.FOLDER_LIST,
745        ConversationColumns.RAW_FOLDERS,
746        ConversationColumns.FLAGS,
747        ConversationColumns.PERSONAL_LEVEL,
748        ConversationColumns.SPAM,
749        ConversationColumns.PHISHING,
750        ConversationColumns.MUTED,
751        ConversationColumns.COLOR,
752        ConversationColumns.ACCOUNT_URI,
753        ConversationColumns.SENDER_INFO
754    };
755
756    // These column indexes only work when the caller uses the
757    // default CONVERSATION_PROJECTION defined above.
758    public static final int CONVERSATION_ID_COLUMN = 0;
759    public static final int CONVERSATION_URI_COLUMN = 1;
760    public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
761    public static final int CONVERSATION_SUBJECT_COLUMN = 3;
762    public static final int CONVERSATION_SNIPPET_COLUMN = 4;
763    public static final int CONVERSATION_INFO_COLUMN = 5;
764    public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
765    public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
766    public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
767    public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
768    public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
769    public static final int CONVERSATION_PRIORITY_COLUMN = 11;
770    public static final int CONVERSATION_READ_COLUMN = 12;
771    public static final int CONVERSATION_STARRED_COLUMN = 13;
772    public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14;
773    public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 15;
774    public static final int CONVERSATION_FLAGS_COLUMN = 16;
775    public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 17;
776    public static final int CONVERSATION_IS_SPAM_COLUMN = 18;
777    public static final int CONVERSATION_IS_PHISHING_COLUMN = 19;
778    public static final int CONVERSATION_MUTED_COLUMN = 20;
779    public static final int CONVERSATION_COLOR_COLUMN = 21;
780    public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 22;
781    public static final int CONVERSATION_SENDER_INFO_COLUMN = 23;
782
783    public static final class ConversationSendingState {
784        public static final int OTHER = 0;
785        public static final int SENDING = 1;
786        public static final int SENT = 2;
787        public static final int SEND_ERROR = -1;
788    }
789
790    public static final class ConversationPriority {
791        public static final int DEFAULT = 0;
792        public static final int IMPORTANT = 1;
793        public static final int LOW = 0;
794        public static final int HIGH = 1;
795    }
796
797    public static final class ConversationPersonalLevel {
798        public static final int NOT_TO_ME = 0;
799        public static final int TO_ME_AND_OTHERS = 1;
800        public static final int ONLY_TO_ME = 2;
801    }
802
803    public static final class ConversationFlags {
804        public static final int REPLIED = 1<<2;
805        public static final int FORWARDED = 1<<3;
806        public static final int CALENDAR_INVITE = 1<<4;
807    }
808
809    public static final class ConversationPhishing {
810        public static final int NOT_PHISHING = 0;
811        public static final int PHISHING = 1;
812    }
813
814    /**
815     * Names of columns representing fields in a Conversation.
816     */
817    public static final class ConversationColumns {
818        public static final String URI = "conversationUri";
819        /**
820         * This string column contains the content provider uri to return the
821         * list of messages for this conversation.
822         * The cursor returned by this query can return a {@link android.os.Bundle}
823         * from a call to {@link android.database.Cursor#getExtras()}.  This Bundle may have
824         * values with keys listed in {@link CursorExtraKeys}
825         */
826        public static final String MESSAGE_LIST_URI = "messageListUri";
827        /**
828         * This string column contains the subject string for a conversation.
829         */
830        public static final String SUBJECT = "subject";
831        /**
832         * This string column contains the snippet string for a conversation.
833         */
834        public static final String SNIPPET = "snippet";
835        /**
836         * @deprecated
837         */
838        public static final String SENDER_INFO = "senderInfo";
839        /**
840         * This string column contains the string representation of the
841         * ConversationInfo JSON object for a conversation.
842         */
843        public static final String CONVERSATION_INFO = "conversationInfo";
844        /**
845         * This long column contains the time in ms of the latest update to a
846         * conversation.
847         */
848        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
849
850        /**
851         * This boolean column contains whether any messages in this conversation
852         * have attachments.
853         */
854        public static final String HAS_ATTACHMENTS = "hasAttachments";
855
856        /**
857         * This int column contains the number of messages in this conversation.
858         * For unthreaded, this will always be 1.
859         */
860        public static String NUM_MESSAGES = "numMessages";
861
862        /**
863         * This int column contains the number of drafts associated with this
864         * conversation.
865         */
866        public static String NUM_DRAFTS = "numDrafts";
867
868        /**
869         * This int column contains the state of drafts and replies associated
870         * with this conversation. Use ConversationSendingState to interpret
871         * this field.
872         */
873        public static String SENDING_STATE = "sendingState";
874
875        /**
876         * This int column contains the priority of this conversation. Use
877         * ConversationPriority to interpret this field.
878         */
879        public static String PRIORITY = "priority";
880
881        /**
882         * This int column indicates whether the conversation has been read
883         */
884        public static String READ = "read";
885
886        /**
887         * This int column indicates whether the conversation has been starred
888         */
889        public static String STARRED = "starred";
890
891        /**
892         * This string column contains a csv of all folder uris associated with this
893         * conversation
894         */
895        public static final String FOLDER_LIST = "folderList";
896
897        /**
898         * This string column contains a serialized list of all folders
899         * separated by a Folder.FOLDER_SEPARATOR that are associated with this
900         * conversation. The folders should be only those that the provider
901         * wants to have displayed.
902         */
903        public static final String RAW_FOLDERS = "rawFolders";
904        public static final String FLAGS = "conversationFlags";
905        /**
906         * This int column indicates the personal level of a conversation per
907         * {@link ConversationPersonalLevel}.
908         */
909        public static final String PERSONAL_LEVEL = "personalLevel";
910
911        /**
912         * This int column indicates whether the conversation is marked spam.
913         */
914        public static final String SPAM = "spam";
915
916        /**
917         * This int column indicates whether the conversation is marked phishing.
918         */
919        public static final String PHISHING = "phishing";
920
921        /**
922         * This int column indicates whether the conversation was muted.
923         */
924        public static final String MUTED = "muted";
925
926        /**
927         * This int column contains a color for the conversation (used in Email only)
928         */
929        public static final String COLOR = "color";
930
931        /**
932         * This String column contains the Uri for this conversation's account
933         */
934        public static final String ACCOUNT_URI = "accountUri";
935
936        private ConversationColumns() {
937        }
938    }
939
940    public static final class ConversationCursorCommand {
941
942        public static final String COMMAND_RESPONSE_OK = "ok";
943        public static final String COMMAND_RESPONSE_FAILED = "failed";
944
945        /**
946         * This bundle key has a boolean value: true to allow cursor network access (whether this
947         * is true by default is up to the provider), false to temporarily disable network access.
948         * <p>
949         * A provider that implements this command should include this key in its response with a
950         * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
951         */
952        public static final String COMMAND_KEY_ALLOW_NETWORK_ACCESS = "allowNetwork";
953
954        /**
955         * This bundle key has a boolean value: true to indicate that this cursor has been shown
956         * to the user.
957         */
958        public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility";
959
960        private ConversationCursorCommand() {}
961    }
962
963    /**
964     * List of operations that can can be performed on a conversation. These operations are applied
965     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
966     * where the conversation uri is specified, and the ContentValues specifies the operation to
967     * be performed.
968     * <p/>
969     * The operation to be performed is specified in the ContentValues by
970     * the {@link ConversationOperations#OPERATION_KEY}
971     * <p/>
972     * Note not all UI providers will support these operations.  {@link AccountCapabilities} can
973     * be used to determine which operations are supported.
974     */
975    public static final class ConversationOperations {
976        /**
977         * ContentValues key used to specify the operation to be performed
978         */
979        public static final String OPERATION_KEY = "operation";
980
981        /**
982         * Archive operation
983         */
984        public static final String ARCHIVE = "archive";
985
986        /**
987         * Mute operation
988         */
989        public static final String MUTE = "mute";
990
991        /**
992         * Report spam operation
993         */
994        public static final String REPORT_SPAM = "report_spam";
995
996        /**
997         * Report not spam operation
998         */
999        public static final String REPORT_NOT_SPAM = "report_not_spam";
1000
1001        /**
1002         * Report phishing operation
1003         */
1004        public static final String REPORT_PHISHING = "report_phishing";
1005
1006        private ConversationOperations() {
1007        }
1008    }
1009
1010    public static final class DraftType {
1011        public static final int NOT_A_DRAFT = 0;
1012        public static final int COMPOSE = 1;
1013        public static final int REPLY = 2;
1014        public static final int REPLY_ALL = 3;
1015        public static final int FORWARD = 4;
1016
1017        private DraftType() {}
1018    }
1019
1020    /**
1021     * Class for the enum values to determine whether this
1022     * string should be displayed as a high priority warning
1023     * or a low priority warning. The current design has
1024     * high priority warnings in red while low priority warnings
1025     * are grey.
1026     */
1027    public static final class SpamWarningLevel {
1028        public static final int NO_WARNING = 0;
1029        public static final int LOW_WARNING = 1;
1030        public static final int HIGH_WARNING = 2;
1031
1032        private SpamWarningLevel() {}
1033    }
1034
1035    /**
1036     * Class for the enum values to determine which type
1037     * of link to show in the spam warning.
1038     */
1039    public static final class SpamWarningLinkType {
1040        public static final int NO_LINK = 0;
1041        public static final int IGNORE_WARNING = 1;
1042        public static final int REPORT_PHISHING = 2;
1043
1044        private SpamWarningLinkType() {}
1045    }
1046
1047    public static final String[] MESSAGE_PROJECTION = {
1048        BaseColumns._ID,
1049        MessageColumns.SERVER_ID,
1050        MessageColumns.URI,
1051        MessageColumns.CONVERSATION_ID,
1052        MessageColumns.SUBJECT,
1053        MessageColumns.SNIPPET,
1054        MessageColumns.FROM,
1055        MessageColumns.TO,
1056        MessageColumns.CC,
1057        MessageColumns.BCC,
1058        MessageColumns.REPLY_TO,
1059        MessageColumns.DATE_RECEIVED_MS,
1060        MessageColumns.BODY_HTML,
1061        MessageColumns.BODY_TEXT,
1062        MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
1063        MessageColumns.REF_MESSAGE_ID,
1064        MessageColumns.DRAFT_TYPE,
1065        MessageColumns.APPEND_REF_MESSAGE_CONTENT,
1066        MessageColumns.HAS_ATTACHMENTS,
1067        MessageColumns.ATTACHMENT_LIST_URI,
1068        MessageColumns.MESSAGE_FLAGS,
1069        MessageColumns.JOINED_ATTACHMENT_INFOS,
1070        MessageColumns.SAVE_MESSAGE_URI,
1071        MessageColumns.SEND_MESSAGE_URI,
1072        MessageColumns.ALWAYS_SHOW_IMAGES,
1073        MessageColumns.READ,
1074        MessageColumns.STARRED,
1075        MessageColumns.QUOTE_START_POS,
1076        MessageColumns.ATTACHMENTS,
1077        MessageColumns.CUSTOM_FROM_ADDRESS,
1078        MessageColumns.MESSAGE_ACCOUNT_URI,
1079        MessageColumns.EVENT_INTENT_URI,
1080        MessageColumns.SPAM_WARNING_STRING,
1081        MessageColumns.SPAM_WARNING_LEVEL,
1082        MessageColumns.SPAM_WARNING_LINK_TYPE,
1083        MessageColumns.VIA_DOMAIN
1084    };
1085
1086    /** Separates attachment info parts in strings in a message. */
1087    @Deprecated
1088    public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
1089    public static final String MESSAGE_LIST_TYPE =
1090            "vnd.android.cursor.dir/vnd.com.android.mail.message";
1091    public static final String MESSAGE_TYPE =
1092            "vnd.android.cursor.item/vnd.com.android.mail.message";
1093
1094    public static final int MESSAGE_ID_COLUMN = 0;
1095    public static final int MESSAGE_SERVER_ID_COLUMN = 1;
1096    public static final int MESSAGE_URI_COLUMN = 2;
1097    public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3;
1098    public static final int MESSAGE_SUBJECT_COLUMN = 4;
1099    public static final int MESSAGE_SNIPPET_COLUMN = 5;
1100    public static final int MESSAGE_FROM_COLUMN = 6;
1101    public static final int MESSAGE_TO_COLUMN = 7;
1102    public static final int MESSAGE_CC_COLUMN = 8;
1103    public static final int MESSAGE_BCC_COLUMN = 9;
1104    public static final int MESSAGE_REPLY_TO_COLUMN = 10;
1105    public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
1106    public static final int MESSAGE_BODY_HTML_COLUMN = 12;
1107    public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
1108    public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
1109    public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
1110    public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
1111    public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
1112    public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
1113    public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
1114    public static final int MESSAGE_FLAGS_COLUMN = 20;
1115    public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
1116    public static final int MESSAGE_SAVE_URI_COLUMN = 22;
1117    public static final int MESSAGE_SEND_URI_COLUMN = 23;
1118    public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 24;
1119    public static final int MESSAGE_READ_COLUMN = 25;
1120    public static final int MESSAGE_STARRED_COLUMN = 26;
1121    public static final int QUOTED_TEXT_OFFSET_COLUMN = 27;
1122    public static final int MESSAGE_ATTACHMENTS_COLUMN = 28;
1123    public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 29;
1124    public static final int MESSAGE_ACCOUNT_URI_COLUMN = 30;
1125    public static final int MESSAGE_EVENT_INTENT_COLUMN = 31;
1126    public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 32;
1127    public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 33;
1128    public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 34;
1129    public static final int MESSAGE_VIA_DOMAIN_COLUMN = 35;
1130
1131    public static final class CursorStatus {
1132        // The cursor is actively loading more data
1133        public static final int LOADING =      1 << 0;
1134
1135        // The cursor is currently not loading more data, but more data may be available
1136        public static final int LOADED =       1 << 1;
1137
1138        // An error occured while loading data
1139        public static final int ERROR =        1 << 2;
1140
1141        // The cursor is loaded, and there will be no more data
1142        public static final int COMPLETE =     1 << 3;
1143    }
1144
1145
1146    public static final class CursorExtraKeys {
1147        /**
1148         * This integer column contains the staus of the message cursor.  The value will be
1149         * one defined in {@link CursorStatus}.
1150         */
1151        public static final String EXTRA_STATUS = "status";
1152
1153        /**
1154         * Used for finding the cause of an error.
1155         * TODO: define these values
1156         */
1157        public static final String EXTRA_ERROR = "error";
1158
1159    }
1160
1161    public static final class AccountCursorExtraKeys {
1162        /**
1163         * This integer column contains the staus of the account cursor.  The value will be
1164         * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully
1165         * initialized
1166         */
1167        public static final String ACCOUNTS_LOADED = "accounts_loaded";
1168    }
1169
1170
1171    public static final class MessageFlags {
1172        public static final int REPLIED =       1 << 2;
1173        public static final int FORWARDED =     1 << 3;
1174        public static final int CALENDAR_INVITE =     1 << 4;
1175    }
1176
1177    public static final class MessageColumns {
1178        /**
1179         * This string column contains a content provider URI that points to this single message.
1180         */
1181        public static final String URI = "messageUri";
1182        /**
1183         * This string column contains a server-assigned ID for this message.
1184         */
1185        public static final String SERVER_ID = "serverMessageId";
1186        public static final String CONVERSATION_ID = "conversationId";
1187        /**
1188         * This string column contains the subject of a message.
1189         */
1190        public static final String SUBJECT = "subject";
1191        /**
1192         * This string column contains a snippet of the message body.
1193         */
1194        public static final String SNIPPET = "snippet";
1195        /**
1196         * This string column contains the single email address (and optionally name) of the sender.
1197         */
1198        public static final String FROM = "fromAddress";
1199        /**
1200         * This string column contains a comma-delimited list of "To:" recipient email addresses.
1201         */
1202        public static final String TO = "toAddresses";
1203        /**
1204         * This string column contains a comma-delimited list of "CC:" recipient email addresses.
1205         */
1206        public static final String CC = "ccAddresses";
1207        /**
1208         * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
1209         * This value will be null for incoming messages.
1210         */
1211        public static final String BCC = "bccAddresses";
1212        /**
1213         * This string column contains the single email address (and optionally name) of the
1214         * sender's reply-to address.
1215         */
1216        public static final String REPLY_TO = "replyToAddress";
1217        /**
1218         * This long column contains the timestamp (in millis) of receipt of the message.
1219         */
1220        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
1221        /**
1222         * This string column contains the HTML form of the message body, if available. If not,
1223         * a provider must populate BODY_TEXT.
1224         */
1225        public static final String BODY_HTML = "bodyHtml";
1226        /**
1227         * This string column contains the plaintext form of the message body, if HTML is not
1228         * otherwise available. If HTML is available, this value should be left empty (null).
1229         */
1230        public static final String BODY_TEXT = "bodyText";
1231        public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
1232        /**
1233         * This string column contains an opaque string used by the sendMessage api.
1234         */
1235        public static final String REF_MESSAGE_ID = "refMessageId";
1236        /**
1237         * This integer column contains the type of this draft, or zero (0) if this message is not a
1238         * draft. See {@link DraftType} for possible values.
1239         */
1240        public static final String DRAFT_TYPE = "draftType";
1241        /**
1242         * This boolean column indicates whether an outgoing message should trigger special quoted
1243         * text processing upon send. The value should default to zero (0) for protocols that do
1244         * not support or require this flag, and for all incoming messages.
1245         */
1246        public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
1247        /**
1248         * This boolean column indicates whether a message has attachments. The list of attachments
1249         * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
1250         */
1251        public static final String HAS_ATTACHMENTS = "hasAttachments";
1252        /**
1253         * This string column contains the content provider URI for the list of
1254         * attachments associated with this message.
1255         */
1256        public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
1257        /**
1258         * This long column is a bit field of flags defined in {@link MessageFlags}.
1259         */
1260        public static final String MESSAGE_FLAGS = "messageFlags";
1261        /**
1262         * This string column contains a specially formatted string representing all
1263         * attachments that we added to a message that is being sent or saved.
1264         *
1265         * TODO: remove this and use {@link #ATTACHMENTS} instead
1266         */
1267        @Deprecated
1268        public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
1269        /**
1270         * This string column contains the content provider URI for saving this
1271         * message.
1272         */
1273        public static final String SAVE_MESSAGE_URI = "saveMessageUri";
1274        /**
1275         * This string column contains content provider URI for sending this
1276         * message.
1277         */
1278        public static final String SEND_MESSAGE_URI = "sendMessageUri";
1279
1280        /**
1281         * This integer column represents whether the user has specified that images should always
1282         * be shown.  The value of "1" indicates that the user has specified that images should be
1283         * shown, while the value of "0" indicates that the user should be prompted before loading
1284         * any external images.
1285         */
1286        public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
1287
1288        /**
1289         * This boolean column indicates whether the message has been read
1290         */
1291        public static String READ = "read";
1292
1293        /**
1294         * This boolean column indicates whether the message has been starred
1295         */
1296        public static String STARRED = "starred";
1297
1298        /**
1299         * This integer column represents the offset in the message of quoted
1300         * text. If include_quoted_text is zero, the value contained in this
1301         * column is invalid.
1302         */
1303        public static final String QUOTE_START_POS = "quotedTextStartPos";
1304
1305        /**
1306         * This string columns contains a JSON array of serialized {@link Attachment} objects.
1307         */
1308        public static final String ATTACHMENTS = "attachments";
1309        public static final String CUSTOM_FROM_ADDRESS = "customFrom";
1310        /**
1311         * Uri of the account associated with this message. Except in the case
1312         * of showing a combined view, this column is almost always empty.
1313         */
1314        public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri";
1315        /**
1316         * Intent Uri to launch when the user wants to view an event in their calendar, or null.
1317         */
1318        public static final String EVENT_INTENT_URI = "eventIntentUri";
1319        /**
1320         * This string column contains the string for the spam
1321         * warning of this message, or null if there is no spam warning for the message.
1322         */
1323        public static final String SPAM_WARNING_STRING = "spamWarningString";
1324        /**
1325         * This integer column contains the level of spam warning of this message,
1326         * or zero (0) if this message does not have a warning level.
1327         * See {@link SpamWarningLevel} for possible values.
1328         */
1329        public static final String SPAM_WARNING_LEVEL = "spamWarningLevel";
1330        /**
1331         * This integer column contains the type of link for the spam warning
1332         * of this message, or zero (0) if this message does not have a link type.
1333         * See {@link SpamWarningLinkType} for possible values.
1334         */
1335        public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType";
1336        /**
1337         * This string column contains the string for the via domain
1338         * to be included if this message was sent via an alternate
1339         * domain. This column should be null if no via domain exists.
1340         */
1341        public static final String VIA_DOMAIN = "viaDomain";
1342
1343        private MessageColumns() {}
1344    }
1345
1346    /**
1347     * List of operations that can can be performed on a message. These operations are applied
1348     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1349     * where the message uri is specified, and the ContentValues specifies the operation to
1350     * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT)
1351     * <p/>
1352     * Note not all UI providers will support these operations.
1353     */
1354    public static final class MessageOperations {
1355        /**
1356         * Respond to a calendar invitation
1357         */
1358        public static final String RESPOND_COLUMN = "respond";
1359
1360        public static final int RESPOND_ACCEPT = 1;
1361        public static final int RESPOND_TENTATIVE = 2;
1362        public static final int RESPOND_DECLINE = 3;
1363
1364        private MessageOperations() {
1365        }
1366    }
1367
1368    public static final String ATTACHMENT_LIST_TYPE =
1369            "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
1370    public static final String ATTACHMENT_TYPE =
1371            "vnd.android.cursor.item/vnd.com.android.mail.attachment";
1372
1373    public static final String[] ATTACHMENT_PROJECTION = {
1374        AttachmentColumns.NAME,
1375        AttachmentColumns.SIZE,
1376        AttachmentColumns.URI,
1377        AttachmentColumns.CONTENT_TYPE,
1378        AttachmentColumns.STATE,
1379        AttachmentColumns.DESTINATION,
1380        AttachmentColumns.DOWNLOADED_SIZE,
1381        AttachmentColumns.CONTENT_URI,
1382        AttachmentColumns.THUMBNAIL_URI,
1383        AttachmentColumns.PREVIEW_INTENT
1384    };
1385    private static final String EMAIL_SEPARATOR_PATTERN = "\n";
1386    public static final int ATTACHMENT_NAME_COLUMN = 0;
1387    public static final int ATTACHMENT_SIZE_COLUMN = 1;
1388    public static final int ATTACHMENT_URI_COLUMN = 2;
1389    public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
1390    public static final int ATTACHMENT_STATE_COLUMN = 4;
1391    public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
1392    public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
1393    public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
1394    public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
1395    public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
1396
1397    /**
1398     * Valid states for the {@link AttachmentColumns#STATE} column.
1399     *
1400     */
1401    public static final class AttachmentState {
1402        /**
1403         * The full attachment is not present on device. When used as a command,
1404         * setting this state will tell the provider to cancel a download in
1405         * progress.
1406         * <p>
1407         * Valid next states: {@link #DOWNLOADING}
1408         */
1409        public static final int NOT_SAVED = 0;
1410        /**
1411         * The most recent attachment download attempt failed. The current UI
1412         * design does not require providers to persist this state, but
1413         * providers must return this state at least once after a download
1414         * failure occurs. This state may not be used as a command.
1415         * <p>
1416         * Valid next states: {@link #DOWNLOADING}
1417         */
1418        public static final int FAILED = 1;
1419        /**
1420         * The attachment is currently being downloaded by the provider.
1421         * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1422         * download progress while in this state. When used as a command,
1423         * setting this state will tell the provider to initiate a download to
1424         * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1425         * .
1426         * <p>
1427         * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
1428         * {@link #SAVED}
1429         */
1430        public static final int DOWNLOADING = 2;
1431        /**
1432         * The attachment was successfully downloaded to the destination in
1433         * {@link AttachmentColumns#DESTINATION}. If a provider later detects
1434         * that a download is missing, it should reset the state to
1435         * {@link #NOT_SAVED}. This state may not be used as a command on its
1436         * own. To move a file from cache to external, update
1437         * {@link AttachmentColumns#DESTINATION}.
1438         * <p>
1439         * Valid next states: {@link #NOT_SAVED}
1440         */
1441        public static final int SAVED = 3;
1442
1443        private AttachmentState() {}
1444    }
1445
1446    public static final class AttachmentDestination {
1447
1448        /**
1449         * The attachment will be or is already saved to the app-private cache partition.
1450         */
1451        public static final int CACHE = 0;
1452        /**
1453         * The attachment will be or is already saved to external shared device storage.
1454         */
1455        public static final int EXTERNAL = 1;
1456
1457        private AttachmentDestination() {}
1458    }
1459
1460    public static final class AttachmentColumns {
1461        /**
1462         * This string column is the attachment's file name, intended for display in UI. It is not
1463         * the full path of the file.
1464         */
1465        public static final String NAME = OpenableColumns.DISPLAY_NAME;
1466        /**
1467         * This integer column is the file size of the attachment, in bytes.
1468         */
1469        public static final String SIZE = OpenableColumns.SIZE;
1470        /**
1471         * This column is a {@link Uri} that can be queried to monitor download state and progress
1472         * for this individual attachment (resulting cursor has one single row for this attachment).
1473         */
1474        public static final String URI = "uri";
1475        /**
1476         * This string column is the MIME type of the attachment.
1477         */
1478        public static final String CONTENT_TYPE = "contentType";
1479        /**
1480         * This integer column is the current downloading state of the
1481         * attachment as defined in {@link AttachmentState}.
1482         * <p>
1483         * Providers must accept updates to {@link #URI} with new values of
1484         * this column to initiate or cancel downloads.
1485         */
1486        public static final String STATE = "state";
1487        /**
1488         * This integer column is the file destination for the current download
1489         * in progress (when {@link #STATE} is
1490         * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
1491         * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
1492         * in {@link AttachmentDestination}. This value is undefined in any
1493         * other state.
1494         * <p>
1495         * Providers must accept updates to {@link #URI} with new values of
1496         * this column to move an existing downloaded file.
1497         */
1498        public static final String DESTINATION = "destination";
1499        /**
1500         * This integer column is the current number of bytes downloaded when
1501         * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
1502         * undefined in any other state.
1503         */
1504        public static final String DOWNLOADED_SIZE = "downloadedSize";
1505        /**
1506         * This column is a {@link Uri} that points to the downloaded local file
1507         * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
1508         * undefined in any other state.
1509         */
1510        public static final String CONTENT_URI = "contentUri";
1511        /**
1512         * This column is a {@link Uri} that points to a local thumbnail file
1513         * for the attachment. Providers that do not support downloading
1514         * attachment thumbnails may leave this null.
1515         */
1516        public static final String THUMBNAIL_URI = "thumbnailUri";
1517        /**
1518         * This column is an {@link Intent} to launch a preview activity that
1519         * allows the user to efficiently view an attachment without having to
1520         * first download the entire file. Providers that do not support
1521         * previewing attachments may leave this null. The intent is represented
1522         * as a byte-array blob generated by writing an Intent to a parcel and
1523         * then marshaling that parcel.
1524         */
1525        public static final String PREVIEW_INTENT = "previewIntent";
1526
1527        private AttachmentColumns() {}
1528    }
1529
1530    public static String getAttachmentTypeSetting() {
1531        // TODO: query the account to see what kinds of attachments it supports?
1532        return "com.google.android.gm.allowAddAnyAttachment";
1533    }
1534
1535    public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1536        DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1537        ArrayList<String> recipients = new ArrayList<String>();
1538        String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1539        for (String address : addresses) {
1540            recipients.add(address);
1541        }
1542        statsUpdater.updateWithAddress(recipients);
1543    }
1544
1545    public static final String[] UNDO_PROJECTION = {
1546        ConversationColumns.MESSAGE_LIST_URI
1547    };
1548    public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
1549
1550    // Parameter used to indicate the sequence number for an undoable operation
1551    public static final String SEQUENCE_QUERY_PARAMETER = "seq";
1552
1553    /**
1554     * Settings for auto advancing when the current conversation has been destroyed.
1555     */
1556    public static final class AutoAdvance {
1557        /** No setting specified. */
1558        public static final int UNSET = 0;
1559        /** Go to the older message (if available) */
1560        public static final int OLDER = 1;
1561        /** Go to the newer message (if available) */
1562        public static final int NEWER = 2;
1563        /** Go back to conversation list*/
1564        public static final int LIST = 3;
1565    }
1566
1567    public static final class SnapHeaderValue {
1568        public static final int ALWAYS = 0;
1569        public static final int PORTRAIT_ONLY = 1;
1570        public static final int NEVER = 2;
1571    }
1572
1573    public static final class MessageTextSize {
1574        public static final int TINY = -2;
1575        public static final int SMALL = -1;
1576        public static final int NORMAL = 0;
1577        public static final int LARGE = 1;
1578        public static final int HUGE = 2;
1579    }
1580
1581    public static final class DefaultReplyBehavior {
1582        public static final int REPLY = 0;
1583        public static final int REPLY_ALL = 1;
1584    }
1585
1586    /**
1587     * Action for an intent used to update/create new notifications.  The mime type of this
1588     * intent should be set to the mimeType of the account that is generating this notification.
1589     * An intent of this action is required to have the following extras:
1590     * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT}
1591     */
1592    public static final String ACTION_UPDATE_NOTIFICATION =
1593            "com.android.mail.action.update_notification";
1594
1595    public static final class UpdateNotificationExtras {
1596        /**
1597         * Parcelable extra containing a {@link Uri} to a {@link Folder}
1598         */
1599        public static final String EXTRA_FOLDER = "notification_extra_folder";
1600
1601        /**
1602         * Parcelable extra containing a {@link Uri} to an {@link Account}
1603         */
1604        public static final String EXTRA_ACCOUNT = "notification_extra_account";
1605
1606        /**
1607         * Integer extra containing the update unread count for the account/folder.
1608         * If this value is 0, the UI will not block the intent to allow code to clear notifications
1609         * to run.
1610         */
1611        public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count";
1612    }
1613
1614    public static final class EditSettingsExtras {
1615        /**
1616         * Parcelable extra containing account for which the user wants to
1617         * modify settings
1618         */
1619        public static final String EXTRA_ACCOUNT = "extra_account";
1620
1621        /**
1622         * Parcelable extra containing folder for which the user wants to
1623         * modify settings
1624         */
1625        public static final String EXTRA_FOLDER = "extra_folder";
1626
1627        /**
1628         * Boolean extra which is set true if the user wants to "manage folders"
1629         */
1630        public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders";
1631    }
1632}
1633