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