Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (C) 2011 Google Inc. |
| 3 | * Licensed to The Android Open Source Project. |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 4 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 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 |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 8 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 10 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 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 | *******************************************************************************/ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 17 | |
Andy Huang | 30e2c24 | 2012-01-06 18:14:30 -0800 | [diff] [blame] | 18 | package com.android.mail.providers; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 19 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 20 | import android.content.ContentProvider; |
| 21 | import android.content.ContentValues; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 22 | import android.content.Context; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 23 | import android.provider.BaseColumns; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 24 | import android.text.TextUtils; |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 25 | import android.net.Uri; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 26 | |
| 27 | import com.android.common.contacts.DataUsageStatUpdater; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 28 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 29 | import java.lang.String; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 30 | import java.util.ArrayList; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 31 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 32 | |
| 33 | public class UIProvider { |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 34 | public static final String EMAIL_SEPARATOR = "\n"; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 35 | public static final long INVALID_CONVERSATION_ID = -1; |
| 36 | public static final long INVALID_MESSAGE_ID = -1; |
| 37 | |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 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 |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 44 | public static final int NO_SYNC = 0; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 45 | // A user-requested sync/refresh is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 46 | public static final int USER_REFRESH = 1<<0; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 47 | // A user-requested query is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 48 | public static final int USER_QUERY = 1<<1; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 49 | // A user request for additional results is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 50 | public static final int USER_MORE_RESULTS = 1<<2; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 51 | // A background sync is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 52 | public static final int BACKGROUND_SYNC = 1<<3; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Values for the result of the last attempted sync of a Folder/Account |
| 57 | */ |
| 58 | public static final class LastSyncResult { |
| 59 | // The sync completed successfully |
| 60 | public static final int SUCCESS = 0; |
| 61 | // The sync wasn't completed due to a connection error |
| 62 | public static final int CONNECTION_ERROR = 1; |
| 63 | // The sync wasn't completed due to an authentication error |
| 64 | public static final int AUTH_ERROR = 2; |
| 65 | // The sync wasn't completed due to a security error |
| 66 | public static final int SECURITY_ERROR = 3; |
| 67 | // The sync wasn't completed due to a low memory condition |
| 68 | public static final int STORAGE_ERROR = 4; |
| 69 | // The sync wasn't completed due to an internal error/exception |
| 70 | public static final int INTERNAL_ERROR = 5; |
| 71 | } |
| 72 | |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 73 | // The actual content provider should define its own authority |
Andy Huang | 30e2c24 | 2012-01-06 18:14:30 -0800 | [diff] [blame] | 74 | public static final String AUTHORITY = "com.android.mail.providers"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 75 | |
| 76 | public static final String ACCOUNT_LIST_TYPE = |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 77 | "vnd.android.cursor.dir/vnd.com.android.mail.account"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 78 | public static final String ACCOUNT_TYPE = |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 79 | "vnd.android.cursor.item/vnd.com.android.mail.account"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 80 | |
| 81 | public static final String[] ACCOUNTS_PROJECTION = { |
| 82 | BaseColumns._ID, |
| 83 | AccountColumns.NAME, |
| 84 | AccountColumns.PROVIDER_VERSION, |
| 85 | AccountColumns.URI, |
| 86 | AccountColumns.CAPABILITIES, |
| 87 | AccountColumns.FOLDER_LIST_URI, |
| 88 | AccountColumns.SEARCH_URI, |
| 89 | AccountColumns.ACCOUNT_FROM_ADDRESSES_URI, |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 90 | AccountColumns.SAVE_DRAFT_URI, |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 91 | AccountColumns.SEND_MAIL_URI, |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 92 | AccountColumns.EXPUNGE_MESSAGE_URI, |
Mindy Pereira | 9600dac | 2012-02-17 15:59:25 -0800 | [diff] [blame] | 93 | AccountColumns.UNDO_URI, |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 94 | AccountColumns.SETTINGS_INTENT_URI, |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 95 | AccountColumns.SYNC_STATUS, |
Mindy Pereira | 23755e2 | 2012-02-27 13:58:04 -0800 | [diff] [blame^] | 96 | AccountColumns.HELP_INTENT_URI, |
| 97 | AccountColumns.COMPOSE_URI |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 98 | }; |
| 99 | |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 100 | public static final int ACCOUNT_ID_COLUMN = 0; |
| 101 | public static final int ACCOUNT_NAME_COLUMN = 1; |
| 102 | public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2; |
| 103 | public static final int ACCOUNT_URI_COLUMN = 3; |
| 104 | public static final int ACCOUNT_CAPABILITIES_COLUMN = 4; |
| 105 | public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5; |
| 106 | public static final int ACCOUNT_SEARCH_URI_COLUMN = 6; |
| 107 | public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7; |
| 108 | public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8; |
| 109 | public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 110 | public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10; |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 111 | public static final int ACCOUNT_UNDO_URI_COLUMN = 11; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 112 | public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12; |
| 113 | public static final int ACCOUNT_SYNC_STATUS_COLUMN = 13; |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 114 | public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 14; |
Mindy Pereira | 23755e2 | 2012-02-27 13:58:04 -0800 | [diff] [blame^] | 115 | public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 14; |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 116 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 117 | public static final class AccountCapabilities { |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 118 | /** |
| 119 | * Whether folders can be synchronized back to the server. |
| 120 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 121 | public static final int SYNCABLE_FOLDERS = 0x0001; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 122 | /** |
| 123 | * Whether the server allows reporting spam back. |
| 124 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 125 | public static final int REPORT_SPAM = 0x0002; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 126 | /** |
| 127 | * Whether the server supports a concept of Archive: removing mail from the Inbox but |
| 128 | * keeping it around. |
| 129 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 130 | public static final int ARCHIVE = 0x0004; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 131 | /** |
| 132 | * Whether the server will stop notifying on updates to this thread? This requires |
| 133 | * THREADED_CONVERSATIONS to be true, otherwise it should be ignored. |
| 134 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 135 | public static final int MUTE = 0x0008; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 136 | /** |
| 137 | * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS |
| 138 | * to be true, otherwise it should be ignored. |
| 139 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 140 | public static final int SERVER_SEARCH = 0x0010; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 141 | /** |
| 142 | * Whether the server supports constraining search to a single folder. Requires |
| 143 | * SYNCABLE_FOLDERS, otherwise it should be ignored. |
| 144 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 145 | public static final int FOLDER_SERVER_SEARCH = 0x0020; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 146 | /** |
| 147 | * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML). |
| 148 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 149 | public static final int SANITIZED_HTML = 0x0040; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 150 | /** |
| 151 | * Whether the server allows synchronization of draft messages. This does NOT require |
| 152 | * SYNCABLE_FOLDERS to be set. |
| 153 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 154 | public static final int DRAFT_SYNCHRONIZATION = 0x0080; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 155 | /** |
| 156 | * Does the server allow the user to compose mails (and reply) using addresses other than |
| 157 | * their account name? For instance, GMail allows users to set FROM addresses that are |
| 158 | * different from account@gmail.com address. For instance, user@gmail.com could have another |
| 159 | * FROM: address like user@android.com. If the user has enabled multiple FROM address, he |
| 160 | * can compose (and reply) using either address. |
| 161 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 162 | public static final int MULTIPLE_FROM_ADDRESSES = 0x0100; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 163 | /** |
| 164 | * Whether the server allows the original message to be included in the reply by setting a |
| 165 | * flag on the reply. If we can avoid including the entire previous message, we save on |
| 166 | * bandwidth (replies are shorter). |
| 167 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 168 | public static final int SMART_REPLY = 0x0200; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 169 | /** |
| 170 | * Does this account support searching locally, on the device? This requires the backend |
| 171 | * storage to support a mechanism for searching. |
| 172 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 173 | public static final int LOCAL_SEARCH = 0x0400; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 174 | /** |
| 175 | * Whether the server supports a notion of threaded conversations: where replies to messages |
| 176 | * are tagged to keep conversations grouped. This could be full threading (each message |
| 177 | * lists its parent) or conversation-level threading (each message lists one conversation |
| 178 | * which it belongs to) |
| 179 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 180 | public static final int THREADED_CONVERSATIONS = 0x0800; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 181 | /** |
| 182 | * Whether the server supports allowing a conversation to be in multiple folders. (Or allows |
| 183 | * multiple labels on a single conversation, since labels and folders are interchangeable |
| 184 | * in this application.) |
| 185 | */ |
Mindy Pereira | 8464889 | 2012-02-03 08:29:55 -0800 | [diff] [blame] | 186 | public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000; |
Mindy Pereira | 343ffeb | 2012-02-22 10:12:14 -0800 | [diff] [blame] | 187 | /** |
| 188 | * Whether the provider supports undoing operations. If it doesn't, never show the undo bar. |
| 189 | */ |
| 190 | public static final int UNDO = 0x2000; |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 191 | /** |
| 192 | * Whether the account provides help content. |
| 193 | */ |
| 194 | public static final int HELP_CONTENT = 0x4000; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | public static final class AccountColumns { |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 198 | /** |
| 199 | * This string column contains the human visible name for the account. |
| 200 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 201 | public static final String NAME = "name"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 202 | |
| 203 | /** |
| 204 | * This integer column returns the version of the UI provider schema from which this |
| 205 | * account provider will return results. |
| 206 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 207 | public static final String PROVIDER_VERSION = "providerVersion"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 208 | |
| 209 | /** |
| 210 | * This string column contains the uri to directly access the information for this account. |
| 211 | */ |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 212 | public static final String URI = "accountUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 213 | |
| 214 | /** |
| 215 | * This integer column contains a bit field of the possible cabibilities that this account |
| 216 | * supports. |
| 217 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 218 | public static final String CAPABILITIES = "capabilities"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 219 | |
| 220 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 221 | * This string column contains the content provider uri to return the |
| 222 | * list of top level folders for this account. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 223 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 224 | public static final String FOLDER_LIST_URI = "folderListUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 225 | |
| 226 | /** |
| 227 | * This string column contains the content provider uri that can be queried for search |
| 228 | * results. |
| 229 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 230 | public static final String SEARCH_URI = "searchUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 231 | |
| 232 | /** |
| 233 | * This string column contains the content provider uri that can be queried to access the |
| 234 | * from addresses for this account. |
| 235 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 236 | public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * This string column contains the content provider uri that can be used to save (insert) |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 240 | * new draft messages for this account. NOTE: This might be better to |
| 241 | * be an update operation on the messageUri. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 242 | */ |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 243 | public static final String SAVE_DRAFT_URI = "saveDraftUri"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 244 | |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 245 | /** |
| 246 | * This string column contains the content provider uri that can be used to send |
| 247 | * a message for this account. |
| 248 | * NOTE: This might be better to be an update operation on the messageUri. |
| 249 | */ |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 250 | public static final String SEND_MAIL_URI = "sendMailUri"; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * This string column contains the content provider uri that can be used |
| 254 | * to expunge a message from this account. NOTE: This might be better to |
| 255 | * be an update operation on the messageUri. |
| 256 | */ |
| 257 | public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri"; |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * This string column contains the content provider uri that can be used |
| 261 | * to undo the last committed action. |
| 262 | */ |
Mindy Pereira | 9600dac | 2012-02-17 15:59:25 -0800 | [diff] [blame] | 263 | public static final String UNDO_URI = "undoUri"; |
Paul Westbrook | 2861b6a | 2012-02-15 15:25:34 -0800 | [diff] [blame] | 264 | |
| 265 | /** |
Paul Westbrook | 9912eee | 2012-02-22 14:49:03 -0800 | [diff] [blame] | 266 | * Uri for EDIT intent that will cause the settings screens for this account type to be |
Paul Westbrook | 2861b6a | 2012-02-15 15:25:34 -0800 | [diff] [blame] | 267 | * shown. |
| 268 | * TODO: When we want to support a heterogeneous set of account types, this value may need |
| 269 | * to be moved to a global content provider. |
| 270 | */ |
| 271 | public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri"; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 272 | |
| 273 | /** |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 274 | * Uri for VIEW intent that will cause the help screens for this account type to be |
| 275 | * shown. |
| 276 | * TODO: When we want to support a heterogeneous set of account types, this value may need |
| 277 | * to be moved to a global content provider. |
| 278 | */ |
| 279 | public static String HELP_INTENT_URI = "helpIntentUri"; |
| 280 | |
| 281 | /** |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 282 | * This int column contains the current sync status of the account (the logical AND of the |
| 283 | * sync status of folders in this account) |
| 284 | */ |
| 285 | public static final String SYNC_STATUS = "syncStatus"; |
Mindy Pereira | 23755e2 | 2012-02-27 13:58:04 -0800 | [diff] [blame^] | 286 | /** |
| 287 | * Uri for VIEW intent that will cause the compose screens for this type |
| 288 | * of account to be shown. |
| 289 | */ |
| 290 | public static final String COMPOSE_URI = "composeUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 291 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 292 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 293 | // We define a "folder" as anything that contains a list of conversations. |
| 294 | public static final String FOLDER_LIST_TYPE = |
| 295 | "vnd.android.cursor.dir/vnd.com.android.mail.folder"; |
| 296 | public static final String FOLDER_TYPE = |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 297 | "vnd.android.cursor.item/vnd.com.android.mail.folder"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 298 | |
| 299 | public static final String[] FOLDERS_PROJECTION = { |
| 300 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 301 | FolderColumns.URI, |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 302 | FolderColumns.NAME, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 303 | FolderColumns.HAS_CHILDREN, |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 304 | FolderColumns.CAPABILITIES, |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 305 | FolderColumns.SYNC_WINDOW, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 306 | FolderColumns.CONVERSATION_LIST_URI, |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 307 | FolderColumns.CHILD_FOLDERS_LIST_URI, |
| 308 | FolderColumns.UNREAD_COUNT, |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 309 | FolderColumns.TOTAL_COUNT, |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 310 | FolderColumns.REFRESH_URI, |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 311 | FolderColumns.SYNC_STATUS, |
| 312 | FolderColumns.LAST_SYNC_RESULT |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 313 | }; |
| 314 | |
Mindy Pereira | 818143e | 2012-01-11 13:59:49 -0800 | [diff] [blame] | 315 | public static final int FOLDER_ID_COLUMN = 0; |
| 316 | public static final int FOLDER_URI_COLUMN = 1; |
| 317 | public static final int FOLDER_NAME_COLUMN = 2; |
| 318 | public static final int FOLDER_HAS_CHILDREN_COLUMN = 3; |
| 319 | public static final int FOLDER_CAPABILITIES_COLUMN = 4; |
Mindy Pereira | 621b4bd | 2012-02-23 13:48:50 -0800 | [diff] [blame] | 320 | public static final int FOLDER_SYNC_WINDOW_COLUMN = 5; |
| 321 | public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6; |
| 322 | public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7; |
| 323 | public static final int FOLDER_UNREAD_COUNT_COLUMN = 8; |
| 324 | public static final int FOLDER_TOTAL_COUNT_COLUMN = 9; |
| 325 | public static final int FOLDER_REFRESH_URI_COLUMN = 10; |
| 326 | public static final int FOLDER_SYNC_STATUS_COLUMN = 11; |
| 327 | public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12; |
Mindy Pereira | 818143e | 2012-01-11 13:59:49 -0800 | [diff] [blame] | 328 | |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 329 | public static final class FolderCapabilities { |
| 330 | public static final int SYNCABLE = 0x0001; |
| 331 | public static final int PARENT = 0x0002; |
| 332 | public static final int CAN_HOLD_MAIL = 0x0004; |
| 333 | public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 334 | /** |
| 335 | * For accounts that support archive, this will indicate that this folder supports |
| 336 | * the archive functionality. |
| 337 | */ |
| 338 | public static final int ARCHIVE = 0x0010; |
| 339 | |
| 340 | /** |
| 341 | * For accounts that support report spam, this will indicate that this folder supports |
| 342 | * the report spam functionality. |
| 343 | */ |
| 344 | public static final int REPORT_SPAM = 0x0020; |
| 345 | |
| 346 | /** |
| 347 | * For accounts that support mute, this will indicate if a mute is performed from within |
| 348 | * this folder, the action is destructive. |
| 349 | */ |
| 350 | public static final int DESTRUCTIVE_MUTE = 0x0040; |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 351 | } |
| 352 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 353 | public static final class FolderColumns { |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 354 | public static final String URI = "folderUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 355 | /** |
| 356 | * This string column contains the human visible name for the folder. |
| 357 | */ |
| 358 | public static final String NAME = "name"; |
| 359 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 360 | * This int column represents the capabilities of the folder specified by |
| 361 | * FolderCapabilities flags. |
| 362 | */ |
| 363 | public static String CAPABILITIES = "capabilities"; |
| 364 | /** |
Mindy Pereira | fc2277e | 2012-01-11 10:23:44 -0800 | [diff] [blame] | 365 | * This int column represents whether or not this folder has any |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 366 | * child folders. |
| 367 | */ |
| 368 | public static String HAS_CHILDREN = "hasChildren"; |
| 369 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 370 | * This int column represents how large the sync window is. |
| 371 | */ |
| 372 | public static String SYNC_WINDOW = "syncWindow"; |
| 373 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 374 | * This string column contains the content provider uri to return the |
| 375 | * list of conversations for this folder. |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 376 | */ |
| 377 | public static final String CONVERSATION_LIST_URI = "conversationListUri"; |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 378 | /** |
| 379 | * This string column contains the content provider uri to return the |
| 380 | * list of child folders of this folder. |
| 381 | */ |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 382 | public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 383 | |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 384 | public static final String UNREAD_COUNT = "unreadCount"; |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 385 | |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 386 | public static final String TOTAL_COUNT = "totalCount"; |
Mindy Pereira | 9c00210 | 2012-02-17 14:45:58 -0800 | [diff] [blame] | 387 | /** |
| 388 | * This string column contains the content provider uri to force a |
| 389 | * refresh of this folder. |
| 390 | */ |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 391 | public static final String REFRESH_URI = "refreshUri"; |
| 392 | /** |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 393 | * This int column contains current sync status of the folder; some combination of the |
| 394 | * SyncStatus bits defined above |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 395 | */ |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 396 | public static final String SYNC_STATUS = "syncStatus"; |
| 397 | /** |
| 398 | * This int column contains the sync status of the last sync attempt; one of the |
| 399 | * LastSyncStatus values defined above |
| 400 | */ |
| 401 | public static final String LAST_SYNC_RESULT = "lastSyncResult"; |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 402 | |
Vikram Aggarwal | ff7d02a | 2012-01-11 16:37:45 -0800 | [diff] [blame] | 403 | public FolderColumns() {} |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 406 | // We define a "folder" as anything that contains a list of conversations. |
| 407 | public static final String CONVERSATION_LIST_TYPE = |
| 408 | "vnd.android.cursor.dir/vnd.com.android.mail.conversation"; |
| 409 | public static final String CONVERSATION_TYPE = |
| 410 | "vnd.android.cursor.item/vnd.com.android.mail.conversation"; |
| 411 | |
Mindy Pereira | 9cdc406 | 2012-02-02 14:18:08 -0800 | [diff] [blame] | 412 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 413 | public static final String[] CONVERSATION_PROJECTION = { |
| 414 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 415 | ConversationColumns.URI, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 416 | ConversationColumns.MESSAGE_LIST_URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 417 | ConversationColumns.SUBJECT, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 418 | ConversationColumns.SNIPPET, |
| 419 | ConversationColumns.SENDER_INFO, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 420 | ConversationColumns.DATE_RECEIVED_MS, |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 421 | ConversationColumns.HAS_ATTACHMENTS, |
| 422 | ConversationColumns.NUM_MESSAGES, |
| 423 | ConversationColumns.NUM_DRAFTS, |
| 424 | ConversationColumns.SENDING_STATE, |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 425 | ConversationColumns.PRIORITY, |
| 426 | ConversationColumns.READ, |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 427 | ConversationColumns.STARRED, |
| 428 | ConversationColumns.FOLDER_LIST |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 429 | }; |
| 430 | |
Mindy Pereira | fdd984b | 2011-12-29 09:43:45 -0800 | [diff] [blame] | 431 | // These column indexes only work when the caller uses the |
| 432 | // default CONVERSATION_PROJECTION defined above. |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 433 | public static final int CONVERSATION_ID_COLUMN = 0; |
Mindy Pereira | 3263fa9 | 2012-01-04 10:15:32 -0800 | [diff] [blame] | 434 | public static final int CONVERSATION_URI_COLUMN = 1; |
| 435 | public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2; |
| 436 | public static final int CONVERSATION_SUBJECT_COLUMN = 3; |
| 437 | public static final int CONVERSATION_SNIPPET_COLUMN = 4; |
| 438 | public static final int CONVERSATION_SENDER_INFO_COLUMN = 5; |
| 439 | public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6; |
| 440 | public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 441 | public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8; |
| 442 | public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9; |
| 443 | public static final int CONVERSATION_SENDING_STATE_COLUMN = 10; |
| 444 | public static final int CONVERSATION_PRIORITY_COLUMN = 11; |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 445 | public static final int CONVERSATION_READ_COLUMN = 12; |
| 446 | public static final int CONVERSATION_STARRED_COLUMN = 13; |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 447 | public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 448 | |
| 449 | public static final class ConversationSendingState { |
Mindy Pereira | a457137 | 2012-01-12 14:04:21 -0800 | [diff] [blame] | 450 | public static final int OTHER = 0; |
| 451 | public static final int SENDING = 1; |
| 452 | public static final int SENT = 2; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 453 | public static final int SEND_ERROR = -1; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 454 | } |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 455 | |
| 456 | public static final class ConversationPriority { |
| 457 | public static final int LOW = 0; |
| 458 | public static final int HIGH = 1; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 459 | } |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 460 | |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 461 | public static final class ConversationFlags { |
| 462 | public static final int READ = 1<<0; |
| 463 | public static final int STARRED = 1<<1; |
| 464 | public static final int REPLIED = 1<<2; |
| 465 | public static final int FORWARDED = 1<<3; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 466 | } |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 467 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 468 | public static final class ConversationColumns { |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 469 | public static final String URI = "conversationUri"; |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 470 | /** |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 471 | * This string column contains the content provider uri to return the |
| 472 | * list of messages for this conversation. |
| 473 | */ |
| 474 | public static final String MESSAGE_LIST_URI = "messageListUri"; |
Mindy Pereira | 27a0cf0 | 2011-12-22 13:16:32 -0800 | [diff] [blame] | 475 | /** |
| 476 | * This string column contains the subject string for a conversation. |
| 477 | */ |
| 478 | public static final String SUBJECT = "subject"; |
| 479 | /** |
| 480 | * This string column contains the snippet string for a conversation. |
| 481 | */ |
| 482 | public static final String SNIPPET = "snippet"; |
| 483 | /** |
| 484 | * This string column contains the sender info string for a |
| 485 | * conversation. |
| 486 | */ |
| 487 | public static final String SENDER_INFO = "senderInfo"; |
| 488 | /** |
| 489 | * This long column contains the time in ms of the latest update to a |
| 490 | * conversation. |
| 491 | */ |
| 492 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
| 493 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 494 | /** |
| 495 | * This boolean column contains whether any messages in this conversation |
| 496 | * have attachments. |
| 497 | */ |
| 498 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
| 499 | |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 500 | /** |
| 501 | * This int column contains the number of messages in this conversation. |
| 502 | * For unthreaded, this will always be 1. |
| 503 | */ |
| 504 | public static String NUM_MESSAGES = "numMessages"; |
| 505 | |
| 506 | /** |
| 507 | * This int column contains the number of drafts associated with this |
| 508 | * conversation. |
| 509 | */ |
| 510 | public static String NUM_DRAFTS = "numDrafts"; |
| 511 | |
| 512 | /** |
| 513 | * This int column contains the state of drafts and replies associated |
| 514 | * with this conversation. Use ConversationSendingState to interpret |
| 515 | * this field. |
| 516 | */ |
| 517 | public static String SENDING_STATE = "sendingState"; |
| 518 | |
| 519 | /** |
| 520 | * This int column contains the priority of this conversation. Use |
| 521 | * ConversationPriority to interpret this field. |
| 522 | */ |
| 523 | public static String PRIORITY = "priority"; |
| 524 | |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 525 | /** |
| 526 | * This boolean column indicates whether the conversation has been read |
| 527 | */ |
| 528 | public static String READ = "read"; |
| 529 | |
| 530 | /** |
| 531 | * This boolean column indicates whether the conversation has been read |
| 532 | */ |
| 533 | public static String STARRED = "starred"; |
| 534 | |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 535 | /** |
| 536 | * This string column contains a csv of all folders associated with this |
| 537 | * conversation |
| 538 | */ |
| 539 | public static final String FOLDER_LIST = "folderList"; |
| 540 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 541 | private ConversationColumns() { |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 542 | } |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 543 | } |
| 544 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 545 | /** |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 546 | * List of operations that can can be performed on a conversation. These operations are applied |
| 547 | * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} |
| 548 | * where the conversation uri is specified, and the ContentValues specifies the operation to |
| 549 | * be performed. |
| 550 | * <p/> |
| 551 | * The operation to be performed is specified in the ContentValues by |
| 552 | * the {@link ConversationOperations#OPERATION_KEY} |
| 553 | * <p/> |
| 554 | * Note not all UI providers will support these operations. {@link AccountCapabilities} can |
| 555 | * be used to determine which operations are supported. |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 556 | */ |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 557 | public static final class ConversationOperations { |
| 558 | /** |
| 559 | * ContentValues key used to specify the operation to be performed |
| 560 | */ |
| 561 | public static final String OPERATION_KEY = "operation"; |
| 562 | |
| 563 | /** |
| 564 | * Archive operation |
| 565 | */ |
| 566 | public static final String ARCHIVE = "archive"; |
| 567 | |
| 568 | /** |
| 569 | * Mute operation |
| 570 | */ |
| 571 | public static final String MUTE = "mute"; |
| 572 | |
| 573 | /** |
| 574 | * Report spam operation |
| 575 | */ |
| 576 | public static final String REPORT_SPAM = "report_spam"; |
| 577 | |
| 578 | private ConversationOperations() { |
| 579 | } |
| 580 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 581 | |
| 582 | public static final class DraftType { |
Andy Huang | 97c25be | 2012-01-12 15:12:09 -0800 | [diff] [blame] | 583 | public static final int NOT_A_DRAFT = 0; |
| 584 | public static final int COMPOSE = 1; |
| 585 | public static final int REPLY = 2; |
| 586 | public static final int REPLY_ALL = 3; |
| 587 | public static final int FORWARD = 4; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 588 | |
| 589 | private DraftType() {} |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 590 | } |
| 591 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 592 | public static final String[] MESSAGE_PROJECTION = { |
| 593 | BaseColumns._ID, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 594 | MessageColumns.SERVER_ID, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 595 | MessageColumns.URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 596 | MessageColumns.CONVERSATION_ID, |
| 597 | MessageColumns.SUBJECT, |
| 598 | MessageColumns.SNIPPET, |
| 599 | MessageColumns.FROM, |
| 600 | MessageColumns.TO, |
| 601 | MessageColumns.CC, |
| 602 | MessageColumns.BCC, |
| 603 | MessageColumns.REPLY_TO, |
| 604 | MessageColumns.DATE_RECEIVED_MS, |
| 605 | MessageColumns.BODY_HTML, |
| 606 | MessageColumns.BODY_TEXT, |
| 607 | MessageColumns.EMBEDS_EXTERNAL_RESOURCES, |
| 608 | MessageColumns.REF_MESSAGE_ID, |
| 609 | MessageColumns.DRAFT_TYPE, |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 610 | MessageColumns.APPEND_REF_MESSAGE_CONTENT, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 611 | MessageColumns.HAS_ATTACHMENTS, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 612 | MessageColumns.ATTACHMENT_LIST_URI, |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 613 | MessageColumns.MESSAGE_FLAGS, |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 614 | MessageColumns.JOINED_ATTACHMENT_INFOS, |
| 615 | MessageColumns.SAVE_MESSAGE_URI, |
| 616 | MessageColumns.SEND_MESSAGE_URI |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 617 | }; |
| 618 | |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 619 | /** Separates attachment info parts in strings in a message. */ |
| 620 | public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n"; |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 621 | public static final String MESSAGE_LIST_TYPE = |
| 622 | "vnd.android.cursor.dir/vnd.com.android.mail.message"; |
| 623 | public static final String MESSAGE_TYPE = |
| 624 | "vnd.android.cursor.item/vnd.com.android.mail.message"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 625 | |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 626 | public static final int MESSAGE_ID_COLUMN = 0; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 627 | public static final int MESSAGE_SERVER_ID_COLUMN = 1; |
| 628 | public static final int MESSAGE_URI_COLUMN = 2; |
| 629 | public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3; |
| 630 | public static final int MESSAGE_SUBJECT_COLUMN = 4; |
| 631 | public static final int MESSAGE_SNIPPET_COLUMN = 5; |
| 632 | public static final int MESSAGE_FROM_COLUMN = 6; |
| 633 | public static final int MESSAGE_TO_COLUMN = 7; |
| 634 | public static final int MESSAGE_CC_COLUMN = 8; |
| 635 | public static final int MESSAGE_BCC_COLUMN = 9; |
| 636 | public static final int MESSAGE_REPLY_TO_COLUMN = 10; |
| 637 | public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11; |
Mindy Pereira | 1666816 | 2012-01-11 16:11:19 -0800 | [diff] [blame] | 638 | public static final int MESSAGE_BODY_HTML_COLUMN = 12; |
| 639 | public static final int MESSAGE_BODY_TEXT_COLUMN = 13; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 640 | public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14; |
| 641 | public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15; |
| 642 | public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16; |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 643 | public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17; |
| 644 | public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18; |
| 645 | public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19; |
| 646 | public static final int MESSAGE_FLAGS_COLUMN = 20; |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 647 | public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21; |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 648 | public static final int MESSAGE_SAVE_URI_COLUMN = 22; |
| 649 | public static final int MESSAGE_SEND_URI_COLUMN = 23; |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 650 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 651 | public static final class MessageFlags { |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 652 | public static final int STARRED = 1 << 0; |
| 653 | public static final int UNREAD = 1 << 1; |
| 654 | public static final int REPLIED = 1 << 2; |
| 655 | public static final int FORWARDED = 1 << 3; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 656 | } |
| 657 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 658 | public static final class MessageColumns { |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 659 | /** |
| 660 | * This string column contains a content provider URI that points to this single message. |
| 661 | */ |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 662 | public static final String URI = "messageUri"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 663 | /** |
| 664 | * This string column contains a server-assigned ID for this message. |
| 665 | */ |
| 666 | public static final String SERVER_ID = "serverMessageId"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 667 | public static final String CONVERSATION_ID = "conversationId"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 668 | /** |
| 669 | * This string column contains the subject of a message. |
| 670 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 671 | public static final String SUBJECT = "subject"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 672 | /** |
| 673 | * This string column contains a snippet of the message body. |
| 674 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 675 | public static final String SNIPPET = "snippet"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 676 | /** |
| 677 | * This string column contains the single email address (and optionally name) of the sender. |
| 678 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 679 | public static final String FROM = "fromAddress"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 680 | /** |
| 681 | * This string column contains a comma-delimited list of "To:" recipient email addresses. |
| 682 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 683 | public static final String TO = "toAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 684 | /** |
| 685 | * This string column contains a comma-delimited list of "CC:" recipient email addresses. |
| 686 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 687 | public static final String CC = "ccAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 688 | /** |
| 689 | * This string column contains a comma-delimited list of "BCC:" recipient email addresses. |
| 690 | * This value will be null for incoming messages. |
| 691 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 692 | public static final String BCC = "bccAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 693 | /** |
| 694 | * This string column contains the single email address (and optionally name) of the |
| 695 | * sender's reply-to address. |
| 696 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 697 | public static final String REPLY_TO = "replyToAddress"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 698 | /** |
| 699 | * This long column contains the timestamp (in millis) of receipt of the message. |
| 700 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 701 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 702 | /** |
| 703 | * This string column contains the HTML form of the message body, if available. If not, |
| 704 | * a provider must populate BODY_TEXT. |
| 705 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 706 | public static final String BODY_HTML = "bodyHtml"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 707 | /** |
| 708 | * This string column contains the plaintext form of the message body, if HTML is not |
| 709 | * otherwise available. If HTML is available, this value should be left empty (null). |
| 710 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 711 | public static final String BODY_TEXT = "bodyText"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 712 | public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources"; |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 713 | /** |
| 714 | * This string column contains an opaque string used by the sendMessage api. |
| 715 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 716 | public static final String REF_MESSAGE_ID = "refMessageId"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 717 | /** |
Andy Huang | 97c25be | 2012-01-12 15:12:09 -0800 | [diff] [blame] | 718 | * This integer column contains the type of this draft, or zero (0) if this message is not a |
| 719 | * draft. See {@link DraftType} for possible values. |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 720 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 721 | public static final String DRAFT_TYPE = "draftType"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 722 | /** |
| 723 | * This boolean column indicates whether an outgoing message should trigger special quoted |
| 724 | * text processing upon send. The value should default to zero (0) for protocols that do |
| 725 | * not support or require this flag, and for all incoming messages. |
| 726 | */ |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 727 | public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 728 | /** |
| 729 | * This boolean column indicates whether a message has attachments. The list of attachments |
| 730 | * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}. |
| 731 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 732 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 733 | /** |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 734 | * This string column contains the content provider URI for the list of |
| 735 | * attachments associated with this message. |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 736 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 737 | public static final String ATTACHMENT_LIST_URI = "attachmentListUri"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 738 | /** |
| 739 | * This long column is a bit field of flags defined in {@link MessageFlags}. |
| 740 | */ |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 741 | public static final String MESSAGE_FLAGS = "messageFlags"; |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 742 | /** |
| 743 | * This string column contains a specially formatted string representing all |
| 744 | * attachments that we added to a message that is being sent or saved. |
| 745 | */ |
Mindy Pereira | 84554ec | 2012-01-17 14:44:44 -0800 | [diff] [blame] | 746 | public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos"; |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 747 | /** |
| 748 | * This string column contains the content provider URI for saving this |
| 749 | * message. |
| 750 | */ |
| 751 | public static final String SAVE_MESSAGE_URI = "saveMessageUri"; |
| 752 | /** |
| 753 | * This string column contains content provider URI for sending this |
| 754 | * message. |
| 755 | */ |
| 756 | public static final String SEND_MESSAGE_URI = "sendMessageUri"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 757 | |
| 758 | private MessageColumns() {} |
| 759 | } |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 760 | |
| 761 | // We define a "folder" as anything that contains a list of conversations. |
| 762 | public static final String ATTACHMENT_LIST_TYPE = |
| 763 | "vnd.android.cursor.dir/vnd.com.android.mail.attachment"; |
| 764 | public static final String ATTACHMENT_TYPE = |
| 765 | "vnd.android.cursor.item/vnd.com.android.mail.attachment"; |
| 766 | |
| 767 | public static final String[] ATTACHMENT_PROJECTION = { |
| 768 | BaseColumns._ID, |
| 769 | AttachmentColumns.NAME, |
| 770 | AttachmentColumns.SIZE, |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 771 | AttachmentColumns.URI, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 772 | AttachmentColumns.ORIGIN_EXTRAS, |
| 773 | AttachmentColumns.CONTENT_TYPE, |
| 774 | AttachmentColumns.SYNCED |
| 775 | }; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 776 | private static final String EMAIL_SEPARATOR_PATTERN = "\n"; |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 777 | public static final int ATTACHMENT_ID_COLUMN = 0; |
| 778 | public static final int ATTACHMENT_NAME_COLUMN = 1; |
| 779 | public static final int ATTACHMENT_SIZE_COLUMN = 2; |
| 780 | public static final int ATTACHMENT_URI_COLUMN = 3; |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 781 | public static final int ATTACHMENT_ORIGIN_EXTRAS_COLUMN = 4; |
| 782 | public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 5; |
| 783 | public static final int ATTACHMENT_SYNCED_COLUMN = 6; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 784 | |
| 785 | public static final class AttachmentColumns { |
| 786 | public static final String NAME = "name"; |
| 787 | public static final String SIZE = "size"; |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 788 | public static final String URI = "uri"; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 789 | public static final String ORIGIN_EXTRAS = "originExtras"; |
| 790 | public static final String CONTENT_TYPE = "contentType"; |
| 791 | public static final String SYNCED = "synced"; |
| 792 | } |
Mindy Pereira | 013194c | 2012-01-06 15:09:33 -0800 | [diff] [blame] | 793 | |
| 794 | public static int getMailMaxAttachmentSize(String account) { |
| 795 | // TODO: query the account to see what the max attachment size is? |
| 796 | return 5 * 1024 * 1024; |
| 797 | } |
| 798 | |
| 799 | public static String getAttachmentTypeSetting() { |
| 800 | // TODO: query the account to see what kinds of attachments it supports? |
| 801 | return "com.google.android.gm.allowAddAnyAttachment"; |
| 802 | } |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 803 | |
| 804 | public static void incrementRecipientsTimesContacted(Context context, String addressString) { |
| 805 | DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context); |
| 806 | ArrayList<String> recipients = new ArrayList<String>(); |
| 807 | String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN); |
| 808 | for (String address : addresses) { |
| 809 | recipients.add(address); |
| 810 | } |
| 811 | statsUpdater.updateWithAddress(recipients); |
| 812 | } |
Marc Blank | b31ab5a | 2012-02-01 12:28:29 -0800 | [diff] [blame] | 813 | |
| 814 | public static final String[] UNDO_PROJECTION = { |
| 815 | ConversationColumns.MESSAGE_LIST_URI |
| 816 | }; |
| 817 | public static final int UNDO_MESSAGE_LIST_COLUMN = 0; |
Marc Blank | dd10bc8 | 2012-02-01 19:10:46 -0800 | [diff] [blame] | 818 | |
| 819 | // Parameter used to indicate the sequence number for an undoable operation |
| 820 | public static final String SEQUENCE_QUERY_PARAMETER = "seq"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 821 | } |