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 | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 53 | AccountColumns.SEND_MESSAGE_URI, |
| 54 | AccountColumns.EXPUNGE_MESSAGE_URI |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 57 | public static final int ACCOUNT_ID_COLUMN = 0; |
| 58 | public static final int ACCOUNT_NAME_COLUMN = 1; |
| 59 | public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2; |
| 60 | public static final int ACCOUNT_URI_COLUMN = 3; |
| 61 | public static final int ACCOUNT_CAPABILITIES_COLUMN = 4; |
| 62 | public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5; |
| 63 | public static final int ACCOUNT_SEARCH_URI_COLUMN = 6; |
| 64 | public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7; |
| 65 | public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8; |
| 66 | public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 67 | public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10; |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 68 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 69 | public static final class AccountCapabilities { |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 70 | public static final int SYNCABLE_FOLDERS = 0x0001; |
| 71 | public static final int REPORT_SPAM = 0x0002; |
| 72 | public static final int ARCHIVE = 0x0004; |
| 73 | public static final int MUTE = 0x0008; |
| 74 | public static final int SERVER_SEARCH = 0x0010; |
| 75 | public static final int FOLDER_SERVER_SEARCH = 0x0020; |
| 76 | public static final int SANITIZED_HTML = 0x0040; |
| 77 | public static final int DRAFT_SYNCHRONIZATION = 0x0080; |
| 78 | public static final int MULTIPLE_FROM_ADDRESSES = 0x0100; |
| 79 | public static final int SMART_REPLY = 0x0200; |
| 80 | public static final int LOCAL_SEARCH = 0x0400; |
| 81 | public static final int THREADED_CONVERSATIONS = 0x0800; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | public static final class AccountColumns { |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 85 | /** |
| 86 | * This string column contains the human visible name for the account. |
| 87 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 88 | public static final String NAME = "name"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * This integer column returns the version of the UI provider schema from which this |
| 92 | * account provider will return results. |
| 93 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 94 | public static final String PROVIDER_VERSION = "providerVersion"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * This string column contains the uri to directly access the information for this account. |
| 98 | */ |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 99 | public static final String URI = "accountUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * This integer column contains a bit field of the possible cabibilities that this account |
| 103 | * supports. |
| 104 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 105 | public static final String CAPABILITIES = "capabilities"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 108 | * This string column contains the content provider uri to return the |
| 109 | * list of top level folders for this account. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 110 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 111 | public static final String FOLDER_LIST_URI = "folderListUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * This string column contains the content provider uri that can be queried for search |
| 115 | * results. |
| 116 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 117 | public static final String SEARCH_URI = "searchUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * This string column contains the content provider uri that can be queried to access the |
| 121 | * from addresses for this account. |
| 122 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 123 | public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * 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] | 127 | * new draft messages for this account. NOTE: This might be better to |
| 128 | * be an update operation on the messageUri. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 129 | */ |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 130 | public static final String SAVE_DRAFT_URI = "saveDraftUri"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 131 | |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 132 | /** |
| 133 | * This string column contains the content provider uri that can be used to send |
| 134 | * a message for this account. |
| 135 | * NOTE: This might be better to be an update operation on the messageUri. |
| 136 | */ |
| 137 | public static final String SEND_MESSAGE_URI = "sendMessageUri"; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * This string column contains the content provider uri that can be used |
| 141 | * to expunge a message from this account. NOTE: This might be better to |
| 142 | * be an update operation on the messageUri. |
| 143 | */ |
| 144 | public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 145 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 146 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 147 | // We define a "folder" as anything that contains a list of conversations. |
| 148 | public static final String FOLDER_LIST_TYPE = |
| 149 | "vnd.android.cursor.dir/vnd.com.android.mail.folder"; |
| 150 | public static final String FOLDER_TYPE = |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 151 | "vnd.android.cursor.item/vnd.com.android.mail.folder"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 152 | |
| 153 | public static final String[] FOLDERS_PROJECTION = { |
| 154 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 155 | FolderColumns.URI, |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 156 | FolderColumns.NAME, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 157 | FolderColumns.HAS_CHILDREN, |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 158 | FolderColumns.CAPABILITIES, |
| 159 | FolderColumns.SYNC_FREQUENCY, |
| 160 | FolderColumns.SYNC_WINDOW, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 161 | FolderColumns.CONVERSATION_LIST_URI, |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 162 | FolderColumns.CHILD_FOLDERS_LIST_URI, |
| 163 | FolderColumns.UNREAD_COUNT, |
| 164 | FolderColumns.TOTAL_COUNT |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 165 | }; |
| 166 | |
Mindy Pereira | 818143e | 2012-01-11 13:59:49 -0800 | [diff] [blame] | 167 | public static final int FOLDER_ID_COLUMN = 0; |
| 168 | public static final int FOLDER_URI_COLUMN = 1; |
| 169 | public static final int FOLDER_NAME_COLUMN = 2; |
| 170 | public static final int FOLDER_HAS_CHILDREN_COLUMN = 3; |
| 171 | public static final int FOLDER_CAPABILITIES_COLUMN = 4; |
| 172 | public static final int FOLDER_SYNC_FREQUENCY_COLUMN = 5; |
| 173 | public static final int FOLDER_SYNC_WINDOW_COLUMN = 6; |
| 174 | public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 7; |
| 175 | public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 8; |
| 176 | public static final int FOLDER_UNREAD_COUNT_COLUMN = 9; |
| 177 | public static final int FOLDER_TOTAL_COUNT_COLUMN = 10; |
| 178 | |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 179 | public static final class FolderCapabilities { |
| 180 | public static final int SYNCABLE = 0x0001; |
| 181 | public static final int PARENT = 0x0002; |
| 182 | public static final int CAN_HOLD_MAIL = 0x0004; |
| 183 | public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; |
| 184 | } |
| 185 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 186 | public static final class FolderColumns { |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 187 | public static String URI = "folderUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 188 | /** |
| 189 | * This string column contains the human visible name for the folder. |
| 190 | */ |
| 191 | public static final String NAME = "name"; |
| 192 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 193 | * This int column represents the capabilities of the folder specified by |
| 194 | * FolderCapabilities flags. |
| 195 | */ |
| 196 | public static String CAPABILITIES = "capabilities"; |
| 197 | /** |
Mindy Pereira | fc2277e | 2012-01-11 10:23:44 -0800 | [diff] [blame] | 198 | * This int column represents whether or not this folder has any |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 199 | * child folders. |
| 200 | */ |
| 201 | public static String HAS_CHILDREN = "hasChildren"; |
| 202 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 203 | * This int column represents how often the folder should be synced. |
| 204 | */ |
| 205 | public static String SYNC_FREQUENCY = "syncFrequency"; |
| 206 | /** |
| 207 | * This int column represents how large the sync window is. |
| 208 | */ |
| 209 | public static String SYNC_WINDOW = "syncWindow"; |
| 210 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 211 | * This string column contains the content provider uri to return the |
| 212 | * list of conversations for this folder. |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 213 | */ |
| 214 | public static final String CONVERSATION_LIST_URI = "conversationListUri"; |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 215 | /** |
| 216 | * This string column contains the content provider uri to return the |
| 217 | * list of child folders of this folder. |
| 218 | */ |
| 219 | public static String CHILD_FOLDERS_LIST_URI = "childFoldersListUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 220 | |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 221 | public static String UNREAD_COUNT = "unreadCount"; |
| 222 | |
| 223 | public static String TOTAL_COUNT = "totalCount"; |
| 224 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 225 | public FolderColumns() {}; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 226 | } |
| 227 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 228 | // We define a "folder" as anything that contains a list of conversations. |
| 229 | public static final String CONVERSATION_LIST_TYPE = |
| 230 | "vnd.android.cursor.dir/vnd.com.android.mail.conversation"; |
| 231 | public static final String CONVERSATION_TYPE = |
| 232 | "vnd.android.cursor.item/vnd.com.android.mail.conversation"; |
| 233 | |
| 234 | public static final String[] CONVERSATION_PROJECTION = { |
| 235 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 236 | ConversationColumns.URI, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 237 | ConversationColumns.MESSAGE_LIST_URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 238 | ConversationColumns.SUBJECT, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 239 | ConversationColumns.SNIPPET, |
| 240 | ConversationColumns.SENDER_INFO, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 241 | ConversationColumns.DATE_RECEIVED_MS, |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 242 | ConversationColumns.HAS_ATTACHMENTS, |
| 243 | ConversationColumns.NUM_MESSAGES, |
| 244 | ConversationColumns.NUM_DRAFTS, |
| 245 | ConversationColumns.SENDING_STATE, |
| 246 | ConversationColumns.PRIORITY |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 247 | }; |
| 248 | |
Mindy Pereira | fdd984b | 2011-12-29 09:43:45 -0800 | [diff] [blame] | 249 | // These column indexes only work when the caller uses the |
| 250 | // default CONVERSATION_PROJECTION defined above. |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 251 | public static final int CONVERSATION_ID_COLUMN = 0; |
Mindy Pereira | 3263fa9 | 2012-01-04 10:15:32 -0800 | [diff] [blame] | 252 | public static final int CONVERSATION_URI_COLUMN = 1; |
| 253 | public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2; |
| 254 | public static final int CONVERSATION_SUBJECT_COLUMN = 3; |
| 255 | public static final int CONVERSATION_SNIPPET_COLUMN = 4; |
| 256 | public static final int CONVERSATION_SENDER_INFO_COLUMN = 5; |
| 257 | public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6; |
| 258 | public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 259 | public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8; |
| 260 | public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9; |
| 261 | public static final int CONVERSATION_SENDING_STATE_COLUMN = 10; |
| 262 | public static final int CONVERSATION_PRIORITY_COLUMN = 11; |
| 263 | |
| 264 | public static final class ConversationSendingState { |
Mindy Pereira | a457137 | 2012-01-12 14:04:21 -0800 | [diff] [blame^] | 265 | public static final int OTHER = 0; |
| 266 | public static final int SENDING = 1; |
| 267 | public static final int SENT = 2; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 268 | public static final int SEND_ERROR = -1; |
| 269 | }; |
| 270 | |
| 271 | public static final class ConversationPriority { |
| 272 | public static final int LOW = 0; |
| 273 | public static final int HIGH = 1; |
| 274 | }; |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 275 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 276 | public static final class ConversationColumns { |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 277 | public static final String URI = "conversationUri"; |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 278 | /** |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 279 | * This string column contains the content provider uri to return the |
| 280 | * list of messages for this conversation. |
| 281 | */ |
| 282 | public static final String MESSAGE_LIST_URI = "messageListUri"; |
Mindy Pereira | 27a0cf0 | 2011-12-22 13:16:32 -0800 | [diff] [blame] | 283 | /** |
| 284 | * This string column contains the subject string for a conversation. |
| 285 | */ |
| 286 | public static final String SUBJECT = "subject"; |
| 287 | /** |
| 288 | * This string column contains the snippet string for a conversation. |
| 289 | */ |
| 290 | public static final String SNIPPET = "snippet"; |
| 291 | /** |
| 292 | * This string column contains the sender info string for a |
| 293 | * conversation. |
| 294 | */ |
| 295 | public static final String SENDER_INFO = "senderInfo"; |
| 296 | /** |
| 297 | * This long column contains the time in ms of the latest update to a |
| 298 | * conversation. |
| 299 | */ |
| 300 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
| 301 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 302 | /** |
| 303 | * This boolean column contains whether any messages in this conversation |
| 304 | * have attachments. |
| 305 | */ |
| 306 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
| 307 | |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 308 | /** |
| 309 | * This int column contains the number of messages in this conversation. |
| 310 | * For unthreaded, this will always be 1. |
| 311 | */ |
| 312 | public static String NUM_MESSAGES = "numMessages"; |
| 313 | |
| 314 | /** |
| 315 | * This int column contains the number of drafts associated with this |
| 316 | * conversation. |
| 317 | */ |
| 318 | public static String NUM_DRAFTS = "numDrafts"; |
| 319 | |
| 320 | /** |
| 321 | * This int column contains the state of drafts and replies associated |
| 322 | * with this conversation. Use ConversationSendingState to interpret |
| 323 | * this field. |
| 324 | */ |
| 325 | public static String SENDING_STATE = "sendingState"; |
| 326 | |
| 327 | /** |
| 328 | * This int column contains the priority of this conversation. Use |
| 329 | * ConversationPriority to interpret this field. |
| 330 | */ |
| 331 | public static String PRIORITY = "priority"; |
| 332 | |
Mindy Pereira | 27a0cf0 | 2011-12-22 13:16:32 -0800 | [diff] [blame] | 333 | public ConversationColumns() { |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 334 | } |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 337 | /** |
| 338 | * Returns a uri that, when queried, will return a cursor with a list of information for the |
| 339 | * list of configured accounts. |
| 340 | * @return |
| 341 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 342 | // TODO: create a static registry for the starting point for the UI provider. |
| 343 | // public static Uri getAccountsUri() { |
| 344 | // return Uri.parse(BASE_URI_STRING + "/"); |
| 345 | // } |
| 346 | |
| 347 | public static final class DraftType { |
| 348 | public static final String COMPOSE = "compose"; |
| 349 | public static final String REPLY = "reply"; |
| 350 | public static final String REPLY_ALL = "replyAll"; |
| 351 | public static final String FORWARD = "forward"; |
| 352 | |
| 353 | private DraftType() {} |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 354 | } |
| 355 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 356 | public static final String[] MESSAGE_PROJECTION = { |
| 357 | BaseColumns._ID, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 358 | MessageColumns.SERVER_ID, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 359 | MessageColumns.URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 360 | MessageColumns.CONVERSATION_ID, |
| 361 | MessageColumns.SUBJECT, |
| 362 | MessageColumns.SNIPPET, |
| 363 | MessageColumns.FROM, |
| 364 | MessageColumns.TO, |
| 365 | MessageColumns.CC, |
| 366 | MessageColumns.BCC, |
| 367 | MessageColumns.REPLY_TO, |
| 368 | MessageColumns.DATE_RECEIVED_MS, |
| 369 | MessageColumns.BODY_HTML, |
| 370 | MessageColumns.BODY_TEXT, |
| 371 | MessageColumns.EMBEDS_EXTERNAL_RESOURCES, |
| 372 | MessageColumns.REF_MESSAGE_ID, |
| 373 | MessageColumns.DRAFT_TYPE, |
| 374 | MessageColumns.INCLUDE_QUOTED_TEXT, |
| 375 | MessageColumns.QUOTE_START_POS, |
| 376 | MessageColumns.CLIENT_CREATED, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 377 | MessageColumns.CUSTOM_FROM_ADDRESS, |
| 378 | MessageColumns.HAS_ATTACHMENTS, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 379 | MessageColumns.ATTACHMENT_LIST_URI, |
| 380 | MessageColumns.MESSAGE_FLAGS |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 381 | }; |
| 382 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 383 | public static final String MESSAGE_LIST_TYPE = |
| 384 | "vnd.android.cursor.dir/vnd.com.android.mail.message"; |
| 385 | public static final String MESSAGE_TYPE = |
| 386 | "vnd.android.cursor.item/vnd.com.android.mail.message"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 387 | |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 388 | public static final int MESSAGE_ID_COLUMN = 0; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 389 | public static final int MESSAGE_SERVER_ID_COLUMN = 1; |
| 390 | public static final int MESSAGE_URI_COLUMN = 2; |
| 391 | public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3; |
| 392 | public static final int MESSAGE_SUBJECT_COLUMN = 4; |
| 393 | public static final int MESSAGE_SNIPPET_COLUMN = 5; |
| 394 | public static final int MESSAGE_FROM_COLUMN = 6; |
| 395 | public static final int MESSAGE_TO_COLUMN = 7; |
| 396 | public static final int MESSAGE_CC_COLUMN = 8; |
| 397 | public static final int MESSAGE_BCC_COLUMN = 9; |
| 398 | public static final int MESSAGE_REPLY_TO_COLUMN = 10; |
| 399 | public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11; |
Mindy Pereira | 1666816 | 2012-01-11 16:11:19 -0800 | [diff] [blame] | 400 | public static final int MESSAGE_BODY_HTML_COLUMN = 12; |
| 401 | public static final int MESSAGE_BODY_TEXT_COLUMN = 13; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 402 | public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14; |
| 403 | public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15; |
| 404 | public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16; |
| 405 | public static final int MESSAGE_INCLUDE_QUOTED_TEXT_COLUMN = 17; |
| 406 | public static final int MESSAGE_QUOTE_START_POS_COLUMN = 18; |
| 407 | public static final int MESSAGE_CLIENT_CREATED_COLUMN = 19; |
| 408 | public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 20; |
| 409 | public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 21; |
| 410 | public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 22; |
| 411 | public static final int MESSAGE_FLAGS_COLUMN = 23; |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 412 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 413 | public static final class MessageFlags { |
| 414 | public static final int SYNCABLE = 0x0001; |
| 415 | public static final int PARENT = 0x0002; |
| 416 | public static final int CAN_HOLD_MAIL = 0x0004; |
| 417 | public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 418 | public static final int STARRED = 0x0012; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 419 | } |
| 420 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 421 | public static final class MessageColumns { |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 422 | public static final String URI = "messageUri"; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 423 | public static final String SERVER_ID = "localMessageId"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 424 | public static final String CONVERSATION_ID = "conversationId"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 425 | public static final String SUBJECT = "subject"; |
| 426 | public static final String SNIPPET = "snippet"; |
| 427 | public static final String FROM = "fromAddress"; |
| 428 | public static final String TO = "toAddresses"; |
| 429 | public static final String CC = "ccAddresses"; |
| 430 | public static final String BCC = "bccAddresses"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 431 | public static final String REPLY_TO = "replyToAddress"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 432 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 433 | public static final String BODY_HTML = "bodyHtml"; |
| 434 | public static final String BODY_TEXT = "bodyText"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 435 | public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources"; |
| 436 | public static final String REF_MESSAGE_ID = "refMessageId"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 437 | public static final String DRAFT_TYPE = "draftType"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 438 | public static final String INCLUDE_QUOTED_TEXT = "includeQuotedText"; |
| 439 | public static final String QUOTE_START_POS = "quoteStartPos"; |
| 440 | public static final String CLIENT_CREATED = "clientCreated"; |
| 441 | public static final String CUSTOM_FROM_ADDRESS = "customFromAddress"; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 442 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
| 443 | public static final String ATTACHMENT_LIST_URI = "attachmentListUri"; |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 444 | public static final String MESSAGE_FLAGS = "messageFlags"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 445 | |
| 446 | private MessageColumns() {} |
| 447 | } |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 448 | |
| 449 | // We define a "folder" as anything that contains a list of conversations. |
| 450 | public static final String ATTACHMENT_LIST_TYPE = |
| 451 | "vnd.android.cursor.dir/vnd.com.android.mail.attachment"; |
| 452 | public static final String ATTACHMENT_TYPE = |
| 453 | "vnd.android.cursor.item/vnd.com.android.mail.attachment"; |
| 454 | |
| 455 | public static final String[] ATTACHMENT_PROJECTION = { |
| 456 | BaseColumns._ID, |
| 457 | AttachmentColumns.NAME, |
| 458 | AttachmentColumns.SIZE, |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 459 | AttachmentColumns.URI, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 460 | AttachmentColumns.ORIGIN_EXTRAS, |
| 461 | AttachmentColumns.CONTENT_TYPE, |
| 462 | AttachmentColumns.SYNCED |
| 463 | }; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 464 | private static final String EMAIL_SEPARATOR_PATTERN = "\n"; |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 465 | public static final int ATTACHMENT_ID_COLUMN = 0; |
| 466 | public static final int ATTACHMENT_NAME_COLUMN = 1; |
| 467 | public static final int ATTACHMENT_SIZE_COLUMN = 2; |
| 468 | public static final int ATTACHMENT_URI_COLUMN = 3; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 469 | |
| 470 | public static final class AttachmentColumns { |
| 471 | public static final String NAME = "name"; |
| 472 | public static final String SIZE = "size"; |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 473 | public static final String URI = "uri"; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 474 | public static final String ORIGIN_EXTRAS = "originExtras"; |
| 475 | public static final String CONTENT_TYPE = "contentType"; |
| 476 | public static final String SYNCED = "synced"; |
| 477 | } |
Mindy Pereira | 013194c | 2012-01-06 15:09:33 -0800 | [diff] [blame] | 478 | |
| 479 | public static int getMailMaxAttachmentSize(String account) { |
| 480 | // TODO: query the account to see what the max attachment size is? |
| 481 | return 5 * 1024 * 1024; |
| 482 | } |
| 483 | |
| 484 | public static String getAttachmentTypeSetting() { |
| 485 | // TODO: query the account to see what kinds of attachments it supports? |
| 486 | return "com.google.android.gm.allowAddAnyAttachment"; |
| 487 | } |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 488 | |
| 489 | public static void incrementRecipientsTimesContacted(Context context, String addressString) { |
| 490 | DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context); |
| 491 | ArrayList<String> recipients = new ArrayList<String>(); |
| 492 | String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN); |
| 493 | for (String address : addresses) { |
| 494 | recipients.add(address); |
| 495 | } |
| 496 | statsUpdater.updateWithAddress(recipients); |
| 497 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 498 | } |