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