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