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