Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (C) 2011 Google Inc. |
| 3 | * Licensed to The Android Open Source Project. |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 4 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 8 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 10 | * |
Vikram Aggarwal | 4f9a4c5 | 2012-01-11 15:04:55 -0800 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | *******************************************************************************/ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 17 | |
Andy Huang | 30e2c24 | 2012-01-06 18:14:30 -0800 | [diff] [blame] | 18 | package com.android.mail.providers; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 19 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 20 | import android.content.ContentProvider; |
| 21 | import android.content.ContentValues; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 22 | import android.content.Context; |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 24 | import android.provider.BaseColumns; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 25 | import android.text.TextUtils; |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 26 | import android.net.Uri; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 27 | |
| 28 | import com.android.common.contacts.DataUsageStatUpdater; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 29 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 30 | import java.lang.String; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 31 | import java.util.ArrayList; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 32 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 33 | public class UIProvider { |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 34 | public static final String EMAIL_SEPARATOR = "\n"; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 35 | public static final long INVALID_CONVERSATION_ID = -1; |
| 36 | public static final long INVALID_MESSAGE_ID = -1; |
| 37 | |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 38 | /** |
| 39 | * Values for the current state of a Folder/Account; note that it's possible that more than one |
| 40 | * sync is in progress |
| 41 | */ |
| 42 | public static final class SyncStatus { |
| 43 | // No sync in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 44 | public static final int NO_SYNC = 0; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 45 | // A user-requested sync/refresh is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 46 | public static final int USER_REFRESH = 1<<0; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 47 | // A user-requested query is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 48 | public static final int USER_QUERY = 1<<1; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 49 | // A user request for additional results is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 50 | public static final int USER_MORE_RESULTS = 1<<2; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 51 | // A background sync is in progress |
Paul Westbrook | c808fac | 2012-02-22 16:42:18 -0800 | [diff] [blame] | 52 | public static final int BACKGROUND_SYNC = 1<<3; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Values for the result of the last attempted sync of a Folder/Account |
| 57 | */ |
| 58 | public static final class LastSyncResult { |
| 59 | // The sync completed successfully |
| 60 | public static final int SUCCESS = 0; |
| 61 | // The sync wasn't completed due to a connection error |
| 62 | public static final int CONNECTION_ERROR = 1; |
| 63 | // The sync wasn't completed due to an authentication error |
| 64 | public static final int AUTH_ERROR = 2; |
| 65 | // The sync wasn't completed due to a security error |
| 66 | public static final int SECURITY_ERROR = 3; |
| 67 | // The sync wasn't completed due to a low memory condition |
| 68 | public static final int STORAGE_ERROR = 4; |
| 69 | // The sync wasn't completed due to an internal error/exception |
| 70 | public static final int INTERNAL_ERROR = 5; |
| 71 | } |
| 72 | |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 73 | // The actual content provider should define its own authority |
Andy Huang | 30e2c24 | 2012-01-06 18:14:30 -0800 | [diff] [blame] | 74 | public static final String AUTHORITY = "com.android.mail.providers"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 75 | |
| 76 | public static final String ACCOUNT_LIST_TYPE = |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 77 | "vnd.android.cursor.dir/vnd.com.android.mail.account"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 78 | public static final String ACCOUNT_TYPE = |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 79 | "vnd.android.cursor.item/vnd.com.android.mail.account"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 80 | |
| 81 | public static final String[] ACCOUNTS_PROJECTION = { |
| 82 | BaseColumns._ID, |
| 83 | AccountColumns.NAME, |
| 84 | AccountColumns.PROVIDER_VERSION, |
| 85 | AccountColumns.URI, |
| 86 | AccountColumns.CAPABILITIES, |
| 87 | AccountColumns.FOLDER_LIST_URI, |
| 88 | AccountColumns.SEARCH_URI, |
| 89 | AccountColumns.ACCOUNT_FROM_ADDRESSES_URI, |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 90 | AccountColumns.SAVE_DRAFT_URI, |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 91 | AccountColumns.SEND_MAIL_URI, |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 92 | AccountColumns.EXPUNGE_MESSAGE_URI, |
Mindy Pereira | 9600dac | 2012-02-17 15:59:25 -0800 | [diff] [blame] | 93 | AccountColumns.UNDO_URI, |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 94 | AccountColumns.SETTINGS_INTENT_URI, |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 95 | AccountColumns.SETTINGS_QUERY_URI, |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 96 | AccountColumns.SYNC_STATUS, |
Mindy Pereira | 23755e2 | 2012-02-27 13:58:04 -0800 | [diff] [blame] | 97 | AccountColumns.HELP_INTENT_URI, |
Mindy Pereira | 898cd38 | 2012-03-06 08:42:47 -0800 | [diff] [blame] | 98 | AccountColumns.COMPOSE_URI, |
Vikram Aggarwal | 27e85f2 | 2012-03-05 16:29:17 -0800 | [diff] [blame] | 99 | AccountColumns.MIME_TYPE, |
| 100 | AccountColumns.RECENT_FOLDER_LIST_URI |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 101 | }; |
| 102 | |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 103 | public static final int ACCOUNT_ID_COLUMN = 0; |
| 104 | public static final int ACCOUNT_NAME_COLUMN = 1; |
| 105 | public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2; |
| 106 | public static final int ACCOUNT_URI_COLUMN = 3; |
| 107 | public static final int ACCOUNT_CAPABILITIES_COLUMN = 4; |
| 108 | public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5; |
| 109 | public static final int ACCOUNT_SEARCH_URI_COLUMN = 6; |
| 110 | public static final int ACCOUNT_FROM_ADDRESSES_URI_COLUMN = 7; |
| 111 | public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 8; |
| 112 | public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 9; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 113 | public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 10; |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 114 | public static final int ACCOUNT_UNDO_URI_COLUMN = 11; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 115 | public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 12; |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 116 | public static final int ACCOUNT_SETTINGS_QUERY_URI_COLUMN = 13; |
| 117 | public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14; |
| 118 | public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15; |
| 119 | public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 16; |
Mindy Pereira | 898cd38 | 2012-03-06 08:42:47 -0800 | [diff] [blame] | 120 | public static final int ACCOUNT_MIME_TYPE_COLUMN = 17; |
Vikram Aggarwal | 27e85f2 | 2012-03-05 16:29:17 -0800 | [diff] [blame] | 121 | public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 18; |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 122 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 123 | public static final class AccountCapabilities { |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 124 | /** |
| 125 | * Whether folders can be synchronized back to the server. |
| 126 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 127 | public static final int SYNCABLE_FOLDERS = 0x0001; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 128 | /** |
| 129 | * Whether the server allows reporting spam back. |
| 130 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 131 | public static final int REPORT_SPAM = 0x0002; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 132 | /** |
| 133 | * Whether the server supports a concept of Archive: removing mail from the Inbox but |
| 134 | * keeping it around. |
| 135 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 136 | public static final int ARCHIVE = 0x0004; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 137 | /** |
| 138 | * Whether the server will stop notifying on updates to this thread? This requires |
| 139 | * THREADED_CONVERSATIONS to be true, otherwise it should be ignored. |
| 140 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 141 | public static final int MUTE = 0x0008; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 142 | /** |
| 143 | * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS |
| 144 | * to be true, otherwise it should be ignored. |
| 145 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 146 | public static final int SERVER_SEARCH = 0x0010; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 147 | /** |
| 148 | * Whether the server supports constraining search to a single folder. Requires |
| 149 | * SYNCABLE_FOLDERS, otherwise it should be ignored. |
| 150 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 151 | public static final int FOLDER_SERVER_SEARCH = 0x0020; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 152 | /** |
| 153 | * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML). |
| 154 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 155 | public static final int SANITIZED_HTML = 0x0040; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 156 | /** |
| 157 | * Whether the server allows synchronization of draft messages. This does NOT require |
| 158 | * SYNCABLE_FOLDERS to be set. |
| 159 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 160 | public static final int DRAFT_SYNCHRONIZATION = 0x0080; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 161 | /** |
| 162 | * Does the server allow the user to compose mails (and reply) using addresses other than |
| 163 | * their account name? For instance, GMail allows users to set FROM addresses that are |
| 164 | * different from account@gmail.com address. For instance, user@gmail.com could have another |
| 165 | * FROM: address like user@android.com. If the user has enabled multiple FROM address, he |
| 166 | * can compose (and reply) using either address. |
| 167 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 168 | public static final int MULTIPLE_FROM_ADDRESSES = 0x0100; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 169 | /** |
| 170 | * Whether the server allows the original message to be included in the reply by setting a |
| 171 | * flag on the reply. If we can avoid including the entire previous message, we save on |
| 172 | * bandwidth (replies are shorter). |
| 173 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 174 | public static final int SMART_REPLY = 0x0200; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 175 | /** |
| 176 | * Does this account support searching locally, on the device? This requires the backend |
| 177 | * storage to support a mechanism for searching. |
| 178 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 179 | public static final int LOCAL_SEARCH = 0x0400; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 180 | /** |
| 181 | * Whether the server supports a notion of threaded conversations: where replies to messages |
| 182 | * are tagged to keep conversations grouped. This could be full threading (each message |
| 183 | * lists its parent) or conversation-level threading (each message lists one conversation |
| 184 | * which it belongs to) |
| 185 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 186 | public static final int THREADED_CONVERSATIONS = 0x0800; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 187 | /** |
| 188 | * Whether the server supports allowing a conversation to be in multiple folders. (Or allows |
Mindy Pereira | 30fd47b | 2012-03-09 09:24:00 -0800 | [diff] [blame^] | 189 | * multiple folders on a single conversation) |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 190 | */ |
Mindy Pereira | 8464889 | 2012-02-03 08:29:55 -0800 | [diff] [blame] | 191 | public static final int MULTIPLE_FOLDERS_PER_CONV = 0x1000; |
Mindy Pereira | 343ffeb | 2012-02-22 10:12:14 -0800 | [diff] [blame] | 192 | /** |
| 193 | * Whether the provider supports undoing operations. If it doesn't, never show the undo bar. |
| 194 | */ |
| 195 | public static final int UNDO = 0x2000; |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 196 | /** |
| 197 | * Whether the account provides help content. |
| 198 | */ |
| 199 | public static final int HELP_CONTENT = 0x4000; |
Mindy Pereira | 7f0a962 | 2012-02-29 15:00:34 -0800 | [diff] [blame] | 200 | /** |
| 201 | * Whether the account provides a mechanism for marking conversations as important. |
| 202 | */ |
| 203 | public static final int MARK_IMPORTANT = 0x8000; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | public static final class AccountColumns { |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 207 | /** |
| 208 | * This string column contains the human visible name for the account. |
| 209 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 210 | public static final String NAME = "name"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * This integer column returns the version of the UI provider schema from which this |
| 214 | * account provider will return results. |
| 215 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 216 | public static final String PROVIDER_VERSION = "providerVersion"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * This string column contains the uri to directly access the information for this account. |
| 220 | */ |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 221 | public static final String URI = "accountUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 222 | |
| 223 | /** |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 224 | * This integer column contains a bit field of the possible capabilities that this account |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 225 | * supports. |
| 226 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 227 | public static final String CAPABILITIES = "capabilities"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 228 | |
| 229 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 230 | * This string column contains the content provider uri to return the |
| 231 | * list of top level folders for this account. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 232 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 233 | public static final String FOLDER_LIST_URI = "folderListUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * This string column contains the content provider uri that can be queried for search |
| 237 | * results. |
Paul Westbrook | 8130e6f | 2012-03-06 13:51:01 -0800 | [diff] [blame] | 238 | * The supported query parameters are limited to those listed |
| 239 | * in {@link #SearchQueryParameters} |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 240 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 241 | public static final String SEARCH_URI = "searchUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 242 | |
| 243 | /** |
| 244 | * This string column contains the content provider uri that can be queried to access the |
| 245 | * from addresses for this account. |
| 246 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 247 | public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 248 | |
| 249 | /** |
| 250 | * 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] | 251 | * new draft messages for this account. NOTE: This might be better to |
| 252 | * be an update operation on the messageUri. |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 253 | */ |
Mindy Pereira | 33fe908 | 2012-01-09 16:24:30 -0800 | [diff] [blame] | 254 | public static final String SAVE_DRAFT_URI = "saveDraftUri"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 255 | |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 256 | /** |
| 257 | * This string column contains the content provider uri that can be used to send |
| 258 | * a message for this account. |
| 259 | * NOTE: This might be better to be an update operation on the messageUri. |
| 260 | */ |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 261 | public static final String SEND_MAIL_URI = "sendMailUri"; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * This string column contains the content provider uri that can be used |
| 265 | * to expunge a message from this account. NOTE: This might be better to |
| 266 | * be an update operation on the messageUri. |
| 267 | */ |
| 268 | public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri"; |
Mindy Pereira | 96b5c35 | 2012-02-01 11:33:40 -0800 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * This string column contains the content provider uri that can be used |
| 272 | * to undo the last committed action. |
| 273 | */ |
Mindy Pereira | 9600dac | 2012-02-17 15:59:25 -0800 | [diff] [blame] | 274 | public static final String UNDO_URI = "undoUri"; |
Paul Westbrook | 2861b6a | 2012-02-15 15:25:34 -0800 | [diff] [blame] | 275 | |
| 276 | /** |
Paul Westbrook | 9912eee | 2012-02-22 14:49:03 -0800 | [diff] [blame] | 277 | * Uri for EDIT intent that will cause the settings screens for this account type to be |
Paul Westbrook | 2861b6a | 2012-02-15 15:25:34 -0800 | [diff] [blame] | 278 | * shown. |
| 279 | * TODO: When we want to support a heterogeneous set of account types, this value may need |
| 280 | * to be moved to a global content provider. |
| 281 | */ |
| 282 | public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri"; |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 283 | |
| 284 | /** |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 285 | * This string column contains the content provider uri that can be used to query user |
| 286 | * settings/preferences. |
| 287 | * |
Vikram Aggarwal | 27e85f2 | 2012-03-05 16:29:17 -0800 | [diff] [blame] | 288 | * The cursor returned by this query support columns declared in {@link #SettingsColumns} |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 289 | */ |
| 290 | public static final String SETTINGS_QUERY_URI = "accountSettingsQueryUri"; |
| 291 | |
| 292 | /** |
Paul Westbrook | 94e440d | 2012-02-24 11:03:47 -0800 | [diff] [blame] | 293 | * Uri for VIEW intent that will cause the help screens for this account type to be |
| 294 | * shown. |
| 295 | * TODO: When we want to support a heterogeneous set of account types, this value may need |
| 296 | * to be moved to a global content provider. |
| 297 | */ |
| 298 | public static String HELP_INTENT_URI = "helpIntentUri"; |
| 299 | |
| 300 | /** |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 301 | * This int column contains the current sync status of the account (the logical AND of the |
| 302 | * sync status of folders in this account) |
| 303 | */ |
| 304 | public static final String SYNC_STATUS = "syncStatus"; |
Mindy Pereira | 23755e2 | 2012-02-27 13:58:04 -0800 | [diff] [blame] | 305 | /** |
| 306 | * Uri for VIEW intent that will cause the compose screens for this type |
| 307 | * of account to be shown. |
| 308 | */ |
| 309 | public static final String COMPOSE_URI = "composeUri"; |
Mindy Pereira | 898cd38 | 2012-03-06 08:42:47 -0800 | [diff] [blame] | 310 | /** |
| 311 | * Mime-type defining this account. |
| 312 | */ |
| 313 | public static final String MIME_TYPE = "mimeType"; |
Vikram Aggarwal | 27e85f2 | 2012-03-05 16:29:17 -0800 | [diff] [blame] | 314 | /** |
| 315 | * URI for location of recent folders viewed on this account. |
| 316 | */ |
| 317 | public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 318 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 319 | |
Paul Westbrook | 8130e6f | 2012-03-06 13:51:01 -0800 | [diff] [blame] | 320 | public static final class SearchQueryParameters { |
| 321 | /** |
| 322 | * Parameter used to specify the search query. |
| 323 | */ |
| 324 | public static final String QUERY = "query"; |
| 325 | |
| 326 | /** |
| 327 | * If specified, the query results will be limited to this folder. |
| 328 | */ |
| 329 | public static final String FOLDER = "folder"; |
| 330 | |
| 331 | private SearchQueryParameters() {} |
| 332 | } |
| 333 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 334 | // We define a "folder" as anything that contains a list of conversations. |
| 335 | public static final String FOLDER_LIST_TYPE = |
| 336 | "vnd.android.cursor.dir/vnd.com.android.mail.folder"; |
| 337 | public static final String FOLDER_TYPE = |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 338 | "vnd.android.cursor.item/vnd.com.android.mail.folder"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 339 | |
| 340 | public static final String[] FOLDERS_PROJECTION = { |
| 341 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 342 | FolderColumns.URI, |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 343 | FolderColumns.NAME, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 344 | FolderColumns.HAS_CHILDREN, |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 345 | FolderColumns.CAPABILITIES, |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 346 | FolderColumns.SYNC_WINDOW, |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 347 | FolderColumns.CONVERSATION_LIST_URI, |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 348 | FolderColumns.CHILD_FOLDERS_LIST_URI, |
| 349 | FolderColumns.UNREAD_COUNT, |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 350 | FolderColumns.TOTAL_COUNT, |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 351 | FolderColumns.REFRESH_URI, |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 352 | FolderColumns.SYNC_STATUS, |
Mindy Pereira | 7866472 | 2012-03-05 13:53:07 -0800 | [diff] [blame] | 353 | FolderColumns.LAST_SYNC_RESULT, |
| 354 | FolderColumns.TYPE, |
Mindy Pereira | 9275a06 | 2012-03-08 15:12:14 -0800 | [diff] [blame] | 355 | FolderColumns.ICON_RES_ID, |
| 356 | FolderColumns.BG_COLOR, |
| 357 | FolderColumns.FG_COLOR |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 358 | }; |
| 359 | |
Mindy Pereira | 818143e | 2012-01-11 13:59:49 -0800 | [diff] [blame] | 360 | public static final int FOLDER_ID_COLUMN = 0; |
| 361 | public static final int FOLDER_URI_COLUMN = 1; |
| 362 | public static final int FOLDER_NAME_COLUMN = 2; |
| 363 | public static final int FOLDER_HAS_CHILDREN_COLUMN = 3; |
| 364 | public static final int FOLDER_CAPABILITIES_COLUMN = 4; |
Mindy Pereira | 621b4bd | 2012-02-23 13:48:50 -0800 | [diff] [blame] | 365 | public static final int FOLDER_SYNC_WINDOW_COLUMN = 5; |
| 366 | public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6; |
| 367 | public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7; |
| 368 | public static final int FOLDER_UNREAD_COUNT_COLUMN = 8; |
| 369 | public static final int FOLDER_TOTAL_COUNT_COLUMN = 9; |
| 370 | public static final int FOLDER_REFRESH_URI_COLUMN = 10; |
| 371 | public static final int FOLDER_SYNC_STATUS_COLUMN = 11; |
| 372 | public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12; |
Mindy Pereira | 7866472 | 2012-03-05 13:53:07 -0800 | [diff] [blame] | 373 | public static final int FOLDER_TYPE_COLUMN = 13; |
| 374 | public static final int FOLDER_ICON_RES_ID_COLUMN = 14; |
Mindy Pereira | 9275a06 | 2012-03-08 15:12:14 -0800 | [diff] [blame] | 375 | public static final int FOLDER_BG_COLOR_COLUMN = 15; |
| 376 | public static final int FOLDER_FG_COLOR_COLUMN = 16; |
Mindy Pereira | 7866472 | 2012-03-05 13:53:07 -0800 | [diff] [blame] | 377 | |
| 378 | public static final class FolderType { |
| 379 | public static final int DEFAULT = 0; |
| 380 | public static final int INBOX = 1; |
| 381 | public static final int DRAFT = 2; |
| 382 | public static final int OUTBOX = 3; |
| 383 | public static final int SENT = 4; |
| 384 | public static final int TRASH = 5; |
| 385 | public static final int SPAM = 6; |
| 386 | } |
Mindy Pereira | 818143e | 2012-01-11 13:59:49 -0800 | [diff] [blame] | 387 | |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 388 | public static final class FolderCapabilities { |
| 389 | public static final int SYNCABLE = 0x0001; |
| 390 | public static final int PARENT = 0x0002; |
| 391 | public static final int CAN_HOLD_MAIL = 0x0004; |
| 392 | public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 393 | /** |
| 394 | * For accounts that support archive, this will indicate that this folder supports |
| 395 | * the archive functionality. |
| 396 | */ |
| 397 | public static final int ARCHIVE = 0x0010; |
| 398 | |
| 399 | /** |
| 400 | * For accounts that support report spam, this will indicate that this folder supports |
| 401 | * the report spam functionality. |
| 402 | */ |
| 403 | public static final int REPORT_SPAM = 0x0020; |
| 404 | |
| 405 | /** |
| 406 | * For accounts that support mute, this will indicate if a mute is performed from within |
| 407 | * this folder, the action is destructive. |
| 408 | */ |
| 409 | public static final int DESTRUCTIVE_MUTE = 0x0040; |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 412 | public static final class FolderColumns { |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 413 | public static final String URI = "folderUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 414 | /** |
| 415 | * This string column contains the human visible name for the folder. |
| 416 | */ |
| 417 | public static final String NAME = "name"; |
| 418 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 419 | * This int column represents the capabilities of the folder specified by |
| 420 | * FolderCapabilities flags. |
| 421 | */ |
| 422 | public static String CAPABILITIES = "capabilities"; |
| 423 | /** |
Mindy Pereira | fc2277e | 2012-01-11 10:23:44 -0800 | [diff] [blame] | 424 | * This int column represents whether or not this folder has any |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 425 | * child folders. |
| 426 | */ |
| 427 | public static String HAS_CHILDREN = "hasChildren"; |
| 428 | /** |
Mindy Pereira | 0973b20 | 2011-12-21 15:48:12 -0800 | [diff] [blame] | 429 | * This int column represents how large the sync window is. |
| 430 | */ |
| 431 | public static String SYNC_WINDOW = "syncWindow"; |
| 432 | /** |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 433 | * This string column contains the content provider uri to return the |
| 434 | * list of conversations for this folder. |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 435 | */ |
| 436 | public static final String CONVERSATION_LIST_URI = "conversationListUri"; |
Mindy Pereira | 750cc73 | 2011-12-21 13:32:29 -0800 | [diff] [blame] | 437 | /** |
| 438 | * This string column contains the content provider uri to return the |
| 439 | * list of child folders of this folder. |
| 440 | */ |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 441 | public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri"; |
Mindy Pereira | 3a565bf | 2011-12-21 11:26:21 -0800 | [diff] [blame] | 442 | |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 443 | public static final String UNREAD_COUNT = "unreadCount"; |
Mindy Pereira | bd8f51c | 2012-01-06 13:41:48 -0800 | [diff] [blame] | 444 | |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 445 | public static final String TOTAL_COUNT = "totalCount"; |
Mindy Pereira | 9c00210 | 2012-02-17 14:45:58 -0800 | [diff] [blame] | 446 | /** |
| 447 | * This string column contains the content provider uri to force a |
| 448 | * refresh of this folder. |
| 449 | */ |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 450 | public static final String REFRESH_URI = "refreshUri"; |
| 451 | /** |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 452 | * This int column contains current sync status of the folder; some combination of the |
| 453 | * SyncStatus bits defined above |
Mindy Pereira | 7752864 | 2012-02-17 15:51:10 -0800 | [diff] [blame] | 454 | */ |
Marc Blank | 9ace18a | 2012-02-21 16:34:07 -0800 | [diff] [blame] | 455 | public static final String SYNC_STATUS = "syncStatus"; |
| 456 | /** |
| 457 | * This int column contains the sync status of the last sync attempt; one of the |
| 458 | * LastSyncStatus values defined above |
| 459 | */ |
| 460 | public static final String LAST_SYNC_RESULT = "lastSyncResult"; |
Mindy Pereira | 7866472 | 2012-03-05 13:53:07 -0800 | [diff] [blame] | 461 | /** |
| 462 | * This long column contains the icon res id for this folder, or 0 if there is none. |
| 463 | */ |
| 464 | public static final String ICON_RES_ID = "iconResId"; |
| 465 | /** |
| 466 | * This int column contains the type of the folder. Zero is default. |
| 467 | */ |
| 468 | public static final String TYPE = "type"; |
Mindy Pereira | 9275a06 | 2012-03-08 15:12:14 -0800 | [diff] [blame] | 469 | /** |
| 470 | * String representing the integer background color associated with this |
| 471 | * folder, or null. |
| 472 | */ |
| 473 | public static final String BG_COLOR = "bgColor"; |
| 474 | /** |
| 475 | * String representing the integer of the foreground color associated |
| 476 | * with this folder, or null. |
| 477 | */ |
| 478 | public static final String FG_COLOR = "fgColor"; |
Vikram Aggarwal | ff7d02a | 2012-01-11 16:37:45 -0800 | [diff] [blame] | 479 | public FolderColumns() {} |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 480 | } |
| 481 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 482 | // We define a "folder" as anything that contains a list of conversations. |
| 483 | public static final String CONVERSATION_LIST_TYPE = |
| 484 | "vnd.android.cursor.dir/vnd.com.android.mail.conversation"; |
| 485 | public static final String CONVERSATION_TYPE = |
| 486 | "vnd.android.cursor.item/vnd.com.android.mail.conversation"; |
| 487 | |
Mindy Pereira | 9cdc406 | 2012-02-02 14:18:08 -0800 | [diff] [blame] | 488 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 489 | public static final String[] CONVERSATION_PROJECTION = { |
| 490 | BaseColumns._ID, |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 491 | ConversationColumns.URI, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 492 | ConversationColumns.MESSAGE_LIST_URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 493 | ConversationColumns.SUBJECT, |
Mindy Pereira | f9573c5 | 2011-12-22 14:02:49 -0800 | [diff] [blame] | 494 | ConversationColumns.SNIPPET, |
| 495 | ConversationColumns.SENDER_INFO, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 496 | ConversationColumns.DATE_RECEIVED_MS, |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 497 | ConversationColumns.HAS_ATTACHMENTS, |
| 498 | ConversationColumns.NUM_MESSAGES, |
| 499 | ConversationColumns.NUM_DRAFTS, |
| 500 | ConversationColumns.SENDING_STATE, |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 501 | ConversationColumns.PRIORITY, |
| 502 | ConversationColumns.READ, |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 503 | ConversationColumns.STARRED, |
| 504 | ConversationColumns.FOLDER_LIST |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 505 | }; |
| 506 | |
Mindy Pereira | fdd984b | 2011-12-29 09:43:45 -0800 | [diff] [blame] | 507 | // These column indexes only work when the caller uses the |
| 508 | // default CONVERSATION_PROJECTION defined above. |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 509 | public static final int CONVERSATION_ID_COLUMN = 0; |
Mindy Pereira | 3263fa9 | 2012-01-04 10:15:32 -0800 | [diff] [blame] | 510 | public static final int CONVERSATION_URI_COLUMN = 1; |
| 511 | public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2; |
| 512 | public static final int CONVERSATION_SUBJECT_COLUMN = 3; |
| 513 | public static final int CONVERSATION_SNIPPET_COLUMN = 4; |
| 514 | public static final int CONVERSATION_SENDER_INFO_COLUMN = 5; |
| 515 | public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6; |
| 516 | public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 517 | public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8; |
| 518 | public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9; |
| 519 | public static final int CONVERSATION_SENDING_STATE_COLUMN = 10; |
| 520 | public static final int CONVERSATION_PRIORITY_COLUMN = 11; |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 521 | public static final int CONVERSATION_READ_COLUMN = 12; |
| 522 | public static final int CONVERSATION_STARRED_COLUMN = 13; |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 523 | public static final int CONVERSATION_FOLDER_LIST_COLUMN = 14; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 524 | |
| 525 | public static final class ConversationSendingState { |
Mindy Pereira | a457137 | 2012-01-12 14:04:21 -0800 | [diff] [blame] | 526 | public static final int OTHER = 0; |
| 527 | public static final int SENDING = 1; |
| 528 | public static final int SENT = 2; |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 529 | public static final int SEND_ERROR = -1; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 530 | } |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 531 | |
| 532 | public static final class ConversationPriority { |
| 533 | public static final int LOW = 0; |
| 534 | public static final int HIGH = 1; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 535 | } |
Mindy Pereira | fa7ef6e | 2011-12-29 14:18:15 -0800 | [diff] [blame] | 536 | |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 537 | public static final class ConversationFlags { |
| 538 | public static final int READ = 1<<0; |
| 539 | public static final int STARRED = 1<<1; |
| 540 | public static final int REPLIED = 1<<2; |
| 541 | public static final int FORWARDED = 1<<3; |
Vikram Aggarwal | 859681b | 2012-02-03 10:02:24 -0800 | [diff] [blame] | 542 | } |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 543 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 544 | public static final class ConversationColumns { |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 545 | public static final String URI = "conversationUri"; |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 546 | /** |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 547 | * This string column contains the content provider uri to return the |
| 548 | * list of messages for this conversation. |
| 549 | */ |
| 550 | public static final String MESSAGE_LIST_URI = "messageListUri"; |
Mindy Pereira | 27a0cf0 | 2011-12-22 13:16:32 -0800 | [diff] [blame] | 551 | /** |
| 552 | * This string column contains the subject string for a conversation. |
| 553 | */ |
| 554 | public static final String SUBJECT = "subject"; |
| 555 | /** |
| 556 | * This string column contains the snippet string for a conversation. |
| 557 | */ |
| 558 | public static final String SNIPPET = "snippet"; |
| 559 | /** |
| 560 | * This string column contains the sender info string for a |
| 561 | * conversation. |
| 562 | */ |
| 563 | public static final String SENDER_INFO = "senderInfo"; |
| 564 | /** |
| 565 | * This long column contains the time in ms of the latest update to a |
| 566 | * conversation. |
| 567 | */ |
| 568 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
| 569 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 570 | /** |
| 571 | * This boolean column contains whether any messages in this conversation |
| 572 | * have attachments. |
| 573 | */ |
| 574 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
| 575 | |
Mindy Pereira | 4db59c5 | 2012-01-12 09:45:13 -0800 | [diff] [blame] | 576 | /** |
| 577 | * This int column contains the number of messages in this conversation. |
| 578 | * For unthreaded, this will always be 1. |
| 579 | */ |
| 580 | public static String NUM_MESSAGES = "numMessages"; |
| 581 | |
| 582 | /** |
| 583 | * This int column contains the number of drafts associated with this |
| 584 | * conversation. |
| 585 | */ |
| 586 | public static String NUM_DRAFTS = "numDrafts"; |
| 587 | |
| 588 | /** |
| 589 | * This int column contains the state of drafts and replies associated |
| 590 | * with this conversation. Use ConversationSendingState to interpret |
| 591 | * this field. |
| 592 | */ |
| 593 | public static String SENDING_STATE = "sendingState"; |
| 594 | |
| 595 | /** |
| 596 | * This int column contains the priority of this conversation. Use |
| 597 | * ConversationPriority to interpret this field. |
| 598 | */ |
| 599 | public static String PRIORITY = "priority"; |
| 600 | |
Marc Blank | c8a9942 | 2012-01-19 14:27:47 -0800 | [diff] [blame] | 601 | /** |
| 602 | * This boolean column indicates whether the conversation has been read |
| 603 | */ |
| 604 | public static String READ = "read"; |
| 605 | |
| 606 | /** |
| 607 | * This boolean column indicates whether the conversation has been read |
| 608 | */ |
| 609 | public static String STARRED = "starred"; |
| 610 | |
Mindy Pereira | 36b6c8b | 2012-02-03 14:16:07 -0800 | [diff] [blame] | 611 | /** |
| 612 | * This string column contains a csv of all folders associated with this |
| 613 | * conversation |
| 614 | */ |
| 615 | public static final String FOLDER_LIST = "folderList"; |
| 616 | |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 617 | private ConversationColumns() { |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 618 | } |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 619 | } |
| 620 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 621 | /** |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 622 | * List of operations that can can be performed on a conversation. These operations are applied |
| 623 | * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} |
| 624 | * where the conversation uri is specified, and the ContentValues specifies the operation to |
| 625 | * be performed. |
| 626 | * <p/> |
| 627 | * The operation to be performed is specified in the ContentValues by |
| 628 | * the {@link ConversationOperations#OPERATION_KEY} |
| 629 | * <p/> |
| 630 | * Note not all UI providers will support these operations. {@link AccountCapabilities} can |
| 631 | * be used to determine which operations are supported. |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 632 | */ |
Paul Westbrook | 334e64a | 2012-02-23 13:26:35 -0800 | [diff] [blame] | 633 | public static final class ConversationOperations { |
| 634 | /** |
| 635 | * ContentValues key used to specify the operation to be performed |
| 636 | */ |
| 637 | public static final String OPERATION_KEY = "operation"; |
| 638 | |
| 639 | /** |
| 640 | * Archive operation |
| 641 | */ |
| 642 | public static final String ARCHIVE = "archive"; |
| 643 | |
| 644 | /** |
| 645 | * Mute operation |
| 646 | */ |
| 647 | public static final String MUTE = "mute"; |
| 648 | |
| 649 | /** |
| 650 | * Report spam operation |
| 651 | */ |
| 652 | public static final String REPORT_SPAM = "report_spam"; |
| 653 | |
| 654 | private ConversationOperations() { |
| 655 | } |
| 656 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 657 | |
| 658 | public static final class DraftType { |
Andy Huang | 97c25be | 2012-01-12 15:12:09 -0800 | [diff] [blame] | 659 | public static final int NOT_A_DRAFT = 0; |
| 660 | public static final int COMPOSE = 1; |
| 661 | public static final int REPLY = 2; |
| 662 | public static final int REPLY_ALL = 3; |
| 663 | public static final int FORWARD = 4; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 664 | |
| 665 | private DraftType() {} |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 666 | } |
| 667 | |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 668 | public static final String[] MESSAGE_PROJECTION = { |
| 669 | BaseColumns._ID, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 670 | MessageColumns.SERVER_ID, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 671 | MessageColumns.URI, |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 672 | MessageColumns.CONVERSATION_ID, |
| 673 | MessageColumns.SUBJECT, |
| 674 | MessageColumns.SNIPPET, |
| 675 | MessageColumns.FROM, |
| 676 | MessageColumns.TO, |
| 677 | MessageColumns.CC, |
| 678 | MessageColumns.BCC, |
| 679 | MessageColumns.REPLY_TO, |
| 680 | MessageColumns.DATE_RECEIVED_MS, |
| 681 | MessageColumns.BODY_HTML, |
| 682 | MessageColumns.BODY_TEXT, |
| 683 | MessageColumns.EMBEDS_EXTERNAL_RESOURCES, |
| 684 | MessageColumns.REF_MESSAGE_ID, |
| 685 | MessageColumns.DRAFT_TYPE, |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 686 | MessageColumns.APPEND_REF_MESSAGE_CONTENT, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 687 | MessageColumns.HAS_ATTACHMENTS, |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 688 | MessageColumns.ATTACHMENT_LIST_URI, |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 689 | MessageColumns.MESSAGE_FLAGS, |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 690 | MessageColumns.JOINED_ATTACHMENT_INFOS, |
| 691 | MessageColumns.SAVE_MESSAGE_URI, |
Paul Westbrook | 104f729 | 2012-02-28 16:07:07 -0800 | [diff] [blame] | 692 | MessageColumns.SEND_MESSAGE_URI, |
| 693 | MessageColumns.ALWAYS_SHOW_IMAGES |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 694 | }; |
| 695 | |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 696 | /** Separates attachment info parts in strings in a message. */ |
| 697 | public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n"; |
Mindy Pereira | a140607 | 2011-12-22 10:54:06 -0800 | [diff] [blame] | 698 | public static final String MESSAGE_LIST_TYPE = |
| 699 | "vnd.android.cursor.dir/vnd.com.android.mail.message"; |
| 700 | public static final String MESSAGE_TYPE = |
| 701 | "vnd.android.cursor.item/vnd.com.android.mail.message"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 702 | |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 703 | public static final int MESSAGE_ID_COLUMN = 0; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 704 | public static final int MESSAGE_SERVER_ID_COLUMN = 1; |
| 705 | public static final int MESSAGE_URI_COLUMN = 2; |
| 706 | public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3; |
| 707 | public static final int MESSAGE_SUBJECT_COLUMN = 4; |
| 708 | public static final int MESSAGE_SNIPPET_COLUMN = 5; |
| 709 | public static final int MESSAGE_FROM_COLUMN = 6; |
| 710 | public static final int MESSAGE_TO_COLUMN = 7; |
| 711 | public static final int MESSAGE_CC_COLUMN = 8; |
| 712 | public static final int MESSAGE_BCC_COLUMN = 9; |
| 713 | public static final int MESSAGE_REPLY_TO_COLUMN = 10; |
| 714 | public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11; |
Mindy Pereira | 1666816 | 2012-01-11 16:11:19 -0800 | [diff] [blame] | 715 | public static final int MESSAGE_BODY_HTML_COLUMN = 12; |
| 716 | public static final int MESSAGE_BODY_TEXT_COLUMN = 13; |
Mindy Pereira | 326c660 | 2012-01-04 15:32:42 -0800 | [diff] [blame] | 717 | public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14; |
| 718 | public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15; |
| 719 | public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16; |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 720 | public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17; |
| 721 | public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18; |
| 722 | public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19; |
| 723 | public static final int MESSAGE_FLAGS_COLUMN = 20; |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 724 | public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21; |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 725 | public static final int MESSAGE_SAVE_URI_COLUMN = 22; |
| 726 | public static final int MESSAGE_SEND_URI_COLUMN = 23; |
Paul Westbrook | 104f729 | 2012-02-28 16:07:07 -0800 | [diff] [blame] | 727 | public static final int ALWAYS_SHOW_IMAGES_COLUMN = 24; |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 728 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 729 | public static final class MessageFlags { |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 730 | public static final int STARRED = 1 << 0; |
| 731 | public static final int UNREAD = 1 << 1; |
| 732 | public static final int REPLIED = 1 << 2; |
| 733 | public static final int FORWARDED = 1 << 3; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 734 | } |
| 735 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 736 | public static final class MessageColumns { |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 737 | /** |
| 738 | * This string column contains a content provider URI that points to this single message. |
| 739 | */ |
Mindy Pereira | 6349a04 | 2012-01-04 11:25:01 -0800 | [diff] [blame] | 740 | public static final String URI = "messageUri"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 741 | /** |
| 742 | * This string column contains a server-assigned ID for this message. |
| 743 | */ |
| 744 | public static final String SERVER_ID = "serverMessageId"; |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 745 | public static final String CONVERSATION_ID = "conversationId"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 746 | /** |
| 747 | * This string column contains the subject of a message. |
| 748 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 749 | public static final String SUBJECT = "subject"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 750 | /** |
| 751 | * This string column contains a snippet of the message body. |
| 752 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 753 | public static final String SNIPPET = "snippet"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 754 | /** |
| 755 | * This string column contains the single email address (and optionally name) of the sender. |
| 756 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 757 | public static final String FROM = "fromAddress"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 758 | /** |
| 759 | * This string column contains a comma-delimited list of "To:" recipient email addresses. |
| 760 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 761 | public static final String TO = "toAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 762 | /** |
| 763 | * This string column contains a comma-delimited list of "CC:" recipient email addresses. |
| 764 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 765 | public static final String CC = "ccAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 766 | /** |
| 767 | * This string column contains a comma-delimited list of "BCC:" recipient email addresses. |
| 768 | * This value will be null for incoming messages. |
| 769 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 770 | public static final String BCC = "bccAddresses"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 771 | /** |
| 772 | * This string column contains the single email address (and optionally name) of the |
| 773 | * sender's reply-to address. |
| 774 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 775 | public static final String REPLY_TO = "replyToAddress"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 776 | /** |
| 777 | * This long column contains the timestamp (in millis) of receipt of the message. |
| 778 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 779 | public static final String DATE_RECEIVED_MS = "dateReceivedMs"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 780 | /** |
| 781 | * This string column contains the HTML form of the message body, if available. If not, |
| 782 | * a provider must populate BODY_TEXT. |
| 783 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 784 | public static final String BODY_HTML = "bodyHtml"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 785 | /** |
| 786 | * This string column contains the plaintext form of the message body, if HTML is not |
| 787 | * otherwise available. If HTML is available, this value should be left empty (null). |
| 788 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 789 | public static final String BODY_TEXT = "bodyText"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 790 | public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources"; |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 791 | /** |
| 792 | * This string column contains an opaque string used by the sendMessage api. |
| 793 | */ |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 794 | public static final String REF_MESSAGE_ID = "refMessageId"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 795 | /** |
Andy Huang | 97c25be | 2012-01-12 15:12:09 -0800 | [diff] [blame] | 796 | * This integer column contains the type of this draft, or zero (0) if this message is not a |
| 797 | * draft. See {@link DraftType} for possible values. |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 798 | */ |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 799 | public static final String DRAFT_TYPE = "draftType"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 800 | /** |
| 801 | * This boolean column indicates whether an outgoing message should trigger special quoted |
| 802 | * text processing upon send. The value should default to zero (0) for protocols that do |
| 803 | * not support or require this flag, and for all incoming messages. |
| 804 | */ |
Mindy Pereira | 3ce64e7 | 2012-01-13 14:29:45 -0800 | [diff] [blame] | 805 | public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 806 | /** |
| 807 | * This boolean column indicates whether a message has attachments. The list of attachments |
| 808 | * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}. |
| 809 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 810 | public static final String HAS_ATTACHMENTS = "hasAttachments"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 811 | /** |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 812 | * This string column contains the content provider URI for the list of |
| 813 | * attachments associated with this message. |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 814 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 815 | public static final String ATTACHMENT_LIST_URI = "attachmentListUri"; |
Andy Huang | db97747 | 2012-01-11 19:53:25 -0800 | [diff] [blame] | 816 | /** |
| 817 | * This long column is a bit field of flags defined in {@link MessageFlags}. |
| 818 | */ |
Andy Huang | 732600e | 2012-01-10 17:47:17 -0800 | [diff] [blame] | 819 | public static final String MESSAGE_FLAGS = "messageFlags"; |
Mindy Pereira | f944e96 | 2012-01-17 11:43:36 -0800 | [diff] [blame] | 820 | /** |
| 821 | * This string column contains a specially formatted string representing all |
| 822 | * attachments that we added to a message that is being sent or saved. |
| 823 | */ |
Mindy Pereira | 84554ec | 2012-01-17 14:44:44 -0800 | [diff] [blame] | 824 | public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos"; |
Mindy Pereira | 7ed1c11 | 2012-01-18 10:59:25 -0800 | [diff] [blame] | 825 | /** |
| 826 | * This string column contains the content provider URI for saving this |
| 827 | * message. |
| 828 | */ |
| 829 | public static final String SAVE_MESSAGE_URI = "saveMessageUri"; |
| 830 | /** |
| 831 | * This string column contains content provider URI for sending this |
| 832 | * message. |
| 833 | */ |
| 834 | public static final String SEND_MESSAGE_URI = "sendMessageUri"; |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 835 | |
Paul Westbrook | 104f729 | 2012-02-28 16:07:07 -0800 | [diff] [blame] | 836 | /** |
| 837 | * This integer column represents whether the user has specified that images should always |
| 838 | * be shown. The value of "1" indicates that the user has specified that images should be |
| 839 | * shown, while the value of "0" indicates that the user should be prompted before loading |
| 840 | * any external images. |
| 841 | */ |
| 842 | public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages"; |
| 843 | |
Mindy Pereira | 6f92de6 | 2011-12-19 11:31:48 -0800 | [diff] [blame] | 844 | private MessageColumns() {} |
| 845 | } |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 846 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 847 | public static final String ATTACHMENT_LIST_TYPE = |
| 848 | "vnd.android.cursor.dir/vnd.com.android.mail.attachment"; |
| 849 | public static final String ATTACHMENT_TYPE = |
| 850 | "vnd.android.cursor.item/vnd.com.android.mail.attachment"; |
| 851 | |
| 852 | public static final String[] ATTACHMENT_PROJECTION = { |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 853 | AttachmentColumns.NAME, |
| 854 | AttachmentColumns.SIZE, |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 855 | AttachmentColumns.URI, |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 856 | AttachmentColumns.CONTENT_TYPE, |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 857 | AttachmentColumns.STATE, |
| 858 | AttachmentColumns.DESTINATION, |
| 859 | AttachmentColumns.DOWNLOADED_SIZE, |
| 860 | AttachmentColumns.CONTENT_URI, |
| 861 | AttachmentColumns.THUMBNAIL_URI, |
| 862 | AttachmentColumns.PREVIEW_INTENT |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 863 | }; |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 864 | private static final String EMAIL_SEPARATOR_PATTERN = "\n"; |
Andy Huang | 109369d | 2012-03-07 20:05:31 -0800 | [diff] [blame] | 865 | public static final int ATTACHMENT_NAME_COLUMN = 0; |
| 866 | public static final int ATTACHMENT_SIZE_COLUMN = 1; |
| 867 | public static final int ATTACHMENT_URI_COLUMN = 2; |
| 868 | public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3; |
| 869 | public static final int ATTACHMENT_STATE_COLUMN = 4; |
| 870 | public static final int ATTACHMENT_DESTINATION_COLUMN = 5; |
| 871 | public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6; |
| 872 | public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7; |
| 873 | public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8; |
| 874 | public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9; |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 875 | |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 876 | /** |
| 877 | * Valid states for the {@link AttachmentColumns#STATE} column. |
| 878 | * |
| 879 | */ |
| 880 | public static final class AttachmentState { |
| 881 | /** |
| 882 | * The full attachment is not present on device. When used as a command, |
| 883 | * setting this state will tell the provider to cancel a download in |
| 884 | * progress. |
| 885 | * <p> |
| 886 | * Valid next states: {@link #DOWNLOADING} |
| 887 | */ |
| 888 | public static final int NOT_SAVED = 0; |
| 889 | /** |
| 890 | * The most recent attachment download attempt failed. The current UI |
| 891 | * design does not require providers to persist this state, but |
| 892 | * providers must return this state at least once after a download |
| 893 | * failure occurs. This state may not be used as a command. |
| 894 | * <p> |
| 895 | * Valid next states: {@link #DOWNLOADING} |
| 896 | */ |
| 897 | public static final int FAILED = 1; |
| 898 | /** |
| 899 | * The attachment is currently being downloaded by the provider. |
| 900 | * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current |
| 901 | * download progress while in this state. When used as a command, |
| 902 | * setting this state will tell the provider to initiate a download to |
| 903 | * the accompanying destination in {@link AttachmentColumns#DESTINATION} |
| 904 | * . |
| 905 | * <p> |
| 906 | * Valid next states: {@link #NOT_SAVED}, {@link #FAILED}, |
| 907 | * {@link #SAVED} |
| 908 | */ |
| 909 | public static final int DOWNLOADING = 2; |
| 910 | /** |
| 911 | * The attachment was successfully downloaded to the destination in |
| 912 | * {@link AttachmentColumns#DESTINATION}. If a provider later detects |
| 913 | * that a download is missing, it should reset the state to |
| 914 | * {@link #NOT_SAVED}. This state may not be used as a command on its |
| 915 | * own. To move a file from cache to external, update |
| 916 | * {@link AttachmentColumns#DESTINATION}. |
| 917 | * <p> |
| 918 | * Valid next states: {@link #NOT_SAVED} |
| 919 | */ |
| 920 | public static final int SAVED = 3; |
| 921 | |
| 922 | private AttachmentState() {} |
| 923 | } |
| 924 | |
| 925 | public static final class AttachmentDestination { |
| 926 | |
| 927 | /** |
| 928 | * The attachment will be or is already saved to the app-private cache partition. |
| 929 | */ |
| 930 | public static final int CACHE = 0; |
| 931 | /** |
| 932 | * The attachment will be or is already saved to external shared device storage. |
| 933 | */ |
| 934 | public static final int EXTERNAL = 1; |
| 935 | |
| 936 | private AttachmentDestination() {} |
| 937 | } |
| 938 | |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 939 | public static final class AttachmentColumns { |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 940 | /** |
| 941 | * This string column is the attachment's file name, intended for display in UI. It is not |
| 942 | * the full path of the file. |
| 943 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 944 | public static final String NAME = "name"; |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 945 | /** |
| 946 | * This integer column is the file size of the attachment, in bytes. |
| 947 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 948 | public static final String SIZE = "size"; |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 949 | /** |
| 950 | * This column is a {@link Uri} that can be queried to monitor download state and progress |
| 951 | * for this individual attachment (resulting cursor has one single row for this attachment). |
| 952 | */ |
Mindy Pereira | 7a07fb4 | 2012-01-11 10:32:48 -0800 | [diff] [blame] | 953 | public static final String URI = "uri"; |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 954 | /** |
| 955 | * This string column is the MIME type of the attachment. |
| 956 | */ |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 957 | public static final String CONTENT_TYPE = "contentType"; |
Andy Huang | e0b83b8 | 2012-03-06 19:57:04 -0800 | [diff] [blame] | 958 | /** |
| 959 | * This integer column is the current downloading state of the |
| 960 | * attachment as defined in {@link AttachmentState}. |
| 961 | * <p> |
| 962 | * Providers must accept updates to {@link URI} with new values of |
| 963 | * this column to initiate or cancel downloads. |
| 964 | */ |
| 965 | public static final String STATE = "state"; |
| 966 | /** |
| 967 | * This integer column is the file destination for the current download |
| 968 | * in progress (when {@link #STATE} is |
| 969 | * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file |
| 970 | * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined |
| 971 | * in {@link AttachmentDestination}. This value is undefined in any |
| 972 | * other state. |
| 973 | * <p> |
| 974 | * Providers must accept updates to {@link URI} with new values of |
| 975 | * this column to move an existing downloaded file. |
| 976 | */ |
| 977 | public static final String DESTINATION = "destination"; |
| 978 | /** |
| 979 | * This integer column is the current number of bytes downloaded when |
| 980 | * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is |
| 981 | * undefined in any other state. |
| 982 | */ |
| 983 | public static final String DOWNLOADED_SIZE = "downloadedSize"; |
| 984 | /** |
| 985 | * This column is a {@link Uri} that points to the downloaded local file |
| 986 | * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is |
| 987 | * undefined in any other state. |
| 988 | */ |
| 989 | public static final String CONTENT_URI = "contentUri"; |
| 990 | /** |
| 991 | * This column is a {@link Uri} that points to a local thumbnail file |
| 992 | * for the attachment. Providers that do not support downloading |
| 993 | * attachment thumbnails may leave this null. |
| 994 | */ |
| 995 | public static final String THUMBNAIL_URI = "thumbnailUri"; |
| 996 | /** |
| 997 | * This column is an {@link Intent} to launch a preview activity that |
| 998 | * allows the user to efficiently view an attachment without having to |
| 999 | * first download the entire file. Providers that do not support |
| 1000 | * previewing attachments may leave this null. The intent is represented |
| 1001 | * as a byte-array blob generated by writing an Intent to a parcel and |
| 1002 | * then marshaling that parcel. |
| 1003 | */ |
| 1004 | public static final String PREVIEW_INTENT = "previewIntent"; |
| 1005 | |
| 1006 | private AttachmentColumns() {} |
Mindy Pereira | f30cc09 | 2011-12-29 14:02:40 -0800 | [diff] [blame] | 1007 | } |
Mindy Pereira | 013194c | 2012-01-06 15:09:33 -0800 | [diff] [blame] | 1008 | |
| 1009 | public static int getMailMaxAttachmentSize(String account) { |
| 1010 | // TODO: query the account to see what the max attachment size is? |
| 1011 | return 5 * 1024 * 1024; |
| 1012 | } |
| 1013 | |
| 1014 | public static String getAttachmentTypeSetting() { |
| 1015 | // TODO: query the account to see what kinds of attachments it supports? |
| 1016 | return "com.google.android.gm.allowAddAnyAttachment"; |
| 1017 | } |
Mindy Pereira | 82cc566 | 2012-01-09 17:29:30 -0800 | [diff] [blame] | 1018 | |
| 1019 | public static void incrementRecipientsTimesContacted(Context context, String addressString) { |
| 1020 | DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context); |
| 1021 | ArrayList<String> recipients = new ArrayList<String>(); |
| 1022 | String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN); |
| 1023 | for (String address : addresses) { |
| 1024 | recipients.add(address); |
| 1025 | } |
| 1026 | statsUpdater.updateWithAddress(recipients); |
| 1027 | } |
Marc Blank | b31ab5a | 2012-02-01 12:28:29 -0800 | [diff] [blame] | 1028 | |
| 1029 | public static final String[] UNDO_PROJECTION = { |
| 1030 | ConversationColumns.MESSAGE_LIST_URI |
| 1031 | }; |
| 1032 | public static final int UNDO_MESSAGE_LIST_COLUMN = 0; |
Marc Blank | dd10bc8 | 2012-02-01 19:10:46 -0800 | [diff] [blame] | 1033 | |
| 1034 | // Parameter used to indicate the sequence number for an undoable operation |
| 1035 | public static final String SEQUENCE_QUERY_PARAMETER = "seq"; |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1036 | |
| 1037 | |
| 1038 | public static final String[] SETTINGS_PROJECTION = { |
| 1039 | SettingsColumns.SIGNATURE, |
| 1040 | SettingsColumns.AUTO_ADVANCE, |
| 1041 | SettingsColumns.MESSAGE_TEXT_SIZE, |
| 1042 | SettingsColumns.SNAP_HEADERS, |
| 1043 | SettingsColumns.REPLY_BEHAVIOR, |
| 1044 | SettingsColumns.HIDE_CHECKBOXES, |
| 1045 | SettingsColumns.CONFIRM_DELETE, |
| 1046 | SettingsColumns.CONFIRM_ARCHIVE, |
| 1047 | SettingsColumns.CONFIRM_SEND, |
Mindy Pereira | 9783a74 | 2012-03-01 09:13:07 -0800 | [diff] [blame] | 1048 | SettingsColumns.DEFAULT_INBOX |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1049 | }; |
| 1050 | |
Mindy Pereira | 8bd8215 | 2012-03-01 10:06:35 -0800 | [diff] [blame] | 1051 | public static final int SETTINGS_SIGNATURE_COLUMN = 0; |
| 1052 | public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1; |
| 1053 | public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2; |
| 1054 | public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3; |
| 1055 | public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4; |
| 1056 | public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5; |
| 1057 | public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6; |
| 1058 | public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7; |
| 1059 | public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8; |
| 1060 | public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9; |
| 1061 | |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1062 | public static final class AutoAdvance { |
| 1063 | public static final int UNSET = 0; |
| 1064 | public static final int OLDER = 1; |
| 1065 | public static final int NEWER = 2; |
| 1066 | public static final int LIST = 3; |
| 1067 | } |
| 1068 | |
| 1069 | public static final class SnapHeaderValue { |
| 1070 | public static final int ALWAYS = 0; |
| 1071 | public static final int PORTRAIT_ONLY = 1; |
| 1072 | public static final int NEVER = 2; |
| 1073 | } |
| 1074 | |
| 1075 | public static final class MessageTextSize { |
| 1076 | public static final int TINY = -2; |
| 1077 | public static final int SMALL = -1; |
| 1078 | public static final int NORMAL = 0; |
| 1079 | public static final int LARGE = 1; |
| 1080 | public static final int HUGE = 2; |
| 1081 | } |
| 1082 | |
| 1083 | public static final class DefaultReplyBehavior { |
| 1084 | public static final int REPLY = 0; |
| 1085 | public static final int REPLY_ALL = 1; |
| 1086 | } |
| 1087 | |
| 1088 | public static final class SettingsColumns { |
| 1089 | /** |
| 1090 | * String column containing the contents of the signature for this account. If no |
| 1091 | * signature has been specified, the value will be null. |
| 1092 | */ |
| 1093 | public static final String SIGNATURE = "signature"; |
| 1094 | |
| 1095 | /** |
| 1096 | * Integer column containing the user's specified auto-advance policy. This value will be |
| 1097 | * one of the values in {@link UIProvider.AutoAdvance} |
| 1098 | */ |
| 1099 | public static final String AUTO_ADVANCE = "auto_advance"; |
| 1100 | |
| 1101 | /** |
| 1102 | * Integer column containing the user's specified message text size preference. This value |
| 1103 | * will be one of the values in {@link UIProvider.MessageTextSize} |
| 1104 | */ |
| 1105 | public static final String MESSAGE_TEXT_SIZE = "message_text_size"; |
| 1106 | |
| 1107 | /** |
| 1108 | * Integer column contaning the user's specified snap header preference. This value |
| 1109 | * will be one of the values in {@link UIProvider.SnapHeaderValue} |
| 1110 | */ |
| 1111 | public static final String SNAP_HEADERS = "snap_headers"; |
| 1112 | |
| 1113 | /** |
| 1114 | * Integer column containing the user's specified default reply behavior. This value will |
| 1115 | * be one of the values in {@link UIProvider.DefaultReplyBehavior} |
| 1116 | */ |
| 1117 | public static final String REPLY_BEHAVIOR = "reply_behavior"; |
| 1118 | |
| 1119 | /** |
Mindy Pereira | 8bd8215 | 2012-03-01 10:06:35 -0800 | [diff] [blame] | 1120 | * Integer column containing the user's specified checkbox preference. A |
| 1121 | * non zero value means to hide checkboxes. |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1122 | */ |
| 1123 | public static final String HIDE_CHECKBOXES = "hide_checkboxes"; |
| 1124 | |
| 1125 | /** |
| 1126 | * Integer column containing the user's specified confirm delete preference value. |
Mindy Pereira | 8bd8215 | 2012-03-01 10:06:35 -0800 | [diff] [blame] | 1127 | * A non zero value indicates that the user has indicated that a confirmation should |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1128 | * be shown when a delete action is performed. |
| 1129 | */ |
| 1130 | public static final String CONFIRM_DELETE = "confirm_delete"; |
| 1131 | |
| 1132 | /** |
| 1133 | * Integer column containing the user's specified confirm archive preference value. |
Mindy Pereira | 8bd8215 | 2012-03-01 10:06:35 -0800 | [diff] [blame] | 1134 | * A non zero value indicates that the user has indicated that a confirmation should |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1135 | * be shown when an archive action is performed. |
| 1136 | */ |
| 1137 | public static final String CONFIRM_ARCHIVE = "confirm_archive"; |
| 1138 | |
| 1139 | /** |
| 1140 | * Integer column containing the user's specified confirm send preference value. |
Mindy Pereira | 8bd8215 | 2012-03-01 10:06:35 -0800 | [diff] [blame] | 1141 | * A non zero value indicates that the user has indicated that a confirmation should |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1142 | * be shown when a send action is performed. |
| 1143 | */ |
| 1144 | public static final String CONFIRM_SEND = "confirm_send"; |
Mindy Pereira | 9783a74 | 2012-03-01 09:13:07 -0800 | [diff] [blame] | 1145 | /** |
| 1146 | * String folder containing the serialized default inbox folder for an account. |
| 1147 | */ |
| 1148 | public static final String DEFAULT_INBOX = "default_inbox"; |
Paul Westbrook | 63eef79 | 2012-02-27 14:01:06 -0800 | [diff] [blame] | 1149 | } |
Paul Westbrook | 82ea6da | 2011-12-15 11:03:51 -0800 | [diff] [blame] | 1150 | } |