UIProvider.java revision ef0f19e1ebf77efac19640becaac544d6be1e89e
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.database.Cursor;
23import android.net.Uri;
24import android.os.Bundle;
25import android.os.Parcelable;
26import android.provider.BaseColumns;
27import android.provider.OpenableColumns;
28import android.text.TextUtils;
29
30import com.google.common.collect.ImmutableList;
31import com.google.common.collect.ImmutableMap;
32
33import java.util.Map;
34import java.util.regex.Pattern;
35
36public class UIProvider {
37    public static final String EMAIL_SEPARATOR = ",";
38    public static final long INVALID_CONVERSATION_ID = -1;
39    public static final long INVALID_MESSAGE_ID = -1;
40
41    /**
42     * Values for the current state of a Folder/Account; note that it's possible that more than one
43     * sync is in progress
44     */
45    public static final class SyncStatus {
46        /**
47         * No sync in progress
48         */
49        public static final int NO_SYNC = 0;
50        /**
51         * A user-requested sync/refresh is in progress. This occurs when the user taps on the
52         * refresh icon in the action bar.
53         */
54        public static final int USER_REFRESH = 1<<0;
55        /**
56         * A user-requested live query is in progress. This occurs when the user goes past the end
57         * of the fetched results in the conversation list.
58         */
59        public static final int LIVE_QUERY = 1<<1;
60        /** Please use the constant {@link #LIVE_QUERY} instead. */
61        @Deprecated
62        public static final int USER_QUERY = 1<<1;
63        /**
64         * A background sync is in progress. This happens on <b>no</b> user interaction.
65         */
66        public static final int BACKGROUND_SYNC = 1<<2;
67        /**
68         * An initial sync is needed for this Account/Folder to be used. This is account-wide, when
69         * the user has added an account, and the first sync has not completed successfully.
70         */
71        public static final int INITIAL_SYNC_NEEDED = 1<<3;
72        /**
73         * Manual sync is required. This is account-wide, when the user has disabled sync on the
74         * Gmail account.
75         */
76        public static final int MANUAL_SYNC_REQUIRED = 1<<4;
77        /**
78         * Account initialization is required.
79         */
80        public static final int ACCOUNT_INITIALIZATION_REQUIRED = 1<<5;
81
82        public static boolean isSyncInProgress(int syncStatus) {
83            return 0 != (syncStatus & (BACKGROUND_SYNC |
84                    USER_REFRESH |
85                    LIVE_QUERY));
86        }
87    }
88
89    /**
90     * Values for the result of the last attempted sync of a Folder/Account
91     */
92    public static final class LastSyncResult {
93        /** The sync completed successfully */
94        public static final int SUCCESS = 0;
95        /** The sync wasn't completed due to a connection error */
96        public static final int CONNECTION_ERROR = 1;
97        /** The sync wasn't completed due to an authentication error */
98        public static final int AUTH_ERROR = 2;
99        /** The sync wasn't completed due to a security error */
100        public static final int SECURITY_ERROR = 3;
101        /** The sync wasn't completed due to a low memory condition */
102        public static final int STORAGE_ERROR = 4;
103        /** The sync wasn't completed due to an internal error/exception */
104        public static final int INTERNAL_ERROR = 5;
105        /** The sync wasn't completed due to an error in the mail server */
106        public static final int SERVER_ERROR = 6;
107    }
108
109    // The actual content provider should define its own authority
110    public static final String AUTHORITY = "com.android.mail.providers";
111
112    public static final String ACCOUNT_LIST_TYPE =
113            "vnd.android.cursor.dir/vnd.com.android.mail.account";
114    public static final String ACCOUNT_TYPE =
115            "vnd.android.cursor.item/vnd.com.android.mail.account";
116
117    /**
118     * Query parameter key that can be used to control the behavior of list queries.  The value
119     * must be a serialized {@link ListParams} object.  UIProvider implementations are not
120     * required to respect this query parameter
121     */
122    public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams";
123    public static final String LABEL_QUERY_PARAMETER = "label";
124    public static final String SEEN_QUERY_PARAMETER = "seen";
125
126    /**
127     * Query parameter that can be used to specify a parent for a the returned folder object from a
128     * query. When set, if a folder is returned that does not have a true parent, it will use this
129     * uri as its parent uri.
130     */
131    public static final String DEFAULT_PARENT_QUERY_PARAMETER = "defaultParent";
132
133    public static final Map<String, Class<?>> ACCOUNTS_COLUMNS_NO_CAPABILITIES =
134            new ImmutableMap.Builder<String, Class<?>>()
135            .put(AccountColumns._ID, Integer.class)
136            .put(AccountColumns.NAME, String.class)
137            .put(AccountColumns.SENDER_NAME, String.class)
138            .put(AccountColumns.ACCOUNT_MANAGER_NAME, String.class)
139            .put(AccountColumns.TYPE, String.class)
140            .put(AccountColumns.PROVIDER_VERSION, Integer.class)
141            .put(AccountColumns.URI, String.class)
142            .put(AccountColumns.FOLDER_LIST_URI, String.class)
143            .put(AccountColumns.FULL_FOLDER_LIST_URI, String.class)
144            .put(AccountColumns.ALL_FOLDER_LIST_URI, String.class)
145            .put(AccountColumns.SEARCH_URI, String.class)
146            .put(AccountColumns.ACCOUNT_FROM_ADDRESSES, String.class)
147            .put(AccountColumns.EXPUNGE_MESSAGE_URI, String.class)
148            .put(AccountColumns.UNDO_URI, String.class)
149            .put(AccountColumns.SETTINGS_INTENT_URI, String.class)
150            .put(AccountColumns.SYNC_STATUS, Integer.class)
151            .put(AccountColumns.HELP_INTENT_URI, String.class)
152            .put(AccountColumns.SEND_FEEDBACK_INTENT_URI, String.class)
153            .put(AccountColumns.REAUTHENTICATION_INTENT_URI, String.class)
154            .put(AccountColumns.COMPOSE_URI, String.class)
155            .put(AccountColumns.MIME_TYPE, String.class)
156            .put(AccountColumns.RECENT_FOLDER_LIST_URI, String.class)
157            .put(AccountColumns.COLOR, Integer.class)
158            .put(AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI, String.class)
159            .put(AccountColumns.MANUAL_SYNC_URI, String.class)
160            .put(AccountColumns.VIEW_INTENT_PROXY_URI, String.class)
161            .put(AccountColumns.ACCOUNT_COOKIE_QUERY_URI, String.class)
162            .put(AccountColumns.SettingsColumns.SIGNATURE, String.class)
163            .put(AccountColumns.SettingsColumns.AUTO_ADVANCE, Integer.class)
164            .put(AccountColumns.SettingsColumns.SNAP_HEADERS, Integer.class)
165            .put(AccountColumns.SettingsColumns.REPLY_BEHAVIOR, Integer.class)
166            .put(AccountColumns.SettingsColumns.CONV_LIST_ICON, Integer.class)
167            .put(AccountColumns.SettingsColumns.CONV_LIST_ATTACHMENT_PREVIEWS, Integer.class)
168            .put(AccountColumns.SettingsColumns.CONFIRM_DELETE, Integer.class)
169            .put(AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, Integer.class)
170            .put(AccountColumns.SettingsColumns.CONFIRM_SEND, Integer.class)
171            .put(AccountColumns.SettingsColumns.DEFAULT_INBOX, String.class)
172            .put(AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, String.class)
173            .put(AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT, Integer.class)
174            .put(AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE, Integer.class)
175            .put(AccountColumns.SettingsColumns.SWIPE, Integer.class)
176            .put(AccountColumns.SettingsColumns.IMPORTANCE_MARKERS_ENABLED, Integer.class)
177            .put(AccountColumns.SettingsColumns.SHOW_CHEVRONS_ENABLED, Integer.class)
178            .put(AccountColumns.SettingsColumns.SETUP_INTENT_URI, String.class)
179            .put(AccountColumns.SettingsColumns.CONVERSATION_VIEW_MODE, Integer.class)
180            .put(AccountColumns.SettingsColumns.VEILED_ADDRESS_PATTERN, String.class)
181            .put(AccountColumns.UPDATE_SETTINGS_URI, String.class)
182            .put(AccountColumns.ENABLE_MESSAGE_TRANSFORMS, Integer.class)
183            .put(AccountColumns.SYNC_AUTHORITY, String.class)
184            .put(AccountColumns.QUICK_RESPONSE_URI, String.class)
185            .put(AccountColumns.SettingsColumns.MOVE_TO_INBOX, String.class)
186            .put(AccountColumns.SettingsColumns.SHOW_IMAGES, Integer.class)
187            .build();
188
189    public static final Map<String, Class<?>> ACCOUNTS_COLUMNS =
190            new ImmutableMap.Builder<String, Class<?>>()
191            .putAll(ACCOUNTS_COLUMNS_NO_CAPABILITIES)
192            .put(AccountColumns.CAPABILITIES, Integer.class)
193            .build();
194
195    // pull out the keyset from above to form the projection
196    public static final String[] ACCOUNTS_PROJECTION =
197            ACCOUNTS_COLUMNS.keySet().toArray(new String[ACCOUNTS_COLUMNS.size()]);
198
199    public static final
200            String[] ACCOUNTS_PROJECTION_NO_CAPABILITIES = ACCOUNTS_COLUMNS_NO_CAPABILITIES.keySet()
201                    .toArray(new String[ACCOUNTS_COLUMNS_NO_CAPABILITIES.size()]);
202
203    public static final class AccountCapabilities {
204        /**
205         * Whether folders can be synchronized back to the server.
206         */
207        public static final int SYNCABLE_FOLDERS = 0x0001;
208        /**
209         * Whether the server allows reporting spam back.
210         */
211        public static final int REPORT_SPAM = 0x0002;
212        /**
213         * Whether the server allows reporting phishing back.
214         */
215        public static final int REPORT_PHISHING = 0x0004;
216        /**
217         * Whether the server supports a concept of Archive: removing mail from the Inbox but
218         * keeping it around.
219         */
220        public static final int ARCHIVE = 0x0008;
221        /**
222         * Whether the server will stop notifying on updates to this thread? This requires
223         * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
224         */
225        public static final int MUTE = 0x0010;
226        /**
227         * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
228         * to be true, otherwise it should be ignored.
229         */
230        public static final int SERVER_SEARCH = 0x0020;
231        /**
232         * Whether the server supports constraining search to a single folder. Requires
233         * SYNCABLE_FOLDERS, otherwise it should be ignored.
234         */
235        public static final int FOLDER_SERVER_SEARCH = 0x0040;
236        /**
237         * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
238         */
239        public static final int SANITIZED_HTML = 0x0080;
240        /**
241         * Whether the server allows synchronization of draft messages. This does NOT require
242         * SYNCABLE_FOLDERS to be set.
243         */
244        public static final int DRAFT_SYNCHRONIZATION = 0x0100;
245        /**
246         * Does the server allow the user to compose mails (and reply) using addresses other than
247         * their account name? For instance, GMail allows users to set FROM addresses that are
248         * different from account@gmail.com address. For instance, user@gmail.com could have another
249         * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
250         * can compose (and reply) using either address.
251         */
252        public static final int MULTIPLE_FROM_ADDRESSES = 0x0200;
253        /**
254         * Whether the server allows the original message to be included in the reply by setting a
255         * flag on the reply. If we can avoid including the entire previous message, we save on
256         * bandwidth (replies are shorter).
257         */
258        public static final int SMART_REPLY = 0x0400;
259        /**
260         * Does this account support searching locally, on the device? This requires the backend
261         * storage to support a mechanism for searching.
262         */
263        public static final int LOCAL_SEARCH = 0x0800;
264        /**
265         * Whether the server supports a notion of threaded conversations: where replies to messages
266         * are tagged to keep conversations grouped. This could be full threading (each message
267         * lists its parent) or conversation-level threading (each message lists one conversation
268         * which it belongs to)
269         */
270        public static final int THREADED_CONVERSATIONS = 0x1000;
271        /**
272         * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
273         * multiple folders on a single conversation)
274         */
275        public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000;
276        /**
277         * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
278         */
279        public static final int UNDO = 0x4000;
280        /**
281         * Whether the account provides help content.
282         */
283        public static final int HELP_CONTENT = 0x8000;
284        /**
285         * Whether the account provides a way to send feedback content.
286         */
287        public static final int SEND_FEEDBACK = 0x10000;
288        /**
289         * Whether the account provides a mechanism for marking conversations as important.
290         */
291        public static final int MARK_IMPORTANT = 0x20000;
292        /**
293         * Whether initial conversation queries should use a limit parameter
294         */
295        public static final int INITIAL_CONVERSATION_LIMIT = 0x40000;
296        /**
297         * Whether the account cannot be used for sending
298         */
299        public static final int SENDING_UNAVAILABLE = 0x80000;
300        /**
301         * Whether the account supports discarding drafts from a conversation.  This should be
302         * removed when all providers support this capability
303         */
304        public static final int DISCARD_CONVERSATION_DRAFTS = 0x100000;
305        /**
306         * Whether the account supports emptying the trash folder
307         */
308        public static final int EMPTY_TRASH = 0x200000;
309        /**
310         * Whether the account supports emptying the spam folder
311         */
312        public static final int EMPTY_SPAM = 0x400000;
313        /**
314         * Whether the account supports nested folders
315         */
316        public static final int NESTED_FOLDERS = 0x800000;
317    }
318
319    public static final class AccountColumns implements BaseColumns {
320        /**
321         * This string column contains the human visible name for the account.
322         */
323        public static final String NAME = "name";
324
325        /**
326         * This string column contains the real name associated with the account, e.g. "John Doe"
327         */
328        public static final String SENDER_NAME = "senderName";
329
330        /**
331         * This string column contains the account manager name of this account.
332         */
333
334        public static final String ACCOUNT_MANAGER_NAME = "accountManagerName";
335
336        /**
337         * This integer contains the type of the account: Google versus non google. This is not
338         * returned by the UIProvider, rather this is a notion in the system.
339         */
340        public static final String TYPE = "type";
341
342        /**
343         * This integer column returns the version of the UI provider schema from which this
344         * account provider will return results.
345         */
346        public static final String PROVIDER_VERSION = "providerVersion";
347
348        /**
349         * This string column contains the uri to directly access the information for this account.
350         */
351        public static final String URI = "accountUri";
352
353        /**
354         * This integer column contains a bit field of the possible capabilities that this account
355         * supports.
356         */
357        public static final String CAPABILITIES = "capabilities";
358
359        /**
360         * This string column contains the content provider uri to return the
361         * list of top level folders for this account.
362         */
363        public static final String FOLDER_LIST_URI = "folderListUri";
364
365        /**
366         * This string column contains the content provider uri to return the
367         * list of all real folders for this account.
368         */
369        public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri";
370
371        /**
372         * This string column contains the content provider uri to return the
373         * list of all real and synthetic folders for this account.
374         */
375        public static final String ALL_FOLDER_LIST_URI = "allFolderListUri";
376
377        /**
378         * This string column contains the content provider uri that can be queried for search
379         * results.
380         * The supported query parameters are limited to those listed
381         * in {@link SearchQueryParameters}
382         * The cursor returned from this query is expected have one row, where the columnm are a
383         * subset of the columns specified in {@link FolderColumns}
384         */
385        public static final String SEARCH_URI = "searchUri";
386
387        /**
388         * This string column contains a json array of json objects representing
389         * custom from addresses for this account or null if there are none.
390         */
391        public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses";
392
393        /**
394         * This string column contains the content provider uri that can be used
395         * to expunge a message from this account. NOTE: This might be better to
396         * be an update operation on the messageUri.
397         * When {@link android.content.ContentResolver#update(Uri, ContentValues, String, String[])}
398         * is called with this uri, the {@link ContentValues} object is expected to have
399         * {@link BaseColumns#_ID} specified with the local message id of the message.
400         */
401        public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
402
403        /**
404         * This string column contains the content provider uri that can be used
405         * to undo the last committed action.
406         */
407        public static final String UNDO_URI = "undoUri";
408
409        /**
410         * Uri for EDIT intent that will cause the settings screens for this account type to be
411         * shown.
412         * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate
413         * which settings the user wants to edit.
414         * TODO: When we want to support a heterogeneous set of account types, this value may need
415         * to be moved to a global content provider.
416         */
417        public static final String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
418
419        /**
420         * Uri for VIEW intent that will cause the help screens for this account type to be
421         * shown.
422         * TODO: When we want to support a heterogeneous set of account types, this value may need
423         * to be moved to a global content provider.
424         */
425        public static final String HELP_INTENT_URI = "helpIntentUri";
426
427        /**
428         * Uri for VIEW intent that will cause the send feedback for this account type to be
429         * shown.
430         * TODO: When we want to support a heterogeneous set of account types, this value may need
431         * to be moved to a global content provider.
432         */
433        public static final String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri";
434
435        /**
436         * Uri for VIEW intent that will cause the user to be prompted for authentication for
437         * this account.  startActivityForResult() will be called with this intent. Activities that
438         * handle this intent are expected to return {@link android.app.Activity#RESULT_OK} if the
439         * user successfully authenticated.
440         */
441        public static final String REAUTHENTICATION_INTENT_URI = "reauthenticationUri";
442
443        /**
444         * This int column contains the current sync status of the account (the logical AND of the
445         * sync status of folders in this account)
446         */
447        public static final String SYNC_STATUS = "syncStatus";
448        /**
449         * Uri for VIEW intent that will cause the compose screens for this type
450         * of account to be shown.
451         */
452        public static final String COMPOSE_URI = "composeUri";
453        /**
454         * Mime-type defining this account.
455         */
456        public static final String MIME_TYPE = "mimeType";
457        /**
458         * URI for location of recent folders viewed on this account.
459         */
460        public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
461        /**
462         * URI for default recent folders for this account, if any.
463         */
464        public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri";
465        /**
466         * Color (integer) used for this account (for Email/Combined view)
467         */
468        public static final String COLOR = "color";
469        /**
470         * URI for forcing a manual sync of this account.
471         */
472        public static final String MANUAL_SYNC_URI = "manualSyncUri";
473        /**
474         * Optional URI of this account for proxying view intents.
475         */
476        public static final String VIEW_INTENT_PROXY_URI = "viewProxyUri";
477        /**
478         * Optional URI for querying for the cookie needed for accessing inline content.  The cookie
479         * specified here will be set on the uri specified in the
480         * {@link ConversationColumns#CONVERSATION_BASE_URI} column. The cursor returned from this
481         * query is expected have one row, where the columns are specified in
482         * {@link AccountCookieColumns}
483         */
484        public static final String ACCOUNT_COOKIE_QUERY_URI = "accountCookieUri";
485        /**
486         * URI to be used with an update() ContentResolver call with a {@link ContentValues} object
487         * where the keys are from the {@link AccountColumns.SettingsColumns}, and the values are
488         * the new values.
489         */
490        public static final String UPDATE_SETTINGS_URI = "updateSettingsUri";
491        /**
492         * Whether message transforms (HTML DOM manipulation) should be enabled.
493         */
494        public static final String ENABLE_MESSAGE_TRANSFORMS = "enableMessageTransforms";
495        /**
496         * Sync authority to use.
497         */
498        public static final String SYNC_AUTHORITY = "syncAuthority";
499        /**
500         * URI for querying this account's quick responses
501         */
502        public static final String QUICK_RESPONSE_URI = "quickResponseUri";
503
504        public static final class SettingsColumns {
505            /**
506             * String column containing the contents of the signature for this account.  If no
507             * signature has been specified, the value will be null.
508             */
509            public static final String SIGNATURE = "signature";
510
511            /**
512             * Integer column containing the user's specified auto-advance policy.  This value will
513             * be one of the values in {@link UIProvider.AutoAdvance}
514             */
515            public static final String AUTO_ADVANCE = "auto_advance";
516
517            /**
518             * Integer column contaning the user's specified snap header preference.  This value
519             * will be one of the values in {@link UIProvider.SnapHeaderValue}
520             */
521            public static final String SNAP_HEADERS = "snap_headers";
522
523            /**
524             * Integer column containing the user's specified default reply behavior.  This value
525             * will be one of the values in {@link UIProvider.DefaultReplyBehavior}
526             */
527            public static final String REPLY_BEHAVIOR = "reply_behavior";
528
529            /**
530             * Integer column containing the user's preference for whether to show sender images
531             * or not in the conversation list view.  This value will be one of the values in
532             * {@link UIProvider.ConversationListIcon}.
533             */
534            public static final String CONV_LIST_ICON = "conversation_list_icon";
535
536            /**
537             * Integer column containing the user's preference for whether to show attachment
538             * previews or not in the conversation list view. A non zero value indicates that
539             * attachment previews should be displayed.
540             */
541            public static final String CONV_LIST_ATTACHMENT_PREVIEWS
542                    = "conversation_list_attachment_previews";
543
544            /**
545             * Integer column containing the user's specified confirm delete preference value.
546             * A non zero value indicates that the user has indicated that a confirmation should
547             * be shown when a delete action is performed.
548             */
549            public static final String CONFIRM_DELETE = "confirm_delete";
550
551            /**
552             * Integer column containing the user's specified confirm archive preference value.
553             * A non zero value indicates that the user has indicated that a confirmation should
554             * be shown when an archive action is performed.
555             */
556            public static final String CONFIRM_ARCHIVE = "confirm_archive";
557
558            /**
559             * Integer column containing the user's specified confirm send preference value.
560             * A non zero value indicates that the user has indicated that a confirmation should
561             * be shown when a send action is performed.
562             */
563            public static final String CONFIRM_SEND = "confirm_send";
564            /**
565             * String containing the URI for the default inbox for this account.
566             */
567            public static final String DEFAULT_INBOX = "default_inbox";
568            /**
569             * String containing the name of the default Inbox for this account
570             */
571            public static final String DEFAULT_INBOX_NAME = "default_inbox_name";
572            /**
573             * Integer column containing a non zero value if replies should always be sent from
574             * a default address instead of a recipient.
575             */
576            public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default";
577            /**
578             * Integer column containing the max attachment size in kb.
579             */
580            public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size";
581            /**
582             * Integer column containing a value matching one of the constants from {@link Swipe}
583             */
584            public static final String SWIPE = "swipe";
585            /**
586             * Integer column containing whether importance markers are enabled.
587             */
588            public static final String IMPORTANCE_MARKERS_ENABLED = "importance_markers_enabled";
589            /**
590             * Integer column containing whether chevrons should be shown.
591             * Chevrons are personal level indicators:
592             * an arrow ( › ) by messages sent to my address (not a mailing list),
593             * and a double arrow ( » ) by messages sent only to me.
594             */
595            public static final String SHOW_CHEVRONS_ENABLED = "show_chevrons_enabled";
596            /**
597             * Uri for EDIT intent that will cause account-specific setup UI to be shown. If not
598             * null, this intent should be used when an account is "entered" (i.e. viewing a folder
599             * in the account, etc.)
600             */
601            public static final String SETUP_INTENT_URI = "setup_intent_uri";
602            /**
603             * The regex that defines a veiled address, something that must be hidden from user
604             * view because it is temporary, long and clumsy.
605             */
606            public static final String VEILED_ADDRESS_PATTERN = "veiled_address_pattern";
607            /**
608             * Integer column containing the Conversation view mode.  This value will match one of
609             * constants from  {@link ConversationViewMode}
610             */
611            public static final String CONVERSATION_VIEW_MODE = "conversation_view_mode";
612            /**
613             * String containing the URI for the inbox conversations should be moved to for this
614             * account.
615             */
616            public static final String MOVE_TO_INBOX = "move_to_inbox";
617            /**
618             * Show images in conversation view.
619             */
620            public static final String SHOW_IMAGES = "show_images";
621        }
622    }
623
624    public static final String[] QUICK_RESPONSE_PROJECTION = {
625        BaseColumns._ID,
626        QuickResponseColumns.TEXT,
627        QuickResponseColumns.URI
628    };
629
630    public static final class QuickResponseColumns {
631        /**
632         * Text of the Quick Response
633         */
634        public static final String TEXT = "quickResponse";
635        /**
636         * URI to access this row directly
637         */
638        public static final String URI = "uri";
639    }
640
641    public static final String[] ACCOUNT_COOKIE_PROJECTION = {
642        AccountCookieColumns.COOKIE
643    };
644
645    public static final class AccountCookieColumns {
646        /**
647         * String column containing the cookie string for this account.
648         */
649        public static final String COOKIE = "cookie";
650    }
651
652    public static final class SearchQueryParameters {
653        /**
654         * Parameter used to specify the search query.
655         */
656        public static final String QUERY = "query";
657
658        /*
659        * This parameter is set by ACTION_SEARCH to differentiate one ACTION_SEARCH from another.
660        * This is necessary because the Uri we construct for each query is only based on the
661        * search query string. However, subsequent searches with the same string will confuse
662        * the underlying provider into thinking that it's still the same "session", thus it will
663        * keep the data it had before. This is a problem when we do search on some keyword, then
664        * without navigating away we do the same search again (expecting to see new results there
665        * and outdated results gone). By keying the Uri on both search query and a unique id,
666        * we ensure that old data gets properly destroyed.
667        * @see UnifiedGmail, MailEngine#getConversationCursorForQuery.
668        */
669        public static final String QUERY_IDENTIFER = "query_identifier";
670
671        private SearchQueryParameters() {}
672    }
673
674    public static final class ConversationListQueryParameters {
675        public static final String DEFAULT_LIMIT = "50";
676        /**
677         * Parameter used to limit the number of rows returned by a conversation list query
678         */
679        public static final String LIMIT = "limit";
680
681        /**
682         * Parameter used to control whether the this query a remote server.
683         */
684        public static final String USE_NETWORK = "use_network";
685
686        /**
687         * Parameter used to allow the caller to indicate desire to receive all notifications.
688         * (Including ones for user initiated actions)
689         */
690        public static final String ALL_NOTIFICATIONS = "all_notifications";
691
692        private ConversationListQueryParameters() {}
693    }
694
695    // We define a "folder" as anything that contains a list of conversations.
696    public static final String FOLDER_LIST_TYPE =
697            "vnd.android.cursor.dir/vnd.com.android.mail.folder";
698    public static final String FOLDER_TYPE =
699            "vnd.android.cursor.item/vnd.com.android.mail.folder";
700
701    public static final String[] FOLDERS_PROJECTION = {
702        FolderColumns._ID,
703        FolderColumns.PERSISTENT_ID,
704        FolderColumns.URI,
705        FolderColumns.NAME,
706        FolderColumns.HAS_CHILDREN,
707        FolderColumns.CAPABILITIES,
708        FolderColumns.SYNC_WINDOW,
709        FolderColumns.CONVERSATION_LIST_URI,
710        FolderColumns.CHILD_FOLDERS_LIST_URI,
711        FolderColumns.UNSEEN_COUNT,
712        FolderColumns.UNREAD_COUNT,
713        FolderColumns.TOTAL_COUNT,
714        FolderColumns.REFRESH_URI,
715        FolderColumns.SYNC_STATUS,
716        FolderColumns.LAST_SYNC_RESULT,
717        FolderColumns.TYPE,
718        FolderColumns.ICON_RES_ID,
719        FolderColumns.NOTIFICATION_ICON_RES_ID,
720        FolderColumns.BG_COLOR,
721        FolderColumns.FG_COLOR,
722        FolderColumns.LOAD_MORE_URI,
723        FolderColumns.HIERARCHICAL_DESC,
724        FolderColumns.LAST_MESSAGE_TIMESTAMP,
725        FolderColumns.PARENT_URI
726    };
727
728    public static final String[] FOLDERS_PROJECTION_WITH_UNREAD_SENDERS =
729            (new ImmutableList.Builder<String>()
730                    .addAll(ImmutableList.copyOf(FOLDERS_PROJECTION))
731                    .add(FolderColumns.UNREAD_SENDERS)
732                    .build().toArray(new String[0]));
733
734    public static final int FOLDER_ID_COLUMN = 0;
735    public static final int FOLDER_PERSISTENT_ID_COLUMN = 1;
736    public static final int FOLDER_URI_COLUMN = 2;
737    public static final int FOLDER_NAME_COLUMN = 3;
738    public static final int FOLDER_HAS_CHILDREN_COLUMN = 4;
739    public static final int FOLDER_CAPABILITIES_COLUMN = 5;
740    public static final int FOLDER_SYNC_WINDOW_COLUMN = 6;
741    public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 7;
742    public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 8;
743    public static final int FOLDER_UNSEEN_COUNT_COLUMN = 9;
744    public static final int FOLDER_UNREAD_COUNT_COLUMN = 10;
745    public static final int FOLDER_TOTAL_COUNT_COLUMN = 11;
746    public static final int FOLDER_REFRESH_URI_COLUMN = 12;
747    public static final int FOLDER_SYNC_STATUS_COLUMN = 13;
748    public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 14;
749    public static final int FOLDER_TYPE_COLUMN = 15;
750    public static final int FOLDER_ICON_RES_ID_COLUMN = 16;
751    public static final int FOLDER_NOTIFICATION_ICON_RES_ID_COLUMN = 17;
752    public static final int FOLDER_BG_COLOR_COLUMN = 18;
753    public static final int FOLDER_FG_COLOR_COLUMN = 19;
754    public static final int FOLDER_LOAD_MORE_URI_COLUMN = 20;
755    public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 21;
756    public static final int FOLDER_LAST_MESSAGE_TIMESTAMP_COLUMN = 22;
757    public static final int FOLDER_PARENT_URI_COLUMN = 23;
758
759    public static final class FolderType {
760        /** A user defined label. */
761        public static final int DEFAULT = 1 << 0;
762        /** A system defined inbox */
763        public static final int INBOX = 1 << 1;
764        /** A system defined containing mails to be edited before sending. */
765        public static final int DRAFT = 1 << 2;
766        /** A system defined folder containing mails <b>to be</b> sent */
767        public static final int OUTBOX = 1 << 3;
768        /** A system defined folder containing sent mails */
769        public static final int SENT = 1 << 4;
770        /** A system defined trash folder */
771        public static final int TRASH = 1 << 5;
772        /** A system defined spam folder */
773        public static final int SPAM = 1 << 6;
774        /** A system defined starred folder */
775        public static final int STARRED = 1 << 7;
776        /** Any other system label that we do not have a specific name for. */
777        public static final int OTHER_PROVIDER_FOLDER = 1 << 8;
778        /** All mail folder */
779        public static final int ALL_MAIL = 1 << 9;
780        /** Gmail's inbox sections */
781        public static final int INBOX_SECTION = 1 << 10;
782        /** A system defined unread folder */
783        public static final int UNREAD = 1 << 11;
784        /** A "fake" search folder */
785        public static final int SEARCH = 1 << 12;
786    }
787
788    public static final class FolderCapabilities {
789        public static final int SYNCABLE = 0x0001;
790        public static final int PARENT = 0x0002;
791        // FEEL FREE TO USE 0x0004 - was previous CAN_HOLD_MAIL but that was true for all
792        // folders so we removed that value
793        public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
794         /**
795         * For accounts that support archive, this will indicate that this folder supports
796         * the archive functionality.
797         */
798        public static final int ARCHIVE = 0x0010;
799
800        /**
801         * This will indicated that this folder supports the delete functionality.
802         */
803        public static final int DELETE = 0x0020;
804
805        /**
806         * For accounts that support report spam, this will indicate that this folder supports
807         * the report spam functionality.
808         */
809        public static final int REPORT_SPAM = 0x0040;
810
811        /**
812         * For accounts that support report spam, this will indicate that this folder supports
813         * the mark not spam functionality.
814         */
815        public static final int MARK_NOT_SPAM = 0x0080;
816
817        /**
818         * For accounts that support mute, this will indicate if a mute is performed from within
819         * this folder, the action is destructive.
820         */
821        public static final int DESTRUCTIVE_MUTE = 0x0100;
822
823        /**
824         * Indicates that a folder supports settings (sync lookback, etc.)
825         */
826        public static final int SUPPORTS_SETTINGS = 0x0200;
827        /**
828         * All the messages in this folder are important.
829         */
830        public static final int ONLY_IMPORTANT = 0x0400;
831        /**
832         * Deletions in this folder can't be undone (could include archive if desirable)
833         */
834        public static final int DELETE_ACTION_FINAL = 0x0800;
835        /**
836         * This folder is virtual, i.e. contains conversations potentially pulled from other
837         * folders, potentially even from different accounts.  Examples might be a "starred"
838         * folder, or an "unread" folder (per account or provider-wide)
839         */
840        public static final int IS_VIRTUAL = 0x1000;
841
842        /**
843         * For accounts that support report phishing, this will indicate that this folder supports
844         * the report phishing functionality.
845         */
846        public static final int REPORT_PHISHING = 0x2000;
847
848        /**
849         * The flag indicates that the user has the ability to move conversations
850         * from this folder.
851         */
852        public static final int ALLOWS_REMOVE_CONVERSATION = 0x4000;
853
854        /**
855         * The flag indicates that the user has the ability to move conversations to or from this
856         * Folder in the same operation as other Folder changes (usually through
857         * {@link com.android.mail.ui.MultiFoldersSelectionDialog}).
858         */
859        public static final int MULTI_MOVE = 0x8000;
860
861        /**
862         * This flag indicates that a conversation may be moved from this folder into the account's
863         * inbox.
864         */
865        public static final int ALLOWS_MOVE_TO_INBOX = 0x10000;
866
867        /**
868         * For folders that typically represent outgoing mail, this indicates the client should
869         * display recipients rather than the standard list of senders.
870         */
871        public static final int SHOW_RECIPIENTS = 0x20000;
872    }
873
874    public static final class FolderColumns implements BaseColumns {
875        /**
876         * This string column contains an id for the folder that is constant across devices, or
877         * null if there is no constant id.
878         */
879        public static final String PERSISTENT_ID = "persistentId";
880        /**
881         * This string column contains the uri of the folder.
882         */
883        public static final String URI = "folderUri";
884        /**
885         * This string column contains the human visible name for the folder.
886         */
887        public static final String NAME = "name";
888        /**
889         * This int column represents the capabilities of the folder specified by
890         * FolderCapabilities flags.
891         */
892        public static final String CAPABILITIES = "capabilities";
893        /**
894         * This int column represents whether or not this folder has any
895         * child folders.
896         */
897        public static final String HAS_CHILDREN = "hasChildren";
898        /**
899         * This int column represents how large the sync window is.
900         */
901        public static final String SYNC_WINDOW = "syncWindow";
902        /**
903         * This string column contains the content provider uri to return the
904         * list of conversations for this folder.
905         */
906        public static final String CONVERSATION_LIST_URI = "conversationListUri";
907        /**
908         * This string column contains the content provider uri to return the
909         * list of child folders of this folder.
910         */
911        public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
912        /**
913         * This int column contains the current unseen count for the folder, if known.
914         */
915        public static final String UNSEEN_COUNT = "unseenCount";
916        /**
917         * This int column contains the current unread count for the folder.
918         */
919        public static final String UNREAD_COUNT = "unreadCount";
920
921        public static final String TOTAL_COUNT = "totalCount";
922        /**
923         * This string column contains the content provider uri to force a
924         * refresh of this folder.
925         */
926        public static final  String REFRESH_URI = "refreshUri";
927        /**
928         * This int column contains current sync status of the folder; some combination of the
929         * SyncStatus bits defined above
930         */
931        public static final String SYNC_STATUS  = "syncStatus";
932        /**
933         * This int column contains the sync status of the last sync attempt; one of the
934         * LastSyncStatus values defined above
935         */
936        public static final String LAST_SYNC_RESULT  = "lastSyncResult";
937        /**
938         * This int column contains the icon res id for this folder, or 0 if there is none.
939         */
940        public static final String ICON_RES_ID = "iconResId";
941        /**
942         * This int column contains the notification icon res id for this folder, or 0 if there is
943         * none.
944         */
945        public static final String NOTIFICATION_ICON_RES_ID = "notificationIconResId";
946        /**
947         * This int column contains the type of the folder. Zero is default.
948         */
949        public static final String TYPE = "type";
950        /**
951         * String representing the integer background color associated with this
952         * folder, or null.
953         */
954        public static final String BG_COLOR = "bgColor";
955        /**
956         * String representing the integer of the foreground color associated
957         * with this folder, or null.
958         */
959        public static final String FG_COLOR = "fgColor";
960        /**
961         * String with the content provider Uri used to request more items in the folder, or null.
962         */
963        public static final String LOAD_MORE_URI = "loadMoreUri";
964
965        /**
966         * Possibly empty string that describes the full hierarchy of a folder
967         * along with its name.
968         */
969        public static final String HIERARCHICAL_DESC = "hierarchicalDesc";
970
971        /**
972         * The timestamp of the last message received in this folder.
973         */
974        public static final String LAST_MESSAGE_TIMESTAMP = "lastMessageTimestamp";
975
976        /**
977         * The URI, possibly null, of the parent folder.
978         */
979        public static final String PARENT_URI = "parentUri";
980
981        /**
982         * A string of unread senders sorted by date, so we don't have to fetch this in multiple
983         * queries
984         */
985        public static final String UNREAD_SENDERS = "unreadSenders";
986
987        public FolderColumns() {}
988    }
989
990    // We define a "folder" as anything that contains a list of conversations.
991    public static final String CONVERSATION_LIST_TYPE =
992            "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
993    public static final String CONVERSATION_TYPE =
994            "vnd.android.cursor.item/vnd.com.android.mail.conversation";
995
996
997    public static final String[] CONVERSATION_PROJECTION = {
998        BaseColumns._ID,
999        ConversationColumns.URI,
1000        ConversationColumns.MESSAGE_LIST_URI,
1001        ConversationColumns.SUBJECT,
1002        ConversationColumns.SNIPPET,
1003        ConversationColumns.CONVERSATION_INFO,
1004        ConversationColumns.DATE_RECEIVED_MS,
1005        ConversationColumns.HAS_ATTACHMENTS,
1006        ConversationColumns.NUM_MESSAGES,
1007        ConversationColumns.NUM_DRAFTS,
1008        ConversationColumns.SENDING_STATE,
1009        ConversationColumns.PRIORITY,
1010        ConversationColumns.READ,
1011        ConversationColumns.SEEN,
1012        ConversationColumns.STARRED,
1013        ConversationColumns.RAW_FOLDERS,
1014        ConversationColumns.FLAGS,
1015        ConversationColumns.PERSONAL_LEVEL,
1016        ConversationColumns.SPAM,
1017        ConversationColumns.PHISHING,
1018        ConversationColumns.MUTED,
1019        ConversationColumns.COLOR,
1020        ConversationColumns.ACCOUNT_URI,
1021        ConversationColumns.SENDER_INFO,
1022        ConversationColumns.CONVERSATION_BASE_URI,
1023        ConversationColumns.REMOTE,
1024        ConversationColumns.ATTACHMENT_PREVIEW_URI0,
1025        ConversationColumns.ATTACHMENT_PREVIEW_URI1,
1026        ConversationColumns.ATTACHMENT_PREVIEW_STATES,
1027        ConversationColumns.ATTACHMENT_PREVIEWS_COUNT,
1028        ConversationColumns.ORDER_KEY
1029    };
1030
1031    /**
1032     * This integer corresponds to the number of rows of queries that specify the
1033     * {@link UIProvider#CONVERSATION_PROJECTION} projection will fit in a single
1034     * {@link android.database.CursorWindow}
1035     */
1036    public static final int CONVERSATION_PROJECTION_QUERY_CURSOR_WINDOW_LIMIT = 1500;
1037
1038    // These column indexes only work when the caller uses the
1039    // default CONVERSATION_PROJECTION defined above.
1040    public static final int CONVERSATION_ID_COLUMN = 0;
1041    public static final int CONVERSATION_URI_COLUMN = 1;
1042    public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
1043    public static final int CONVERSATION_SUBJECT_COLUMN = 3;
1044    public static final int CONVERSATION_SNIPPET_COLUMN = 4;
1045    public static final int CONVERSATION_INFO_COLUMN = 5;
1046    public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
1047    public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
1048    public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
1049    public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
1050    public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
1051    public static final int CONVERSATION_PRIORITY_COLUMN = 11;
1052    public static final int CONVERSATION_READ_COLUMN = 12;
1053    public static final int CONVERSATION_SEEN_COLUMN = 13;
1054    public static final int CONVERSATION_STARRED_COLUMN = 14;
1055    public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 15;
1056    public static final int CONVERSATION_FLAGS_COLUMN = 16;
1057    public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 17;
1058    public static final int CONVERSATION_IS_SPAM_COLUMN = 18;
1059    public static final int CONVERSATION_IS_PHISHING_COLUMN = 19;
1060    public static final int CONVERSATION_MUTED_COLUMN = 20;
1061    public static final int CONVERSATION_COLOR_COLUMN = 21;
1062    public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 22;
1063    public static final int CONVERSATION_SENDER_INFO_COLUMN = 23;
1064    public static final int CONVERSATION_BASE_URI_COLUMN = 24;
1065    public static final int CONVERSATION_REMOTE_COLUMN = 25;
1066    public static final int CONVERSATION_ATTACHMENT_PREVIEW_URI0_COLUMN = 26;
1067    public static final int CONVERSATION_ATTACHMENT_PREVIEW_URI1_COLUMN = 27;
1068    public static final int CONVERSATION_ATTACHMENT_PREVIEW_STATES_COLUMN = 28;
1069    public static final int CONVERSATION_ATTACHMENT_PREVIEWS_COUNT_COLUMN = 29;
1070    public static final int CONVERSATION_ORDER_KEY_COLUMN = 30;
1071
1072    public static final class ConversationSendingState {
1073        public static final int OTHER = 0;
1074        public static final int QUEUED = 1;
1075        public static final int SENDING = 2;
1076        public static final int SENT = 3;
1077        public static final int RETRYING = 4;
1078        public static final int SEND_ERROR = -1;
1079    }
1080
1081    public static final class ConversationPriority {
1082        public static final int DEFAULT = 0;
1083        public static final int IMPORTANT = 1;
1084        public static final int LOW = 0;
1085        public static final int HIGH = 1;
1086    }
1087
1088    public static final class ConversationPersonalLevel {
1089        public static final int NOT_TO_ME = 0;
1090        public static final int TO_ME_AND_OTHERS = 1;
1091        public static final int ONLY_TO_ME = 2;
1092    }
1093
1094    public static final class ConversationFlags {
1095        public static final int REPLIED = 1<<2;
1096        public static final int FORWARDED = 1<<3;
1097        public static final int CALENDAR_INVITE = 1<<4;
1098    }
1099
1100    public static final class ConversationPhishing {
1101        public static final int NOT_PHISHING = 0;
1102        public static final int PHISHING = 1;
1103    }
1104
1105    /**
1106     * Names of columns representing fields in a Conversation.
1107     */
1108    public static final class ConversationColumns {
1109        public static final String URI = "conversationUri";
1110        /**
1111         * This string column contains the content provider uri to return the
1112         * list of messages for this conversation.
1113         * The cursor returned by this query can return a {@link android.os.Bundle}
1114         * from a call to {@link android.database.Cursor#getExtras()}.  This Bundle may have
1115         * values with keys listed in {@link CursorExtraKeys}
1116         */
1117        public static final String MESSAGE_LIST_URI = "messageListUri";
1118        /**
1119         * This string column contains the subject string for a conversation.
1120         */
1121        public static final String SUBJECT = "subject";
1122        /**
1123         * This string column contains the snippet string for a conversation.
1124         */
1125        public static final String SNIPPET = "snippet";
1126        /**
1127         * @deprecated
1128         */
1129        @Deprecated
1130        public static final String SENDER_INFO = "senderInfo";
1131        /**
1132         * This blob column contains the byte-array representation of the Parceled
1133         * ConversationInfo object for a conversation.
1134         *
1135         * @deprecated providers should implement
1136         * {@link ConversationCursorCommand#COMMAND_GET_CONVERSATION_INFO} instead.
1137         */
1138        @Deprecated
1139        public static final String CONVERSATION_INFO = "conversationInfo";
1140        /**
1141         * This long column contains the time in ms of the latest update to a
1142         * conversation.
1143         */
1144        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
1145
1146        /**
1147         * This boolean column contains whether any messages in this conversation
1148         * have attachments.
1149         */
1150        public static final String HAS_ATTACHMENTS = "hasAttachments";
1151
1152        /**
1153         * This int column contains the number of messages in this conversation.
1154         * For unthreaded, this will always be 1.
1155         */
1156        public static final String NUM_MESSAGES = "numMessages";
1157
1158        /**
1159         * This int column contains the number of drafts associated with this
1160         * conversation.
1161         */
1162        public static final String NUM_DRAFTS = "numDrafts";
1163
1164        /**
1165         * This int column contains the state of drafts and replies associated
1166         * with this conversation. Use ConversationSendingState to interpret
1167         * this field.
1168         */
1169        public static final String SENDING_STATE = "sendingState";
1170
1171        /**
1172         * This int column contains the priority of this conversation. Use
1173         * ConversationPriority to interpret this field.
1174         */
1175        public static final String PRIORITY = "priority";
1176
1177        /**
1178         * This int column indicates whether the conversation has been read
1179         */
1180        public static final String READ = "read";
1181
1182        /**
1183         * This int column indicates whether the conversation has been seen
1184         */
1185        public static final String SEEN = "seen";
1186
1187        /**
1188         * This int column indicates whether the conversation has been starred
1189         */
1190        public static final String STARRED = "starred";
1191
1192        /**
1193         * This blob column contains the marshalled form of a Parceled
1194         * {@FolderList} object. Ideally, only ever use this for
1195         * rendering the folder list for a conversation.
1196         *
1197         * @deprecated providers should implement
1198         * {@link ConversationCursorCommand#COMMAND_GET_RAW_FOLDERS} instead.
1199         */
1200        @Deprecated
1201        public static final String RAW_FOLDERS = "rawFolders";
1202        public static final String FLAGS = "conversationFlags";
1203        /**
1204         * This int column indicates the personal level of a conversation per
1205         * {@link ConversationPersonalLevel}.
1206         */
1207        public static final String PERSONAL_LEVEL = "personalLevel";
1208
1209        /**
1210         * This int column indicates whether the conversation is marked spam.
1211         */
1212        public static final String SPAM = "spam";
1213
1214        /**
1215         * This int column indicates whether the conversation is marked phishing.
1216         */
1217        public static final String PHISHING = "phishing";
1218
1219        /**
1220         * This int column indicates whether the conversation was muted.
1221         */
1222        public static final String MUTED = "muted";
1223
1224        /**
1225         * This int column contains a color for the conversation (used in Email only)
1226         */
1227        public static final String COLOR = "color";
1228
1229        /**
1230         * This String column contains the Uri for this conversation's account
1231         */
1232        public static final String ACCOUNT_URI = "accountUri";
1233        /**
1234         * This int column indicates whether a conversation is remote (non-local), and would require
1235         * a network fetch to load.
1236         */
1237        public static final String REMOTE = "remote";
1238        /**
1239         * This int column indicates whether the conversation was displayed on the UI and the
1240         * user got a chance to read it. The UI does not read this value, it is meant only to
1241         * write the status back to the provider. As a result, it is not available in the
1242         * {@link Conversation} object.
1243         */
1244        public static final String VIEWED = "viewed";
1245        /**
1246         * This String column contains the base uri for this conversation.  This uri can be used
1247         * when handling relative urls in the message content
1248         */
1249        public static final String CONVERSATION_BASE_URI = "conversationBaseUri";
1250
1251        /**
1252         * This string column contains the uri of the first attachment preview of the first unread
1253         * message, denoted by UNREAD_MESSAGE_ID.
1254         */
1255        public static final String ATTACHMENT_PREVIEW_URI0 = "attachmentPreviewUri0";
1256
1257        /**
1258         * This string column contains the uri of the second attachment preview of the first unread
1259         * message, denoted by UNREAD_MESSAGE_ID.
1260         */
1261        public static final String ATTACHMENT_PREVIEW_URI1 = "attachmentPreviewUri1";
1262
1263        /**
1264         * This int column contains the states of the attachment previews of the first unread
1265         * message, the same message used for the snippet. The states is a packed int,
1266         * where the first and second bits represent the SIMPLE and BEST state of the first
1267         * attachment preview, while the third and fourth bits represent those states for the
1268         * second attachment preview. For each bit, a one means that rendition of that attachment
1269         * preview is downloaded.
1270         */
1271        public static final String ATTACHMENT_PREVIEW_STATES = "attachmentPreviewStates";
1272
1273        /**
1274         * This int column contains the total count of images in the first unread message. The
1275         * total count may be higher than the number of ATTACHMENT_PREVIEW_URI columns.
1276         */
1277        public static final String ATTACHMENT_PREVIEWS_COUNT = "attachmentPreviewsCount";
1278
1279        /**
1280         * This long column contains the data that is used for ordering the result.
1281         */
1282        public static final String ORDER_KEY = "orderKey";
1283
1284        private ConversationColumns() {
1285        }
1286    }
1287
1288    public static final class ConversationCursorCommand {
1289
1290        public static final String COMMAND_RESPONSE_OK = "ok";
1291        public static final String COMMAND_RESPONSE_FAILED = "failed";
1292
1293        /**
1294         * Incoming bundles may include this key with an Integer bitfield value. See below for bit
1295         * values.
1296         */
1297        public static final String COMMAND_KEY_OPTIONS = "options";
1298
1299        /**
1300         * Clients must set this bit when the {@link Cursor#respond(Bundle)} call is being used to
1301         * fetch a {@link Parcelable}. It serves as a hint that this call requires the cursor
1302         * position to first safely be moved.
1303         */
1304        public static final int OPTION_MOVE_POSITION = 0x01;
1305
1306        /**
1307         * This bundle key has a boolean value: true to indicate that this cursor has been shown
1308         * to the user.
1309         * <p>
1310         * A provider that implements this command should include this key in its response with a
1311         * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
1312         */
1313        public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility";
1314
1315        /**
1316         * This key has a boolean value: true to indicate that this folder list is shown to the user
1317         * either on first call (launcher/widget/notification) or after switching from an existing
1318         * folder: Inbox -> Folder. Repeated calls are sent when switching back to the folder. Inbox
1319         * -> Folder -> Spam -> Folder will generate two calls to respond() with the value true for
1320         * "Folder".
1321         * <p>
1322         * A provider that implements this command should include the
1323         * {@link #COMMAND_KEY_SET_VISIBILITY} key in its response with a value of
1324         * {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. This is <b>always</b>
1325         * set with {@link #COMMAND_KEY_SET_VISIBILITY} because this is only set when the folder
1326         * list is made visible.
1327         */
1328        public static final String COMMAND_KEY_ENTERED_FOLDER = "enteredFolder";
1329
1330        /**
1331         * This key has an int value, indicating the position that the UI wants to notify the
1332         * provider that the data from a specified row is being shown to the user.
1333         * <p>
1334         * A provider that implements this command should include the
1335         * {@link #COMMAND_NOTIFY_CURSOR_UI_POSITION_CHANGE} key in its response with a value of
1336         * {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
1337         */
1338        public static final String COMMAND_NOTIFY_CURSOR_UI_POSITION_CHANGE = "uiPositionChange";
1339
1340        /**
1341         * Rather than jamming a {@link ConversationInfo} into a byte-array blob to be read out of
1342         * a cursor, providers can optionally implement this command to directly return the object
1343         * in a Bundle.
1344         * <p>
1345         * The requestor (UI code) will place a meaningless value in the request Bundle. The UI will
1346         * also move the cursor position to the desired place prior to calling respond(). Providers
1347         * should just use {@link Bundle#containsKey(String)} to check for this kind of request and
1348         * generate an object at the current cursor position.
1349         * <p>
1350         * A provider that implements this command should include the
1351         * {@link #COMMAND_GET_CONVERSATION_INFO} key in its response with a
1352         * {@link ConversationInfo} Parcelable object as its value.
1353         */
1354        public static final String COMMAND_GET_CONVERSATION_INFO =
1355                ConversationColumns.CONVERSATION_INFO;
1356
1357        /**
1358         * Rather than jamming a {@link FolderList} into a byte-array blob to be read out of
1359         * a cursor, providers can optionally implement this command to directly return the object
1360         * in a Bundle.
1361         * <p>
1362         * The requestor (UI code) will place a meaningless value in the request Bundle. The UI will
1363         * also move the cursor position to the desired place prior to calling respond(). Providers
1364         * should just use {@link Bundle#containsKey(String)} to check for this kind of request and
1365         * generate an object at the current cursor position.
1366         * <p>
1367         * A provider that implements this command should include the
1368         * {@link #COMMAND_GET_RAW_FOLDERS} key in its response with a
1369         * {@link FolderList} Parcelable object as its value.
1370         */
1371        public static final String COMMAND_GET_RAW_FOLDERS = ConversationColumns.RAW_FOLDERS;
1372
1373        private ConversationCursorCommand() {}
1374    }
1375
1376    /**
1377     * List of operations that can can be performed on a conversation. These operations are applied
1378     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1379     * where the conversation uri is specified, and the ContentValues specifies the operation to
1380     * be performed.
1381     * <p/>
1382     * The operation to be performed is specified in the ContentValues by
1383     * the {@link ConversationOperations#OPERATION_KEY}
1384     * <p/>
1385     * Note not all UI providers will support these operations.  {@link AccountCapabilities} can
1386     * be used to determine which operations are supported.
1387     */
1388    public static final class ConversationOperations {
1389        /**
1390         * ContentValues key used to specify the operation to be performed
1391         */
1392        public static final String OPERATION_KEY = "operation";
1393
1394        /**
1395         * Archive operation
1396         */
1397        public static final String ARCHIVE = "archive";
1398
1399        /**
1400         * Mute operation
1401         */
1402        public static final String MUTE = "mute";
1403
1404        /**
1405         * Report spam operation
1406         */
1407        public static final String REPORT_SPAM = "report_spam";
1408
1409        /**
1410         * Report not spam operation
1411         */
1412        public static final String REPORT_NOT_SPAM = "report_not_spam";
1413
1414        /**
1415         * Report phishing operation
1416         */
1417        public static final String REPORT_PHISHING = "report_phishing";
1418
1419        /**
1420         * Discard drafts operation
1421         */
1422        public static final String DISCARD_DRAFTS = "discard_drafts";
1423
1424        /**
1425         * Update conversation folder(s) operation. ContentValues passed as part
1426         * of this update will be of the format (FOLDERS_UPDATED, csv of updated
1427         * folders) where the comma separated values of the updated folders will
1428         * be of the format: folderuri/ADD_VALUE. ADD_VALUE will be true if the
1429         * folder was added, false if it was removed.
1430         */
1431        public static final String FOLDERS_UPDATED = "folders_updated";
1432        public static final String FOLDERS_UPDATED_SPLIT_PATTERN = ",";
1433
1434        public static final class Parameters {
1435            /**
1436             * Boolean indicating whether the undo for this operation should be suppressed
1437             */
1438            public static final String SUPPRESS_UNDO = "suppress_undo";
1439
1440            private Parameters() {}
1441        }
1442
1443        private ConversationOperations() {
1444        }
1445    }
1446
1447    /**
1448     * Methods that can be "called" using the account uri, through
1449     * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)}
1450     * Note, the arg parmateter of call should be the account uri.
1451     */
1452    public static final class AccountCallMethods {
1453        /**
1454         * Save message method.  The Bundle for the call to
1455         * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the
1456         * columns specified in {@link MessageColumns}, and if this is a save for an existing
1457         * message, an entry for the {@link MessageColumns#URI} should reference the existing
1458         * message
1459         *
1460         * The Bundle returned will contain the message uri in the returned bundled with the
1461         * {@link MessageColumns#URI} key.
1462         */
1463        public static final String SAVE_MESSAGE = "save_message";
1464
1465        /**
1466         * Send message method.  The Bundle for the call to
1467         * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the
1468         * columns specified in {@link MessageColumns}, and if this is a send of an existing
1469         * message, an entry for the {@link MessageColumns#URI} should reference the existing
1470         * message
1471         *
1472         * The Bundle returned will contain the message uri in the returned bundled with the
1473         * {@link MessageColumns#URI} key.
1474         */
1475        public static final String SEND_MESSAGE = "send_message";
1476
1477        /**
1478         * Change account method.  The Bundle for the call to
1479         * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the
1480         * columns specified in {@link SetCurrentAccountColumns}
1481         *
1482         * The Bundle returned will be empty.
1483         */
1484        public static final String SET_CURRENT_ACCOUNT = "set_current_account";
1485
1486        private AccountCallMethods() {}
1487    }
1488
1489    /**
1490     * Keys used for parameters to {@link AccountCallMethods#SEND_MESSAGE} or
1491     * {@link AccountCallMethods#SAVE_MESSAGE} methods.
1492     */
1493    public static final class SendOrSaveMethodParamKeys {
1494        /**
1495         * Bundle key used to store any opened file descriptors.
1496         * The keys of this Bundle are the contentUri for each attachment, and the
1497         * values are {@link android.os.ParcelFileDescriptor} objects.
1498         */
1499        public static final String OPENED_FD_MAP = "opened_fds";
1500
1501        private SendOrSaveMethodParamKeys() {}
1502    }
1503
1504    public static final class DraftType {
1505        public static final int NOT_A_DRAFT = 0;
1506        public static final int COMPOSE = 1;
1507        public static final int REPLY = 2;
1508        public static final int REPLY_ALL = 3;
1509        public static final int FORWARD = 4;
1510
1511        private DraftType() {}
1512    }
1513
1514    /**
1515     * Class for the enum values to determine whether this
1516     * string should be displayed as a high priority warning
1517     * or a low priority warning. The current design has
1518     * high priority warnings in red while low priority warnings
1519     * are grey.
1520     */
1521    public static final class SpamWarningLevel {
1522        public static final int NO_WARNING = 0;
1523        public static final int LOW_WARNING = 1;
1524        public static final int HIGH_WARNING = 2;
1525
1526        private SpamWarningLevel() {}
1527    }
1528
1529    /**
1530     * Class for the enum values to determine which type
1531     * of link to show in the spam warning.
1532     */
1533    public static final class SpamWarningLinkType {
1534        public static final int NO_LINK = 0;
1535        public static final int IGNORE_WARNING = 1;
1536        public static final int REPORT_PHISHING = 2;
1537
1538        private SpamWarningLinkType() {}
1539    }
1540
1541    public static final String[] MESSAGE_PROJECTION = {
1542        BaseColumns._ID,
1543        MessageColumns.SERVER_ID,
1544        MessageColumns.URI,
1545        MessageColumns.CONVERSATION_ID,
1546        MessageColumns.SUBJECT,
1547        MessageColumns.SNIPPET,
1548        MessageColumns.FROM,
1549        MessageColumns.TO,
1550        MessageColumns.CC,
1551        MessageColumns.BCC,
1552        MessageColumns.REPLY_TO,
1553        MessageColumns.DATE_RECEIVED_MS,
1554        MessageColumns.BODY_HTML,
1555        MessageColumns.BODY_TEXT,
1556        MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
1557        MessageColumns.REF_MESSAGE_ID,
1558        MessageColumns.DRAFT_TYPE,
1559        MessageColumns.APPEND_REF_MESSAGE_CONTENT,
1560        MessageColumns.HAS_ATTACHMENTS,
1561        MessageColumns.ATTACHMENT_LIST_URI,
1562        MessageColumns.ATTACHMENT_BY_CID_URI,
1563        MessageColumns.MESSAGE_FLAGS,
1564        MessageColumns.ALWAYS_SHOW_IMAGES,
1565        MessageColumns.READ,
1566        MessageColumns.SEEN,
1567        MessageColumns.STARRED,
1568        MessageColumns.QUOTE_START_POS,
1569        MessageColumns.ATTACHMENTS,
1570        MessageColumns.CUSTOM_FROM_ADDRESS,
1571        MessageColumns.MESSAGE_ACCOUNT_URI,
1572        MessageColumns.EVENT_INTENT_URI,
1573        MessageColumns.SPAM_WARNING_STRING,
1574        MessageColumns.SPAM_WARNING_LEVEL,
1575        MessageColumns.SPAM_WARNING_LINK_TYPE,
1576        MessageColumns.VIA_DOMAIN,
1577        MessageColumns.SENDING_STATE,
1578        MessageColumns.CLIPPED,
1579        MessageColumns.PERMALINK
1580    };
1581
1582    /** Separates attachment info parts in strings in a message. */
1583    @Deprecated
1584    public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
1585    public static final String MESSAGE_LIST_TYPE =
1586            "vnd.android.cursor.dir/vnd.com.android.mail.message";
1587    public static final String MESSAGE_TYPE =
1588            "vnd.android.cursor.item/vnd.com.android.mail.message";
1589
1590    public static final int MESSAGE_ID_COLUMN = 0;
1591    public static final int MESSAGE_SERVER_ID_COLUMN = 1;
1592    public static final int MESSAGE_URI_COLUMN = 2;
1593    public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3;
1594    public static final int MESSAGE_SUBJECT_COLUMN = 4;
1595    public static final int MESSAGE_SNIPPET_COLUMN = 5;
1596    public static final int MESSAGE_FROM_COLUMN = 6;
1597    public static final int MESSAGE_TO_COLUMN = 7;
1598    public static final int MESSAGE_CC_COLUMN = 8;
1599    public static final int MESSAGE_BCC_COLUMN = 9;
1600    public static final int MESSAGE_REPLY_TO_COLUMN = 10;
1601    public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
1602    public static final int MESSAGE_BODY_HTML_COLUMN = 12;
1603    public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
1604    public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
1605    public static final int MESSAGE_REF_MESSAGE_URI_COLUMN = 15;
1606    public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
1607    public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
1608    public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
1609    public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
1610    public static final int MESSAGE_ATTACHMENT_BY_CID_URI_COLUMN = 20;
1611    public static final int MESSAGE_FLAGS_COLUMN = 21;
1612    public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 22;
1613    public static final int MESSAGE_READ_COLUMN = 23;
1614    public static final int MESSAGE_SEEN_COLUMN = 24;
1615    public static final int MESSAGE_STARRED_COLUMN = 25;
1616    public static final int QUOTED_TEXT_OFFSET_COLUMN = 26;
1617    public static final int MESSAGE_ATTACHMENTS_COLUMN = 27;
1618    public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 28;
1619    public static final int MESSAGE_ACCOUNT_URI_COLUMN = 29;
1620    public static final int MESSAGE_EVENT_INTENT_COLUMN = 30;
1621    public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 31;
1622    public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 32;
1623    public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 33;
1624    public static final int MESSAGE_VIA_DOMAIN_COLUMN = 34;
1625    public static final int MESSAGE_SENDING_STATE_COLUMN = 35;
1626    public static final int MESSAGE_CLIPPED_COLUMN = 36;
1627    public static final int MESSAGE_PERMALINK_COLUMN = 37;
1628
1629    public static final class CursorStatus {
1630        // The cursor is actively loading more data
1631        public static final int LOADING =      1 << 0;
1632
1633        // The cursor is currently not loading more data, but more data may be available
1634        public static final int LOADED =       1 << 1;
1635
1636        // An error occured while loading data
1637        public static final int ERROR =        1 << 2;
1638
1639        // The cursor is loaded, and there will be no more data
1640        public static final int COMPLETE =     1 << 3;
1641
1642        public static boolean isWaitingForResults(int cursorStatus) {
1643            return 0 != (cursorStatus & LOADING);
1644        }
1645    }
1646
1647
1648    public static final class CursorExtraKeys {
1649        /**
1650         * This integer column contains the staus of the message cursor.  The value will be
1651         * one defined in {@link CursorStatus}.
1652         */
1653        public static final String EXTRA_STATUS = "cursor_status";
1654
1655        /**
1656         * Used for finding the cause of an error.
1657         * TODO: define these values
1658         */
1659        public static final String EXTRA_ERROR = "cursor_error";
1660
1661
1662        /**
1663         * This integer column contains the total message count for this folder.
1664         */
1665        public static final String EXTRA_TOTAL_COUNT = "cursor_total_count";
1666    }
1667
1668    public static final class AccountCursorExtraKeys {
1669        /**
1670         * This integer column contains the staus of the account cursor.  The value will be
1671         * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully
1672         * initialized
1673         */
1674        public static final String ACCOUNTS_LOADED = "accounts_loaded";
1675    }
1676
1677
1678    public static final class MessageFlags {
1679        public static final int REPLIED =           1 << 2;
1680        public static final int FORWARDED =         1 << 3;
1681        public static final int CALENDAR_INVITE =   1 << 4;
1682    }
1683
1684    public static final class MessageColumns {
1685        /**
1686         * This string column contains a content provider URI that points to this single message.
1687         */
1688        public static final String URI = "messageUri";
1689        /**
1690         * This string column contains a server-assigned ID for this message.
1691         */
1692        public static final String SERVER_ID = "serverMessageId";
1693        public static final String CONVERSATION_ID = "conversationId";
1694        /**
1695         * This string column contains the subject of a message.
1696         */
1697        public static final String SUBJECT = "subject";
1698        /**
1699         * This string column contains a snippet of the message body.
1700         */
1701        public static final String SNIPPET = "snippet";
1702        /**
1703         * This string column contains the single email address (and optionally name) of the sender.
1704         */
1705        public static final String FROM = "fromAddress";
1706        /**
1707         * This string column contains a comma-delimited list of "To:" recipient email addresses.
1708         */
1709        public static final String TO = "toAddresses";
1710        /**
1711         * This string column contains a comma-delimited list of "CC:" recipient email addresses.
1712         */
1713        public static final String CC = "ccAddresses";
1714        /**
1715         * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
1716         * This value will be null for incoming messages.
1717         */
1718        public static final String BCC = "bccAddresses";
1719        /**
1720         * This string column contains the single email address (and optionally name) of the
1721         * sender's reply-to address.
1722         */
1723        public static final String REPLY_TO = "replyToAddress";
1724        /**
1725         * This long column contains the timestamp (in millis) of receipt of the message.
1726         */
1727        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
1728        /**
1729         * This string column contains the HTML form of the message body, if available. If not,
1730         * a provider must populate BODY_TEXT.
1731         */
1732        public static final String BODY_HTML = "bodyHtml";
1733        /**
1734         * This string column contains the plaintext form of the message body, if HTML is not
1735         * otherwise available. If HTML is available, this value should be left empty (null).
1736         */
1737        public static final String BODY_TEXT = "bodyText";
1738        public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
1739        /**
1740         * This string column contains an opaque string used by the sendMessage api.
1741         */
1742        public static final String REF_MESSAGE_ID = "refMessageId";
1743        /**
1744         * This integer column contains the type of this draft, or zero (0) if this message is not a
1745         * draft. See {@link DraftType} for possible values.
1746         */
1747        public static final String DRAFT_TYPE = "draftType";
1748        /**
1749         * This boolean column indicates whether an outgoing message should trigger special quoted
1750         * text processing upon send. The value should default to zero (0) for protocols that do
1751         * not support or require this flag, and for all incoming messages.
1752         */
1753        public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
1754        /**
1755         * This boolean column indicates whether a message has attachments. The list of attachments
1756         * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
1757         */
1758        public static final String HAS_ATTACHMENTS = "hasAttachments";
1759        /**
1760         * This string column contains the content provider URI for the list of
1761         * attachments associated with this message.<br>
1762         * <br>
1763         * The resulting cursor MUST have the columns as defined in
1764         * {@link com.android.ex.photo.provider.PhotoContract.PhotoViewColumns}.
1765         */
1766        public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
1767        /**
1768         * This string column contains the content provider URI for the details of an attachment
1769         * associated with this message. (CID to be appended at the time the URI is used)
1770         */
1771        public static final String ATTACHMENT_BY_CID_URI = "attachmentByCidUri";
1772        /**
1773         * This long column is a bit field of flags defined in {@link MessageFlags}.
1774         */
1775        public static final String MESSAGE_FLAGS = "messageFlags";
1776        /**
1777         * This integer column represents whether the user has specified that images should always
1778         * be shown.  The value of "1" indicates that the user has specified that images should be
1779         * shown, while the value of "0" indicates that the user should be prompted before loading
1780         * any external images.
1781         */
1782        public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
1783
1784        /**
1785         * This boolean column indicates whether the message has been read
1786         */
1787        public static final String READ = "read";
1788
1789        /**
1790         * This boolean column indicates whether the message has been seen
1791         */
1792        public static final String SEEN = "seen";
1793
1794        /**
1795         * This boolean column indicates whether the message has been starred
1796         */
1797        public static final String STARRED = "starred";
1798
1799        /**
1800         * This integer column represents the offset in the message of quoted
1801         * text. If include_quoted_text is zero, the value contained in this
1802         * column is invalid.
1803         */
1804        public static final String QUOTE_START_POS = "quotedTextStartPos";
1805
1806        /**
1807         * This string columns contains a JSON array of serialized {@link Attachment} objects.
1808         */
1809        public static final String ATTACHMENTS = "attachments";
1810        public static final String CUSTOM_FROM_ADDRESS = "customFrom";
1811        /**
1812         * Uri of the account associated with this message. Except in the case
1813         * of showing a combined view, this column is almost always empty.
1814         */
1815        public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri";
1816        /**
1817         * Intent Uri to launch when the user wants to view an event in their calendar, or null.
1818         */
1819        public static final String EVENT_INTENT_URI = "eventIntentUri";
1820        /**
1821         * This string column contains the string for the spam
1822         * warning of this message, or null if there is no spam warning for the message.
1823         */
1824        public static final String SPAM_WARNING_STRING = "spamWarningString";
1825        /**
1826         * This integer column contains the level of spam warning of this message,
1827         * or zero (0) if this message does not have a warning level.
1828         * See {@link SpamWarningLevel} for possible values.
1829         */
1830        public static final String SPAM_WARNING_LEVEL = "spamWarningLevel";
1831        /**
1832         * This integer column contains the type of link for the spam warning
1833         * of this message, or zero (0) if this message does not have a link type.
1834         * See {@link SpamWarningLinkType} for possible values.
1835         */
1836        public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType";
1837        /**
1838         * This string column contains the string for the via domain
1839         * to be included if this message was sent via an alternate
1840         * domain. This column should be null if no via domain exists.
1841         */
1842        public static final String VIA_DOMAIN = "viaDomain";
1843        /**
1844         * This int column indicates whether the message is an outgoing message in the process
1845         * of being sent. See {@link com.android.mail.providers.UIProvider.ConversationSendingState}
1846         */
1847        public static final String SENDING_STATE = "sendingState";
1848        /**
1849         * This boolean column indicates whether the message body has been clipped.
1850         */
1851        public static final String CLIPPED = "clipped";
1852        /**
1853         * This string column contains the permalink value of the conversation
1854         * for which this message belongs or null if one does not exist.
1855         */
1856        public static final String PERMALINK = "permalink";
1857
1858        private MessageColumns() {}
1859    }
1860
1861     public static final class SetCurrentAccountColumns {
1862        /**
1863         * This column contains the Account object Parcelable.
1864         */
1865        public static final String ACCOUNT = "account";
1866
1867        private SetCurrentAccountColumns() {}
1868    }
1869
1870    /**
1871     * List of operations that can can be performed on a message. These operations are applied
1872     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1873     * where the message uri is specified, and the ContentValues specifies the operation to
1874     * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT)
1875     * <p/>
1876     * Note not all UI providers will support these operations.
1877     */
1878    public static final class MessageOperations {
1879        /**
1880         * Respond to a calendar invitation
1881         */
1882        public static final String RESPOND_COLUMN = "respond";
1883
1884        public static final int RESPOND_ACCEPT = 1;
1885        public static final int RESPOND_TENTATIVE = 2;
1886        public static final int RESPOND_DECLINE = 3;
1887
1888        private MessageOperations() {
1889        }
1890    }
1891
1892    public static final String ATTACHMENT_LIST_TYPE =
1893            "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
1894    public static final String ATTACHMENT_TYPE =
1895            "vnd.android.cursor.item/vnd.com.android.mail.attachment";
1896
1897    public static final String[] ATTACHMENT_PROJECTION = {
1898        AttachmentColumns.NAME,
1899        AttachmentColumns.SIZE,
1900        AttachmentColumns.URI,
1901        AttachmentColumns.CONTENT_TYPE,
1902        AttachmentColumns.STATE,
1903        AttachmentColumns.DESTINATION,
1904        AttachmentColumns.DOWNLOADED_SIZE,
1905        AttachmentColumns.CONTENT_URI,
1906        AttachmentColumns.THUMBNAIL_URI,
1907        AttachmentColumns.PREVIEW_INTENT_URI,
1908        AttachmentColumns.PROVIDER_DATA,
1909        AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN,
1910        AttachmentColumns.TYPE,
1911        AttachmentColumns.FLAGS,
1912        AttachmentColumns.CONTENT_ID
1913    };
1914    public static final int ATTACHMENT_NAME_COLUMN = 0;
1915    public static final int ATTACHMENT_SIZE_COLUMN = 1;
1916    public static final int ATTACHMENT_URI_COLUMN = 2;
1917    public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
1918    public static final int ATTACHMENT_STATE_COLUMN = 4;
1919    public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
1920    public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
1921    public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
1922    public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
1923    public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
1924    public static final int ATTACHMENT_SUPPORTS_DOWNLOAD_AGAIN_COLUMN = 10;
1925    public static final int ATTACHMENT_TYPE_COLUMN = 11;
1926    public static final int ATTACHMENT_FLAGS_COLUMN = 12;
1927    public static final int ATTACHMENT_CONTENT_ID_COLUMN = 13;
1928
1929    /** Separates attachment info parts in strings in the database. */
1930    public static final String ATTACHMENT_INFO_SEPARATOR = "\n"; // use to join
1931    public static final Pattern ATTACHMENT_INFO_SEPARATOR_PATTERN =
1932            Pattern.compile(ATTACHMENT_INFO_SEPARATOR); // use to split
1933    public static final String ATTACHMENT_INFO_DELIMITER = "|"; // use to join
1934    // use to split
1935    public static final Pattern ATTACHMENT_INFO_DELIMITER_PATTERN = Pattern.compile("\\|");
1936
1937    /**
1938     * Valid states for the {@link AttachmentColumns#STATE} column.
1939     *
1940     */
1941    public static final class AttachmentState {
1942        /**
1943         * The full attachment is not present on device. When used as a command,
1944         * setting this state will tell the provider to cancel a download in
1945         * progress.
1946         * <p>
1947         * Valid next states: {@link #DOWNLOADING}, {@link #PAUSED}
1948         */
1949        public static final int NOT_SAVED = 0;
1950        /**
1951         * The most recent attachment download attempt failed. The current UI
1952         * design does not require providers to persist this state, but
1953         * providers must return this state at least once after a download
1954         * failure occurs. This state may not be used as a command.
1955         * <p>
1956         * Valid next states: {@link #DOWNLOADING}
1957         */
1958        public static final int FAILED = 1;
1959        /**
1960         * The attachment is currently being downloaded by the provider.
1961         * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1962         * download progress while in this state. When used as a command,
1963         * setting this state will tell the provider to initiate a download to
1964         * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1965         * .
1966         * <p>
1967         * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
1968         * {@link #SAVED}
1969         */
1970        public static final int DOWNLOADING = 2;
1971        /**
1972         * The attachment was successfully downloaded to the destination in
1973         * {@link AttachmentColumns#DESTINATION}. If a provider later detects
1974         * that a download is missing, it should reset the state to
1975         * {@link #NOT_SAVED}. This state may not be used as a command on its
1976         * own. To move a file from cache to external, update
1977         * {@link AttachmentColumns#DESTINATION}.
1978         * <p>
1979         * Valid next states: {@link #NOT_SAVED}, {@link #PAUSED}
1980         */
1981        public static final int SAVED = 3;
1982        /**
1983         * This is only used as a command, not as a state. The attachment is
1984         * currently being redownloaded by the provider.
1985         * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1986         * download progress while in this state. When used as a command,
1987         * setting this state will tell the provider to initiate a download to
1988         * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1989         * .
1990         */
1991        public static final int REDOWNLOADING = 4;
1992        /**
1993         * The attachment is either pending or paused in the download manager.
1994         * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1995         * download progress while in this state. This state may not be used as
1996         * a command on its own.
1997         * <p>
1998         * Valid next states: {@link #DOWNLOADING}, {@link #FAILED}
1999         */
2000        public static final int PAUSED = 5;
2001
2002        private AttachmentState() {}
2003    }
2004
2005    public static final class AttachmentDestination {
2006
2007        /**
2008         * The attachment will be or is already saved to the app-private cache partition.
2009         */
2010        public static final int CACHE = 0;
2011        /**
2012         * The attachment will be or is already saved to external shared device storage.
2013         * This value should be 1 since saveToSd is often used in a similar way
2014         */
2015        public static final int EXTERNAL = 1;
2016
2017        private AttachmentDestination() {}
2018    }
2019
2020    public static final class AttachmentColumns {
2021        /**
2022         * This string column is the attachment's file name, intended for display in UI. It is not
2023         * the full path of the file.
2024         */
2025        public static final String NAME = OpenableColumns.DISPLAY_NAME;
2026        /**
2027         * This integer column is the file size of the attachment, in bytes.
2028         */
2029        public static final String SIZE = OpenableColumns.SIZE;
2030        /**
2031         * This column is a {@link android.net.Uri} that can be queried to
2032         * monitor download state and progress for this individual attachment
2033         * (resulting cursor has one single row for this attachment).
2034         */
2035        public static final String URI = "uri";
2036        /**
2037         * This string column is the MIME type of the attachment.
2038         */
2039        public static final String CONTENT_TYPE = "contentType";
2040        /**
2041         * This integer column is the current downloading state of the
2042         * attachment as defined in {@link AttachmentState}.
2043         * <p>
2044         * Providers must accept updates to {@link #URI} with new values of
2045         * this column to initiate or cancel downloads.
2046         */
2047        public static final String STATE = "state";
2048        /**
2049         * This integer column is the file destination for the current download
2050         * in progress (when {@link #STATE} is
2051         * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
2052         * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
2053         * in {@link AttachmentDestination}. This value is undefined in any
2054         * other state.
2055         * <p>
2056         * Providers must accept updates to {@link #URI} with new values of
2057         * this column to move an existing downloaded file.
2058         */
2059        public static final String DESTINATION = "destination";
2060        /**
2061         * This integer column is the current number of bytes downloaded when
2062         * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
2063         * undefined in any other state.
2064         */
2065        public static final String DOWNLOADED_SIZE = "downloadedSize";
2066        /**
2067         * This column is a {@link android.net.Uri} that points to the
2068         * downloaded local file when {@link #STATE} is
2069         * {@link AttachmentState#SAVED}. This value is undefined in any other
2070         * state.
2071         */
2072        public static final String CONTENT_URI = "contentUri";
2073        /**
2074         * This column is a {@link android.net.Uri} that points to a local
2075         * thumbnail file for the attachment. Providers that do not support
2076         * downloading attachment thumbnails may leave this null.
2077         */
2078        public static final String THUMBNAIL_URI = "thumbnailUri";
2079        /**
2080         * This column is an {@link android.net.Uri} used in an
2081         * {@link android.content.Intent#ACTION_VIEW} Intent to launch a preview
2082         * activity that allows the user to efficiently view an attachment
2083         * without having to first download the entire file. Providers that do
2084         * not support previewing attachments may leave this null.
2085         */
2086        public static final String PREVIEW_INTENT_URI = "previewIntentUri";
2087        /**
2088         * This column contains provider-specific private data as JSON string.
2089         */
2090        public static final String PROVIDER_DATA = "providerData";
2091
2092        /**
2093         * This column represents whether this attachment supports the ability to be downloaded
2094         * again.
2095         */
2096        public static final String SUPPORTS_DOWNLOAD_AGAIN = "supportsDownloadAgain";
2097        /**
2098         * This column represents the visibility type of this attachment. One of the
2099         * {@link AttachmentType} constants.
2100         */
2101        public static final String TYPE = "type";
2102
2103        /**
2104         * This column holds various bitwise flags for status information.
2105         */
2106        public static final String FLAGS = "flags";
2107
2108        /**
2109         * This column holds the RFC 2392 content id of the email part for this attachment, if
2110         * possible; otherwise it holds an identifier unique to the parent message.
2111         */
2112        public static final String CONTENT_ID = "contentId";
2113
2114        private AttachmentColumns() {}
2115    }
2116
2117    public static final class AttachmentContentValueKeys {
2118        public static final String RENDITION = "rendition";
2119        public static final String ADDITIONAL_PRIORITY = "additionalPriority";
2120        public static final String DELAY_DOWNLOAD = "delayDownload";
2121    }
2122
2123    /**
2124     * Indicates a version of an attachment.
2125     */
2126    public static final class AttachmentRendition {
2127
2128        /** A smaller or simpler version of the attachment, such as a scaled-down image or an HTML
2129         * version of a document. Not always available.
2130         */
2131        public static final int SIMPLE = 0;
2132        /**
2133         * The full version of an attachment if it can be handled on the device, otherwise the
2134         * preview.
2135         */
2136        public static final int BEST = 1;
2137
2138        private static final String SIMPLE_STRING = "SIMPLE";
2139        private static final String BEST_STRING = "BEST";
2140
2141        /**
2142         * Prefer renditions in this order.
2143         */
2144        public static final int[] PREFERRED_RENDITIONS = new int[]{BEST, SIMPLE};
2145
2146        public static int parseRendition(String rendition) {
2147            if (TextUtils.equals(rendition, SIMPLE_STRING)) {
2148                return SIMPLE;
2149            } else if (TextUtils.equals(rendition, BEST_STRING)) {
2150                return BEST;
2151            }
2152
2153            throw new IllegalArgumentException(String.format("Unknown rendition %s", rendition));
2154        }
2155
2156        public static String toString(int rendition) {
2157            if (rendition == BEST) {
2158                return BEST_STRING;
2159            } else if (rendition == SIMPLE) {
2160                return SIMPLE_STRING;
2161            }
2162
2163            throw new IllegalArgumentException(String.format("Unknown rendition %d", rendition));
2164        }
2165    }
2166
2167    /**
2168     * Indicates the visibility type of an attachment.
2169     */
2170    public static final class AttachmentType {
2171        public static final int STANDARD = 0;
2172        public static final int INLINE_CURRENT_MESSAGE = 1;
2173        public static final int INLINE_QUOTED_MESSAGE = 2;
2174    }
2175
2176    public static final String[] UNDO_PROJECTION = {
2177        ConversationColumns.MESSAGE_LIST_URI
2178    };
2179    public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
2180
2181    // Parameter used to indicate the sequence number for an undoable operation
2182    public static final String SEQUENCE_QUERY_PARAMETER = "seq";
2183
2184    /**
2185     * Parameter used to force UI notifications in an operation involving
2186     * {@link ConversationOperations#OPERATION_KEY}.
2187     */
2188    public static final String FORCE_UI_NOTIFICATIONS_QUERY_PARAMETER = "forceUiNotifications";
2189
2190    /**
2191     * Parameter used to allow returning hidden folders.
2192     */
2193    public static final String ALLOW_HIDDEN_FOLDERS_QUERY_PARAM = "allowHiddenFolders";
2194
2195    public static final String AUTO_ADVANCE_MODE_OLDER = "older";
2196    public static final String AUTO_ADVANCE_MODE_NEWER = "newer";
2197    public static final String AUTO_ADVANCE_MODE_LIST = "list";
2198
2199    /**
2200     * Settings for auto advancing when the current conversation has been destroyed.
2201     */
2202    public static final class AutoAdvance {
2203        /** No setting specified. */
2204        public static final int UNSET = 0;
2205        /** Go to the older message (if available) */
2206        public static final int OLDER = 1;
2207        /** Go to the newer message (if available) */
2208        public static final int NEWER = 2;
2209        /** Go back to conversation list*/
2210        public static final int LIST = 3;
2211        /** The default option is to go to the list */
2212        public static final int DEFAULT = LIST;
2213
2214        /**
2215         * Gets the int value for the given auto advance setting.
2216         *
2217         * @param autoAdvanceSetting The string setting, such as "newer", "older", "list"
2218         */
2219        public static int getAutoAdvanceInt(final String autoAdvanceSetting) {
2220            final int autoAdvance;
2221
2222            if (AUTO_ADVANCE_MODE_NEWER.equals(autoAdvanceSetting)) {
2223                autoAdvance = NEWER;
2224            } else if (AUTO_ADVANCE_MODE_OLDER.equals(autoAdvanceSetting)) {
2225                autoAdvance = OLDER;
2226            } else if (AUTO_ADVANCE_MODE_LIST.equals(autoAdvanceSetting)) {
2227                autoAdvance = LIST;
2228            } else {
2229                autoAdvance = UNSET;
2230            }
2231
2232            return autoAdvance;
2233        }
2234
2235        public static String getAutoAdvanceStr(int autoAdvance) {
2236            final String str;
2237
2238            switch (autoAdvance) {
2239                case OLDER:
2240                    str = AUTO_ADVANCE_MODE_OLDER;
2241                    break;
2242                case NEWER:
2243                    str = AUTO_ADVANCE_MODE_NEWER;
2244                    break;
2245                case LIST:
2246                    str = AUTO_ADVANCE_MODE_LIST;
2247                    break;
2248                default:
2249                    str = "unset";
2250                    break;
2251            }
2252
2253            return str;
2254        }
2255    }
2256
2257    /**
2258     * Settings for what swipe should do.
2259     */
2260    public static final class Swipe {
2261        /** Archive or remove label, if available. */
2262        public static final int ARCHIVE = 0;
2263        /** Delete */
2264        public static final int DELETE = 1;
2265        /** No swipe */
2266        public static final int DISABLED = 2;
2267        /** Default is delete */
2268        public static final int DEFAULT = ARCHIVE;
2269    }
2270
2271    /**
2272     * Settings for Conversation view mode.
2273     */
2274    public static final class ConversationViewMode {
2275        /**
2276         * The user hasn't specified a mode.
2277         */
2278        public static final int UNDEFINED = -1;
2279        /**
2280         * Default to fit the conversation to screen view
2281         */
2282        public static final int OVERVIEW = 0;
2283        /**
2284         * Conversation text size should be the device default, and wide conversations may
2285         * require panning
2286         */
2287        public static final int READING = 1;
2288        public static final int DEFAULT = OVERVIEW;
2289    }
2290
2291    public static final class SnapHeaderValue {
2292        public static final int ALWAYS = 0;
2293        public static final int PORTRAIT_ONLY = 1;
2294        public static final int NEVER = 2;
2295    }
2296
2297    public static final class DefaultReplyBehavior {
2298        public static final int REPLY = 0;
2299        public static final int REPLY_ALL = 1;
2300    }
2301
2302    /**
2303     * Setting for whether to show sender images in conversation list.
2304     */
2305    public static final class ConversationListIcon {
2306        public static final int SENDER_IMAGE = 1;
2307        public static final int NONE = 2;
2308        public static final int DEFAULT = 1; // Default to show sender image
2309    }
2310
2311    /**
2312     * Action for an intent used to update/create new notifications.  The mime type of this
2313     * intent should be set to the mimeType of the account that is generating this notification.
2314     * An intent of this action is required to have the following extras:
2315     * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT}
2316     */
2317    public static final String ACTION_UPDATE_NOTIFICATION =
2318            "com.android.mail.action.update_notification";
2319
2320    public static final class UpdateNotificationExtras {
2321        /**
2322         * Parcelable extra containing a {@link Uri} to a {@link Folder}
2323         */
2324        public static final String EXTRA_FOLDER = "notification_extra_folder";
2325
2326        /**
2327         * Parcelable extra containing a {@link Uri} to an {@link Account}
2328         */
2329        public static final String EXTRA_ACCOUNT = "notification_extra_account";
2330
2331        /**
2332         * Integer extra containing the update unread count for the account/folder.
2333         * If this value is 0, the UI will not block the intent to allow code to clear notifications
2334         * to run.
2335         */
2336        public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count";
2337
2338        /**
2339         * Integer extra containing the update unseen count for the account/folder.
2340         */
2341        public static final String EXTRA_UPDATED_UNSEEN_COUNT = "notification_updated_unseen_count";
2342    }
2343
2344    public static final class EditSettingsExtras {
2345        /**
2346         * Parcelable extra containing account for which the user wants to
2347         * modify settings
2348         */
2349        public static final String EXTRA_ACCOUNT = "extra_account";
2350
2351        /**
2352         * Parcelable extra containing folder for which the user wants to
2353         * modify settings
2354         */
2355        public static final String EXTRA_FOLDER = "extra_folder";
2356
2357        /**
2358         * Boolean extra which is set true if the user wants to "manage folders"
2359         */
2360        public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders";
2361    }
2362
2363    public static final class SendFeedbackExtras {
2364        /**
2365         * Optional boolean extras which indicates that the user is reporting a problem.
2366         */
2367        public static final String EXTRA_REPORTING_PROBLEM = "reporting_problem";
2368        /**
2369         * Optional Parcelable extra containing the screenshot of the screen where the user
2370         * is reporting a problem.
2371         */
2372        public static final String EXTRA_SCREEN_SHOT = "screen_shot";
2373    }
2374
2375    public static final class ViewProxyExtras {
2376        /**
2377         * Uri extra passed to the proxy which indicates the original Uri that was intended to be
2378         * viewed.
2379         */
2380        public static final String EXTRA_ORIGINAL_URI = "original_uri";
2381        /**
2382         * String extra passed to the proxy which indicates the account being viewed.
2383         */
2384        public static final String EXTRA_ACCOUNT_NAME = "account_name";
2385        /**
2386         * String extra passed from the proxy which indicates the salt used to generate the digest.
2387         */
2388        public static final String EXTRA_SALT = "salt";
2389        /**
2390         * Byte[] extra passed from the proxy which indicates the digest of the salted account name.
2391         */
2392        public static final String EXTRA_ACCOUNT_DIGEST = "digest";
2393    }
2394}
2395