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