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