blob: 25da659f07c6420a4a9088abda637be912402e12 [file] [log] [blame]
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08001/*******************************************************************************
2 * Copyright (C) 2011 Google Inc.
3 * Licensed to The Android Open Source Project.
Mindy Pereira6f92de62011-12-19 11:31:48 -08004 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08005 * 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 Pereira6f92de62011-12-19 11:31:48 -08008 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -08009 * http://www.apache.org/licenses/LICENSE-2.0
Mindy Pereira6f92de62011-12-19 11:31:48 -080010 *
Vikram Aggarwal4f9a4c52012-01-11 15:04:55 -080011 * 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 Pereira6f92de62011-12-19 11:31:48 -080017
Andy Huang30e2c242012-01-06 18:14:30 -080018package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080019
Vikram Aggarwala9a05d52012-10-25 13:51:10 -070020import com.google.common.collect.ImmutableMap;
21
Mindy Pereira82cc5662012-01-09 17:29:30 -080022import android.content.Context;
Mindy Pereira6f92de62011-12-19 11:31:48 -080023import android.provider.BaseColumns;
Paul Westbrookc97d8ac2012-03-23 15:21:48 -070024import android.provider.OpenableColumns;
Mindy Pereira82cc5662012-01-09 17:29:30 -080025import android.text.TextUtils;
mindyp845f87e2012-09-24 15:14:49 -070026import android.text.util.Rfc822Token;
27import android.text.util.Rfc822Tokenizer;
Mindy Pereira82cc5662012-01-09 17:29:30 -080028
29import com.android.common.contacts.DataUsageStatUpdater;
Mindy Pereira6f92de62011-12-19 11:31:48 -080030
Mindy Pereira82cc5662012-01-09 17:29:30 -080031import java.util.ArrayList;
Andy Huangbab92212012-11-16 18:32:18 -080032import java.util.Map;
Paul Westbrook82ea6da2011-12-15 11:03:51 -080033
Mindy Pereira6f92de62011-12-19 11:31:48 -080034public class UIProvider {
Mindy Pereira048b5c82012-04-02 11:11:33 -070035 public static final String EMAIL_SEPARATOR = ",";
Mindy Pereira326c6602012-01-04 15:32:42 -080036 public static final long INVALID_CONVERSATION_ID = -1;
37 public static final long INVALID_MESSAGE_ID = -1;
38
Marc Blank9ace18a2012-02-21 16:34:07 -080039 /**
40 * Values for the current state of a Folder/Account; note that it's possible that more than one
41 * sync is in progress
42 */
43 public static final class SyncStatus {
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070044 /**
45 * No sync in progress
46 */
Paul Westbrookc808fac2012-02-22 16:42:18 -080047 public static final int NO_SYNC = 0;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070048 /**
49 * A user-requested sync/refresh is in progress. This occurs when the user taps on the
50 * refresh icon in the action bar.
51 */
Paul Westbrookc808fac2012-02-22 16:42:18 -080052 public static final int USER_REFRESH = 1<<0;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070053 /**
54 * A user-requested live query is in progress. This occurs when the user goes past the end
55 * of the fetched results in the conversation list.
56 */
57 public static final int LIVE_QUERY = 1<<1;
58 /** Please use the constant {@link #LIVE_QUERY} instead. */
59 @Deprecated
Paul Westbrookc808fac2012-02-22 16:42:18 -080060 public static final int USER_QUERY = 1<<1;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070061 /**
62 * A background sync is in progress. This happens on <b>no</b> user interaction.
63 */
64 public static final int BACKGROUND_SYNC = 1<<2;
65 /**
66 * An initial sync is needed for this Account/Folder to be used. This is account-wide, when
67 * the user has added an account, and the first sync has not completed successfully.
68 */
69 public static final int INITIAL_SYNC_NEEDED = 1<<3;
70 /**
71 * Manual sync is required. This is account-wide, when the user has disabled sync on the
72 * Gmail account.
73 */
74 public static final int MANUAL_SYNC_REQUIRED = 1<<4;
Paul Westbrookdfa1dec2012-09-26 16:27:28 -070075 /**
76 * Account initialization is required.
77 */
78 public static final int ACCOUNT_INITIALIZATION_REQUIRED = 1<<5;
Mindy Pereira70a70c92012-08-02 08:39:45 -070079
80 public static boolean isSyncInProgress(int syncStatus) {
81 return 0 != (syncStatus & (BACKGROUND_SYNC |
82 USER_REFRESH |
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070083 LIVE_QUERY |
Mindy Pereira70a70c92012-08-02 08:39:45 -070084 USER_MORE_RESULTS));
85 }
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070086 /**
87 * Unused currently, is not used by any provider.
88 * TODO(viki): Remove.
89 */
90 public static final int USER_MORE_RESULTS = 1<<5;
Marc Blank9ace18a2012-02-21 16:34:07 -080091 }
92
93 /**
94 * Values for the result of the last attempted sync of a Folder/Account
95 */
96 public static final class LastSyncResult {
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070097 /** The sync completed successfully */
Marc Blank9ace18a2012-02-21 16:34:07 -080098 public static final int SUCCESS = 0;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -070099 /** The sync wasn't completed due to a connection error */
Marc Blank9ace18a2012-02-21 16:34:07 -0800100 public static final int CONNECTION_ERROR = 1;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700101 /** The sync wasn't completed due to an authentication error */
Marc Blank9ace18a2012-02-21 16:34:07 -0800102 public static final int AUTH_ERROR = 2;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700103 /** The sync wasn't completed due to a security error */
Marc Blank9ace18a2012-02-21 16:34:07 -0800104 public static final int SECURITY_ERROR = 3;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700105 /** The sync wasn't completed due to a low memory condition */
Marc Blank9ace18a2012-02-21 16:34:07 -0800106 public static final int STORAGE_ERROR = 4;
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700107 /** The sync wasn't completed due to an internal error/exception */
Marc Blank9ace18a2012-02-21 16:34:07 -0800108 public static final int INTERNAL_ERROR = 5;
109 }
110
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800111 // The actual content provider should define its own authority
Andy Huang30e2c242012-01-06 18:14:30 -0800112 public static final String AUTHORITY = "com.android.mail.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800113
114 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800115 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800116 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800117 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800118
Paul Westbrook2d82d612012-03-07 09:21:14 -0800119 /**
120 * Query parameter key that can be used to control the behavior of list queries. The value
121 * must be a serialized {@link ListParams} object. UIProvider implementations are not
122 * required to respect this query parameter
123 */
124 public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams";
125
Andy Huangbab92212012-11-16 18:32:18 -0800126 public static final Map<String, Class<?>> ACCOUNTS_COLUMNS =
127 new ImmutableMap.Builder<String, Class<?>>()
128 // order matters! (ImmutableMap.Builder preserves insertion order)
129 .put(BaseColumns._ID, Integer.class)
130 .put(AccountColumns.NAME, String.class)
131 .put(AccountColumns.PROVIDER_VERSION, Integer.class)
132 .put(AccountColumns.URI, String.class)
133 .put(AccountColumns.CAPABILITIES, Integer.class)
134 .put(AccountColumns.FOLDER_LIST_URI, String.class)
135 .put(AccountColumns.FULL_FOLDER_LIST_URI, String.class)
136 .put(AccountColumns.SEARCH_URI, String.class)
137 .put(AccountColumns.ACCOUNT_FROM_ADDRESSES, String.class)
138 .put(AccountColumns.SAVE_DRAFT_URI, String.class)
139 .put(AccountColumns.SEND_MAIL_URI, String.class)
140 .put(AccountColumns.EXPUNGE_MESSAGE_URI, String.class)
141 .put(AccountColumns.UNDO_URI, String.class)
142 .put(AccountColumns.SETTINGS_INTENT_URI, String.class)
143 .put(AccountColumns.SYNC_STATUS, Integer.class)
144 .put(AccountColumns.HELP_INTENT_URI, String.class)
145 .put(AccountColumns.SEND_FEEDBACK_INTENT_URI, String.class)
146 .put(AccountColumns.REAUTHENTICATION_INTENT_URI, String.class)
147 .put(AccountColumns.COMPOSE_URI, String.class)
148 .put(AccountColumns.MIME_TYPE, String.class)
149 .put(AccountColumns.RECENT_FOLDER_LIST_URI, String.class)
150 .put(AccountColumns.COLOR, Integer.class)
151 .put(AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI, String.class)
152 .put(AccountColumns.MANUAL_SYNC_URI, String.class)
153 .put(AccountColumns.VIEW_INTENT_PROXY_URI, String.class)
154 .put(AccountColumns.ACCOUNT_COOKIE_QUERY_URI, String.class)
155 .put(AccountColumns.SettingsColumns.SIGNATURE, String.class)
156 .put(AccountColumns.SettingsColumns.AUTO_ADVANCE, Integer.class)
157 .put(AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE, Integer.class)
158 .put(AccountColumns.SettingsColumns.SNAP_HEADERS, Integer.class)
159 .put(AccountColumns.SettingsColumns.REPLY_BEHAVIOR, Integer.class)
Paul Westbrook7ed53772013-01-23 10:19:55 -0800160 .put(AccountColumns.SettingsColumns.HIDE_CHECKBOXES, Integer.class)
Andy Huangbab92212012-11-16 18:32:18 -0800161 .put(AccountColumns.SettingsColumns.CONFIRM_DELETE, Integer.class)
162 .put(AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, Integer.class)
163 .put(AccountColumns.SettingsColumns.CONFIRM_SEND, Integer.class)
164 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX, String.class)
165 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, String.class)
166 .put(AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT, Integer.class)
167 .put(AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE, Integer.class)
168 .put(AccountColumns.SettingsColumns.SWIPE, Integer.class)
169 .put(AccountColumns.SettingsColumns.PRIORITY_ARROWS_ENABLED, Integer.class)
170 .put(AccountColumns.SettingsColumns.SETUP_INTENT_URI, String.class)
171 .put(AccountColumns.SettingsColumns.CONVERSATION_VIEW_MODE, Integer.class)
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800172 .put(AccountColumns.SettingsColumns.VEILED_ADDRESS_PATTERN, String.class)
Andy Huangbab92212012-11-16 18:32:18 -0800173 .put(AccountColumns.UPDATE_SETTINGS_URI, String.class)
174 .build();
175
176 // pull out the (ordered!) keyset from above to form the projection
177 public static final String[] ACCOUNTS_PROJECTION = ACCOUNTS_COLUMNS.keySet()
178 .toArray(new String[ACCOUNTS_COLUMNS.size()]);
Mindy Pereira6f92de62011-12-19 11:31:48 -0800179
Mindy Pereira33fe9082012-01-09 16:24:30 -0800180 public static final int ACCOUNT_ID_COLUMN = 0;
181 public static final int ACCOUNT_NAME_COLUMN = 1;
182 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
183 public static final int ACCOUNT_URI_COLUMN = 3;
184 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
185 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
Mindy Pereira31d79672012-06-26 14:43:09 -0700186 public static final int ACCOUNT_FULL_FOLDER_LIST_URI_COLUMN = 6;
187 public static final int ACCOUNT_SEARCH_URI_COLUMN = 7;
188 public static final int ACCOUNT_FROM_ADDRESSES_COLUMN = 8;
189 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 9;
190 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 10;
191 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 11;
192 public static final int ACCOUNT_UNDO_URI_COLUMN = 12;
193 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 13;
194 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
195 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
196 public static final int ACCOUNT_SEND_FEEDBACK_INTENT_URI_COLUMN = 16;
Paul Westbrook122f7c22012-08-20 17:50:31 -0700197 public static final int ACCOUNT_REAUTHENTICATION_INTENT_URI_COLUMN = 17;
198 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 18;
199 public static final int ACCOUNT_MIME_TYPE_COLUMN = 19;
200 public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 20;
201 public static final int ACCOUNT_COLOR_COLUMN = 21;
202 public static final int ACCOUNT_DEFAULT_RECENT_FOLDER_LIST_URI_COLUMN = 22;
203 public static final int ACCOUNT_MANUAL_SYNC_URI_COLUMN = 23;
Mark Wei9982fdb2012-08-30 18:27:46 -0700204 public static final int ACCOUNT_VIEW_INTENT_PROXY_URI_COLUMN = 24;
Paul Westbrookb8361c92012-09-27 10:57:14 -0700205 public static final int ACCOUNT_COOKIE_QUERY_URI_COLUMN = 25;
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700206
Paul Westbrookb8361c92012-09-27 10:57:14 -0700207 public static final int ACCOUNT_SETTINGS_SIGNATURE_COLUMN = 26;
208 public static final int ACCOUNT_SETTINGS_AUTO_ADVANCE_COLUMN = 27;
209 public static final int ACCOUNT_SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 28;
210 public static final int ACCOUNT_SETTINGS_SNAP_HEADERS_COLUMN = 29;
211 public static final int ACCOUNT_SETTINGS_REPLY_BEHAVIOR_COLUMN = 30;
Paul Westbrook7ed53772013-01-23 10:19:55 -0800212 public static final int ACCOUNT_SETTINGS_HIDE_CHECKBOXES_COLUMN = 31;
Paul Westbrookb8361c92012-09-27 10:57:14 -0700213 public static final int ACCOUNT_SETTINGS_CONFIRM_DELETE_COLUMN = 32;
214 public static final int ACCOUNT_SETTINGS_CONFIRM_ARCHIVE_COLUMN = 33;
215 public static final int ACCOUNT_SETTINGS_CONFIRM_SEND_COLUMN = 34;
216 public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_COLUMN = 35;
217 public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_NAME_COLUMN = 36;
218 public static final int ACCOUNT_SETTINGS_FORCE_REPLY_FROM_DEFAULT_COLUMN = 37;
219 public static final int ACCOUNT_SETTINGS_MAX_ATTACHMENT_SIZE_COLUMN = 38;
220 public static final int ACCOUNT_SETTINGS_SWIPE_COLUMN = 39;
221 public static final int ACCOUNT_SETTINGS_PRIORITY_ARROWS_ENABLED_COLUMN = 40;
222 public static final int ACCOUNT_SETTINGS_SETUP_INTENT_URI = 41;
Paul Westbrookfa255c02012-10-13 14:32:52 -0700223 public static final int ACCOUNT_SETTINGS_CONVERSATION_MODE_COLUMN = 42;
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800224 public static final int ACCOUNT_SETTINGS_VEILED_ADDRESS_PATTERN_COLUMN = 43;
Mindy Pereira33fe9082012-01-09 16:24:30 -0800225
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800226 public static final int ACCOUNT_UPDATE_SETTINGS_URI_COLUMN = 44;
Scott Kennedy0d0f8b02012-10-12 15:18:18 -0700227
Mindy Pereira6f92de62011-12-19 11:31:48 -0800228 public static final class AccountCapabilities {
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800229 /**
230 * Whether folders can be synchronized back to the server.
231 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800232 public static final int SYNCABLE_FOLDERS = 0x0001;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800233 /**
234 * Whether the server allows reporting spam back.
235 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800236 public static final int REPORT_SPAM = 0x0002;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800237 /**
Paul Westbrook77eee622012-07-10 13:41:57 -0700238 * Whether the server allows reporting phishing back.
239 */
240 public static final int REPORT_PHISHING = 0x0004;
241 /**
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800242 * Whether the server supports a concept of Archive: removing mail from the Inbox but
243 * keeping it around.
244 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700245 public static final int ARCHIVE = 0x0008;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800246 /**
247 * Whether the server will stop notifying on updates to this thread? This requires
248 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
249 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700250 public static final int MUTE = 0x0010;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800251 /**
252 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
253 * to be true, otherwise it should be ignored.
254 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700255 public static final int SERVER_SEARCH = 0x0020;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800256 /**
257 * Whether the server supports constraining search to a single folder. Requires
258 * SYNCABLE_FOLDERS, otherwise it should be ignored.
259 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700260 public static final int FOLDER_SERVER_SEARCH = 0x0040;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800261 /**
262 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
263 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700264 public static final int SANITIZED_HTML = 0x0080;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800265 /**
266 * Whether the server allows synchronization of draft messages. This does NOT require
267 * SYNCABLE_FOLDERS to be set.
268 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700269 public static final int DRAFT_SYNCHRONIZATION = 0x0100;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800270 /**
271 * Does the server allow the user to compose mails (and reply) using addresses other than
272 * their account name? For instance, GMail allows users to set FROM addresses that are
273 * different from account@gmail.com address. For instance, user@gmail.com could have another
274 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
275 * can compose (and reply) using either address.
276 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700277 public static final int MULTIPLE_FROM_ADDRESSES = 0x0200;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800278 /**
279 * Whether the server allows the original message to be included in the reply by setting a
280 * flag on the reply. If we can avoid including the entire previous message, we save on
281 * bandwidth (replies are shorter).
282 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700283 public static final int SMART_REPLY = 0x0400;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800284 /**
285 * Does this account support searching locally, on the device? This requires the backend
286 * storage to support a mechanism for searching.
287 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700288 public static final int LOCAL_SEARCH = 0x0800;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800289 /**
290 * Whether the server supports a notion of threaded conversations: where replies to messages
291 * are tagged to keep conversations grouped. This could be full threading (each message
292 * lists its parent) or conversation-level threading (each message lists one conversation
293 * which it belongs to)
294 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700295 public static final int THREADED_CONVERSATIONS = 0x1000;
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800296 /**
297 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
Mindy Pereira30fd47b2012-03-09 09:24:00 -0800298 * multiple folders on a single conversation)
Vikram Aggarwal859681b2012-02-03 10:02:24 -0800299 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700300 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000;
Mindy Pereira343ffeb2012-02-22 10:12:14 -0800301 /**
302 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
303 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700304 public static final int UNDO = 0x4000;
Paul Westbrook94e440d2012-02-24 11:03:47 -0800305 /**
306 * Whether the account provides help content.
307 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700308 public static final int HELP_CONTENT = 0x8000;
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800309 /**
Paul Westbrook517743e2012-03-22 10:40:46 -0700310 * Whether the account provides a way to send feedback content.
311 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700312 public static final int SEND_FEEDBACK = 0x10000;
Paul Westbrook517743e2012-03-22 10:40:46 -0700313 /**
Mindy Pereira7f0a9622012-02-29 15:00:34 -0800314 * Whether the account provides a mechanism for marking conversations as important.
315 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700316 public static final int MARK_IMPORTANT = 0x20000;
Marc Blank51144942012-03-20 13:59:32 -0700317 /**
318 * Whether initial conversation queries should use a limit parameter
319 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700320 public static final int INITIAL_CONVERSATION_LIMIT = 0x40000;
Marc Blankd3707922012-04-24 11:51:50 -0700321 /**
322 * Whether the account cannot be used for sending
323 */
Paul Westbrook77eee622012-07-10 13:41:57 -0700324 public static final int SENDING_UNAVAILABLE = 0x80000;
Paul Westbrookef362542012-08-27 14:53:32 -0700325 /**
326 * Whether the account supports discarding drafts from a conversation. This should be
327 * removed when all providers support this capability
328 */
329 public static final int DISCARD_CONVERSATION_DRAFTS = 0x100000;
Mindy Pereira6f92de62011-12-19 11:31:48 -0800330 }
331
332 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800333 /**
334 * This string column contains the human visible name for the account.
335 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800336 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800337
338 /**
Vikram Aggarwal6dde1782012-03-12 17:16:48 -0700339 * This integer contains the type of the account: Google versus non google. This is not
340 * returned by the UIProvider, rather this is a notion in the system.
341 */
342 public static final String TYPE = "type";
343
344 /**
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800345 * This integer column returns the version of the UI provider schema from which this
346 * account provider will return results.
347 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800348 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800349
350 /**
351 * This string column contains the uri to directly access the information for this account.
352 */
Mindy Pereira6349a042012-01-04 11:25:01 -0800353 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800354
355 /**
Andy Huange0b83b82012-03-06 19:57:04 -0800356 * This integer column contains a bit field of the possible capabilities that this account
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800357 * supports.
358 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800359 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800360
361 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800362 * This string column contains the content provider uri to return the
363 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800364 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800365 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800366
367 /**
Mindy Pereira31d79672012-06-26 14:43:09 -0700368 * This string column contains the content provider uri to return the
369 * list of all folders for this account.
370 */
371 public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri";
372
373 /**
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800374 * This string column contains the content provider uri that can be queried for search
375 * results.
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800376 * The supported query parameters are limited to those listed
Andy Huangd8e249e2012-03-21 17:01:37 -0700377 * in {@link SearchQueryParameters}
Paul Westbrook1475a7a2012-03-08 15:06:27 -0800378 * The cursor returned from this query is expected have one row, where the columnm are a
Andy Huangd8e249e2012-03-21 17:01:37 -0700379 * subset of the columns specified in {@link FolderColumns}
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800380 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800381 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800382
383 /**
Mindy Pereira92551d02012-04-05 11:31:12 -0700384 * This string column contains a json array of json objects representing
385 * custom from addresses for this account or null if there are none.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800386 */
Mindy Pereira92551d02012-04-05 11:31:12 -0700387 public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800388
389 /**
390 * This string column contains the content provider uri that can be used to save (insert)
Mindy Pereira82cc5662012-01-09 17:29:30 -0800391 * new draft messages for this account. NOTE: This might be better to
392 * be an update operation on the messageUri.
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800393 */
Paul Westbrook72e2ea82012-10-22 16:25:22 -0700394 @Deprecated
Mindy Pereira33fe9082012-01-09 16:24:30 -0800395 public static final String SAVE_DRAFT_URI = "saveDraftUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800396
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800397 /**
398 * This string column contains the content provider uri that can be used to send
399 * a message for this account.
400 * NOTE: This might be better to be an update operation on the messageUri.
401 */
Paul Westbrook72e2ea82012-10-22 16:25:22 -0700402 @Deprecated
Mindy Pereira7ed1c112012-01-18 10:59:25 -0800403 public static final String SEND_MAIL_URI = "sendMailUri";
Mindy Pereira82cc5662012-01-09 17:29:30 -0800404
405 /**
406 * This string column contains the content provider uri that can be used
407 * to expunge a message from this account. NOTE: This might be better to
408 * be an update operation on the messageUri.
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700409 * When {@link android.content.ContentResolver#update(Uri, ContentValues, String, String[])}
410 * is called with this uri, the {@link ContentValues} object is expected to have
411 * {@link BaseColumns#_ID} specified with the local message id of the message.
Mindy Pereira82cc5662012-01-09 17:29:30 -0800412 */
413 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
Mindy Pereira96b5c352012-02-01 11:33:40 -0800414
415 /**
416 * This string column contains the content provider uri that can be used
417 * to undo the last committed action.
418 */
Mindy Pereira9600dac2012-02-17 15:59:25 -0800419 public static final String UNDO_URI = "undoUri";
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800420
421 /**
Paul Westbrook9912eee2012-02-22 14:49:03 -0800422 * Uri for EDIT intent that will cause the settings screens for this account type to be
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800423 * shown.
Paul Westbrooke5503552012-03-28 00:35:57 -0700424 * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate
425 * which settings the user wants to edit.
Paul Westbrook2861b6a2012-02-15 15:25:34 -0800426 * TODO: When we want to support a heterogeneous set of account types, this value may need
427 * to be moved to a global content provider.
428 */
429 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
Marc Blank9ace18a2012-02-21 16:34:07 -0800430
431 /**
Paul Westbrook94e440d2012-02-24 11:03:47 -0800432 * Uri for VIEW intent that will cause the help screens for this account type to be
433 * shown.
434 * TODO: When we want to support a heterogeneous set of account types, this value may need
435 * to be moved to a global content provider.
436 */
437 public static String HELP_INTENT_URI = "helpIntentUri";
438
439 /**
Paul Westbrook517743e2012-03-22 10:40:46 -0700440 * Uri for VIEW intent that will cause the send feedback for this account type to be
441 * shown.
442 * TODO: When we want to support a heterogeneous set of account types, this value may need
443 * to be moved to a global content provider.
444 */
445 public static String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri";
446
447 /**
Paul Westbrook122f7c22012-08-20 17:50:31 -0700448 * Uri for VIEW intent that will cause the user to be prompted for authentication for
449 * this account. startActivityForResult() will be called with this intent. Activities that
Vikram Aggarwal41b9e8f2012-09-25 10:15:04 -0700450 * handle this intent are expected to return {@link android.app.Activity#RESULT_OK} if the
Paul Westbrook122f7c22012-08-20 17:50:31 -0700451 * user successfully authenticated.
452 */
453 public static String REAUTHENTICATION_INTENT_URI = "reauthenticationUri";
454
455 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800456 * This int column contains the current sync status of the account (the logical AND of the
457 * sync status of folders in this account)
458 */
459 public static final String SYNC_STATUS = "syncStatus";
Mindy Pereira23755e22012-02-27 13:58:04 -0800460 /**
461 * Uri for VIEW intent that will cause the compose screens for this type
462 * of account to be shown.
463 */
464 public static final String COMPOSE_URI = "composeUri";
Mindy Pereira898cd382012-03-06 08:42:47 -0800465 /**
466 * Mime-type defining this account.
467 */
468 public static final String MIME_TYPE = "mimeType";
Vikram Aggarwal27e85f22012-03-05 16:29:17 -0800469 /**
470 * URI for location of recent folders viewed on this account.
471 */
472 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
Marc Blankb2878332012-05-17 15:16:59 -0700473 /**
Vikram Aggarwal27d89ad2012-06-12 13:38:40 -0700474 * URI for default recent folders for this account, if any.
475 */
476 public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri";
477 /**
Andy Huangbab92212012-11-16 18:32:18 -0800478 * Color (integer) used for this account (for Email/Combined view)
Marc Blankb2878332012-05-17 15:16:59 -0700479 */
480 public static final String COLOR = "color";
Mindy Pereirab378d642012-07-11 09:46:20 -0700481 /**
482 * URI for forcing a manual sync of this account.
483 */
484 public static final String MANUAL_SYNC_URI = "manualSyncUri";
Mark Wei9982fdb2012-08-30 18:27:46 -0700485 /**
486 * Optional URI of this account for proxying view intents.
487 */
488 public static final String VIEW_INTENT_PROXY_URI = "viewProxyUri";
Paul Westbrookb8361c92012-09-27 10:57:14 -0700489 /**
490 * Optional URI for querying for the cookie needed for accessing inline content. The cookie
491 * specified here will be set on the uri specified in the
492 * {@link ConversationColumns#CONVERSATION_BASE_URI} column. The cursor returned from this
493 * query is expected have one row, where the columns are specified in
494 * {@link AccountCookieColumns}
495 */
496 public static final String ACCOUNT_COOKIE_QUERY_URI = "accountCookieUri";
Scott Kennedy0d0f8b02012-10-12 15:18:18 -0700497 /**
498 * URI to be used with an update() ContentResolver call with a {@link ContentValues} object
499 * where the keys are from the {@link AccountColumns.SettingsColumns}, and the values are
500 * the new values.
501 */
502 public static final String UPDATE_SETTINGS_URI = "updateSettingsUri";
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700503
504 public static final class SettingsColumns {
505 /**
506 * String column containing the contents of the signature for this account. If no
507 * signature has been specified, the value will be null.
508 */
509 public static final String SIGNATURE = "signature";
510
511 /**
512 * Integer column containing the user's specified auto-advance policy. This value will
513 * be one of the values in {@link UIProvider.AutoAdvance}
514 */
515 public static final String AUTO_ADVANCE = "auto_advance";
516
517 /**
518 * Integer column containing the user's specified message text size preference. This
519 * value will be one of the values in {@link UIProvider.MessageTextSize}
520 */
521 public static final String MESSAGE_TEXT_SIZE = "message_text_size";
522
523 /**
524 * Integer column contaning the user's specified snap header preference. This value
525 * will be one of the values in {@link UIProvider.SnapHeaderValue}
526 */
527 public static final String SNAP_HEADERS = "snap_headers";
528
529 /**
530 * Integer column containing the user's specified default reply behavior. This value
531 * will be one of the values in {@link UIProvider.DefaultReplyBehavior}
532 */
533 public static final String REPLY_BEHAVIOR = "reply_behavior";
534
535 /**
536 * Integer column containing the user's specified checkbox preference. A
Paul Westbrook7ed53772013-01-23 10:19:55 -0800537 * non zero value means to hide checkboxes.
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700538 */
Paul Westbrook7ed53772013-01-23 10:19:55 -0800539 public static final String HIDE_CHECKBOXES = "hide_checkboxes";
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700540
541 /**
542 * Integer column containing the user's specified confirm delete preference value.
543 * A non zero value indicates that the user has indicated that a confirmation should
544 * be shown when a delete action is performed.
545 */
546 public static final String CONFIRM_DELETE = "confirm_delete";
547
548 /**
549 * Integer column containing the user's specified confirm archive preference value.
550 * A non zero value indicates that the user has indicated that a confirmation should
551 * be shown when an archive action is performed.
552 */
553 public static final String CONFIRM_ARCHIVE = "confirm_archive";
554
555 /**
556 * Integer column containing the user's specified confirm send preference value.
557 * A non zero value indicates that the user has indicated that a confirmation should
558 * be shown when a send action is performed.
559 */
560 public static final String CONFIRM_SEND = "confirm_send";
561 /**
Mindy Pereira571de222012-07-20 09:28:44 -0700562 * String containing the URI for the default inbox for this account.
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700563 */
564 public static final String DEFAULT_INBOX = "default_inbox";
565 /**
Vikram Aggarwal5e63e8a2012-07-19 10:05:24 -0700566 * String containing the name of the default Inbox for this account
567 */
568 public static final String DEFAULT_INBOX_NAME = "default_inbox_name";
569 /**
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700570 * Integer column containing a non zero value if replies should always be sent from
571 * a default address instead of a recipient.
572 */
Mindy Pereira3cd4f402012-07-17 11:16:18 -0700573 public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default";
574 /**
575 * Integer column containing the max attachment size in kb.
576 */
577 public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size";
Mindy Pereira71a8f5e2012-07-25 14:33:18 -0700578 /**
579 * Integer column containing a value matching one of the constants from {@link Swipe}
580 */
581 public static final String SWIPE = "swipe";
Vikram Aggarwal707f24c2012-07-31 15:59:36 -0700582 /**
Andy Huangbab92212012-11-16 18:32:18 -0800583 * Integer column containing whether priority inbox arrows are enabled.
Vikram Aggarwal707f24c2012-07-31 15:59:36 -0700584 */
585 public static final String PRIORITY_ARROWS_ENABLED = "priority_inbox_arrows_enabled";
Marc Blank57899082012-09-05 11:35:57 -0700586 /**
587 * Uri for EDIT intent that will cause account-specific setup UI to be shown. If not
588 * null, this intent should be used when an account is "entered" (i.e. viewing a folder
589 * in the account, etc.)
590 */
591 public static final String SETUP_INTENT_URI = "setup_intent_uri";
Paul Westbrookfa255c02012-10-13 14:32:52 -0700592 /**
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800593 * The regex that defines a veiled address, something that must be hidden from user
594 * view because it is temporary, long and clumsy.
595 */
Vikram Aggarwal6c3875a2013-01-15 16:00:11 -0800596 public static final String VEILED_ADDRESS_PATTERN = "veiled_address_pattern";
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800597 /**
Paul Westbrookfa255c02012-10-13 14:32:52 -0700598 * Integer column containing the Conversation view mode. This value will match one of
599 * constants from {@link ConversationViewMode}
600 */
601 public static final String CONVERSATION_VIEW_MODE = "conversation_view_mode";
Paul Westbrookb1f573c2012-04-06 11:38:28 -0700602 }
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800603 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800604
Vikram Aggarwala9a05d52012-10-25 13:51:10 -0700605 /**
606 * Map to go from account column name to account column. Can only be used through
607 * {@link #getAccountColumn(String)}.
608 */
609 private static final ImmutableMap<String, Integer> ACCOUNT_TO_ID_MAP =
610 new ImmutableMap.Builder<String, Integer>()
611 .put(BaseColumns._ID, ACCOUNT_ID_COLUMN)
612 .put(AccountColumns.NAME, ACCOUNT_NAME_COLUMN)
613 .put(AccountColumns.TYPE, -1)
614 .put(AccountColumns.PROVIDER_VERSION, ACCOUNT_PROVIDER_VERISON_COLUMN)
615 .put(AccountColumns.URI, ACCOUNT_URI_COLUMN)
616 .put(AccountColumns.CAPABILITIES, ACCOUNT_CAPABILITIES_COLUMN)
617 .put(AccountColumns.FOLDER_LIST_URI, ACCOUNT_FOLDER_LIST_URI_COLUMN)
618 .put(AccountColumns.FULL_FOLDER_LIST_URI, ACCOUNT_FULL_FOLDER_LIST_URI_COLUMN)
619 .put(AccountColumns.SEARCH_URI, ACCOUNT_SEARCH_URI_COLUMN)
620 .put(AccountColumns.ACCOUNT_FROM_ADDRESSES, ACCOUNT_FROM_ADDRESSES_COLUMN)
621 .put(AccountColumns.SAVE_DRAFT_URI, ACCOUNT_SAVE_DRAFT_URI_COLUMN)
622 .put(AccountColumns.SEND_MAIL_URI, ACCOUNT_SEND_MESSAGE_URI_COLUMN)
623 .put(AccountColumns.EXPUNGE_MESSAGE_URI, ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN)
624 .put(AccountColumns.UNDO_URI, ACCOUNT_UNDO_URI_COLUMN)
625 .put(AccountColumns.SETTINGS_INTENT_URI, ACCOUNT_SETTINGS_INTENT_URI_COLUMN)
626 .put(AccountColumns.HELP_INTENT_URI, ACCOUNT_HELP_INTENT_URI_COLUMN)
627 .put(AccountColumns.SEND_FEEDBACK_INTENT_URI, ACCOUNT_SEND_FEEDBACK_INTENT_URI_COLUMN)
628 .put(AccountColumns.REAUTHENTICATION_INTENT_URI,
629 ACCOUNT_REAUTHENTICATION_INTENT_URI_COLUMN)
630 .put(AccountColumns.SYNC_STATUS, ACCOUNT_SYNC_STATUS_COLUMN)
631 .put(AccountColumns.COMPOSE_URI, ACCOUNT_COMPOSE_INTENT_URI_COLUMN)
632 .put(AccountColumns.MIME_TYPE, ACCOUNT_MIME_TYPE_COLUMN)
633 .put(AccountColumns.RECENT_FOLDER_LIST_URI, ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN)
634 .put(AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI,
635 ACCOUNT_DEFAULT_RECENT_FOLDER_LIST_URI_COLUMN)
636 .put(AccountColumns.COLOR, ACCOUNT_COLOR_COLUMN)
637 .put(AccountColumns.MANUAL_SYNC_URI, ACCOUNT_MANUAL_SYNC_URI_COLUMN)
638 .put(AccountColumns.VIEW_INTENT_PROXY_URI, ACCOUNT_VIEW_INTENT_PROXY_URI_COLUMN)
639 .put(AccountColumns.ACCOUNT_COOKIE_QUERY_URI, ACCOUNT_COOKIE_QUERY_URI_COLUMN)
640 .put(AccountColumns.SettingsColumns.SIGNATURE, ACCOUNT_SETTINGS_SIGNATURE_COLUMN)
641 .put(AccountColumns.SettingsColumns.AUTO_ADVANCE, ACCOUNT_SETTINGS_AUTO_ADVANCE_COLUMN)
642 .put(AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE,
643 ACCOUNT_SETTINGS_MESSAGE_TEXT_SIZE_COLUMN)
644 .put(AccountColumns.SettingsColumns.SNAP_HEADERS,ACCOUNT_SETTINGS_SNAP_HEADERS_COLUMN)
645 .put(AccountColumns.SettingsColumns.REPLY_BEHAVIOR,
646 ACCOUNT_SETTINGS_REPLY_BEHAVIOR_COLUMN)
Paul Westbrook7ed53772013-01-23 10:19:55 -0800647 .put(AccountColumns.SettingsColumns.HIDE_CHECKBOXES,
648 ACCOUNT_SETTINGS_HIDE_CHECKBOXES_COLUMN)
Vikram Aggarwala9a05d52012-10-25 13:51:10 -0700649 .put(AccountColumns.SettingsColumns.CONFIRM_DELETE,
650 ACCOUNT_SETTINGS_CONFIRM_DELETE_COLUMN)
651 .put(AccountColumns.SettingsColumns.CONFIRM_ARCHIVE,
652 ACCOUNT_SETTINGS_CONFIRM_ARCHIVE_COLUMN)
653 .put(AccountColumns.SettingsColumns.CONFIRM_SEND,
654 ACCOUNT_SETTINGS_CONFIRM_SEND_COLUMN)
655 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX,
656 ACCOUNT_SETTINGS_DEFAULT_INBOX_COLUMN)
657 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME,
658 ACCOUNT_SETTINGS_DEFAULT_INBOX_NAME_COLUMN)
659 .put(AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT,
660 ACCOUNT_SETTINGS_FORCE_REPLY_FROM_DEFAULT_COLUMN)
661 .put(AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE,
662 ACCOUNT_SETTINGS_MAX_ATTACHMENT_SIZE_COLUMN)
663 .put(AccountColumns.SettingsColumns.SWIPE, ACCOUNT_SETTINGS_SWIPE_COLUMN)
664 .put(AccountColumns.SettingsColumns.PRIORITY_ARROWS_ENABLED,
665 ACCOUNT_SETTINGS_PRIORITY_ARROWS_ENABLED_COLUMN)
666 .put(AccountColumns.SettingsColumns.SETUP_INTENT_URI,
667 ACCOUNT_SETTINGS_SETUP_INTENT_URI)
668 .put(AccountColumns.SettingsColumns.CONVERSATION_VIEW_MODE,
669 ACCOUNT_SETTINGS_CONVERSATION_MODE_COLUMN)
Vikram Aggarwal69a6cdf2013-01-08 16:05:17 -0800670 .put(AccountColumns.SettingsColumns.VEILED_ADDRESS_PATTERN,
671 ACCOUNT_SETTINGS_VEILED_ADDRESS_PATTERN_COLUMN)
Scott Kennedy0d0f8b02012-10-12 15:18:18 -0700672 .put(AccountColumns.UPDATE_SETTINGS_URI, ACCOUNT_UPDATE_SETTINGS_URI_COLUMN)
Vikram Aggarwala9a05d52012-10-25 13:51:10 -0700673 .build();
674
675 /**
676 * Returns the column number for a given column name. The column numbers are guaranteed to be
677 * unique for distinct column names. Column names are values from {@link AccountColumns} while
678 * columns are integers.
679 * @param columnName
680 * @return
681 */
682 public static final int getAccountColumn(String columnName) {
683 final Integer id = ACCOUNT_TO_ID_MAP.get(columnName);
684 if (id == null) {
685 return -1;
686 }
687 return id.intValue();
688 }
689
Paul Westbrookb8361c92012-09-27 10:57:14 -0700690 public static final String[] ACCOUNT_COOKIE_PROJECTION = {
691 AccountCookieColumns.COOKIE
692 };
693
694 public static final class AccountCookieColumns {
695 /**
696 * String column containing the cookie string for this account.
697 */
698 public static final String COOKIE = "cookie";
699 }
700
Paul Westbrook8130e6f2012-03-06 13:51:01 -0800701 public static final class SearchQueryParameters {
702 /**
703 * Parameter used to specify the search query.
704 */
705 public static final String QUERY = "query";
706
707 /**
708 * If specified, the query results will be limited to this folder.
709 */
710 public static final String FOLDER = "folder";
711
712 private SearchQueryParameters() {}
713 }
714
Marc Blank51144942012-03-20 13:59:32 -0700715 public static final class ConversationListQueryParameters {
716 public static final String DEFAULT_LIMIT = "50";
717 /**
718 * Parameter used to limit the number of rows returned by a conversation list query
719 */
720 public static final String LIMIT = "limit";
721
Paul Westbrook5f2876a2012-03-20 18:47:22 -0700722 /**
723 * Parameter used to control whether the this query a remote server.
724 */
725 public static final String USE_NETWORK = "use_network";
726
Paul Westbrook4880b5d2012-07-24 09:10:25 -0700727 /**
728 * Parameter used to allow the caller to indicate desire to receive all notifications.
729 * (Including ones for user initiated actions)
730 */
731 public static final String ALL_NOTIFICATIONS = "all_notifications";
732
Marc Blank51144942012-03-20 13:59:32 -0700733 private ConversationListQueryParameters() {}
734 }
735
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800736 // We define a "folder" as anything that contains a list of conversations.
737 public static final String FOLDER_LIST_TYPE =
738 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
739 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800740 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800741
742 public static final String[] FOLDERS_PROJECTION = {
743 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800744 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800745 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800746 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800747 FolderColumns.CAPABILITIES,
Mindy Pereira0973b202011-12-21 15:48:12 -0800748 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800749 FolderColumns.CONVERSATION_LIST_URI,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800750 FolderColumns.CHILD_FOLDERS_LIST_URI,
751 FolderColumns.UNREAD_COUNT,
Marc Blankc8a99422012-01-19 14:27:47 -0800752 FolderColumns.TOTAL_COUNT,
Mindy Pereira77528642012-02-17 15:51:10 -0800753 FolderColumns.REFRESH_URI,
Marc Blank9ace18a2012-02-21 16:34:07 -0800754 FolderColumns.SYNC_STATUS,
Mindy Pereira78664722012-03-05 13:53:07 -0800755 FolderColumns.LAST_SYNC_RESULT,
756 FolderColumns.TYPE,
Mindy Pereira9275a062012-03-08 15:12:14 -0800757 FolderColumns.ICON_RES_ID,
758 FolderColumns.BG_COLOR,
Marc Blank48a4aed2012-03-10 14:07:00 -0800759 FolderColumns.FG_COLOR,
Mindy Pereirac1e87902012-06-26 11:51:41 -0700760 FolderColumns.LOAD_MORE_URI,
761 FolderColumns.HIERARCHICAL_DESC
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800762 };
763
Mindy Pereira7e5de7a2012-03-13 15:36:03 -0700764 public static final int FOLDER_ID_COLUMN = 0;
765 public static final int FOLDER_URI_COLUMN = 1;
766 public static final int FOLDER_NAME_COLUMN = 2;
767 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
768 public static final int FOLDER_CAPABILITIES_COLUMN = 4;
769 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
770 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
771 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
772 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
773 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
774 public static final int FOLDER_REFRESH_URI_COLUMN = 10;
775 public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
776 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
777 public static final int FOLDER_TYPE_COLUMN = 13;
778 public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
779 public static final int FOLDER_BG_COLOR_COLUMN = 15;
780 public static final int FOLDER_FG_COLOR_COLUMN = 16;
781 public static final int FOLDER_LOAD_MORE_URI_COLUMN = 17;
Mindy Pereirac1e87902012-06-26 11:51:41 -0700782 public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 18;
Mindy Pereira78664722012-03-05 13:53:07 -0800783
784 public static final class FolderType {
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700785 /** A user defined label. */
Mindy Pereira78664722012-03-05 13:53:07 -0800786 public static final int DEFAULT = 0;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700787 /** A system defined inbox */
Mindy Pereira78664722012-03-05 13:53:07 -0800788 public static final int INBOX = 1;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700789 /** A system defined containing mails to be edited before sending. */
Mindy Pereira78664722012-03-05 13:53:07 -0800790 public static final int DRAFT = 2;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700791 /** A system defined folder containing mails <b>to be</b> sent */
Mindy Pereira78664722012-03-05 13:53:07 -0800792 public static final int OUTBOX = 3;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700793 /** A system defined folder containing sent mails */
Mindy Pereira78664722012-03-05 13:53:07 -0800794 public static final int SENT = 4;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700795 /** A system defined trash folder */
Mindy Pereira78664722012-03-05 13:53:07 -0800796 public static final int TRASH = 5;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700797 /** A system defined spam folder */
Mindy Pereira78664722012-03-05 13:53:07 -0800798 public static final int SPAM = 6;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700799 /** A system defined starred folder */
Vikram Aggarwal04dc8192012-04-09 13:07:19 -0700800 public static final int STARRED = 7;
Vikram Aggarwal58cad2e2012-08-28 16:18:23 -0700801 /** Any other system label that we do not have a specific name for. */
Mindy Pereira9ba42512012-08-14 11:52:48 -0700802 public static final int OTHER_PROVIDER_FOLDER = 8;
mindypa8492632012-09-24 09:27:54 -0700803 /** All mail folder **/
804 public static final int ALL_MAIL = 9;
Mindy Pereira78664722012-03-05 13:53:07 -0800805 }
Mindy Pereira818143e2012-01-11 13:59:49 -0800806
Mindy Pereira0973b202011-12-21 15:48:12 -0800807 public static final class FolderCapabilities {
808 public static final int SYNCABLE = 0x0001;
809 public static final int PARENT = 0x0002;
810 public static final int CAN_HOLD_MAIL = 0x0004;
811 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Marc Blanka8352052012-04-04 11:37:48 -0700812 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800813 * For accounts that support archive, this will indicate that this folder supports
814 * the archive functionality.
815 */
816 public static final int ARCHIVE = 0x0010;
817
818 /**
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700819 * This will indicated that this folder supports the delete functionality.
820 */
821 public static final int DELETE = 0x0020;
822
823 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800824 * For accounts that support report spam, this will indicate that this folder supports
825 * the report spam functionality.
826 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700827 public static final int REPORT_SPAM = 0x0040;
Paul Westbrook334e64a2012-02-23 13:26:35 -0800828
829 /**
Paul Westbrook77eee622012-07-10 13:41:57 -0700830 * For accounts that support report spam, this will indicate that this folder supports
Paul Westbrook76b20622012-07-12 11:45:43 -0700831 * the mark not spam functionality.
Paul Westbrook77eee622012-07-10 13:41:57 -0700832 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700833 public static final int MARK_NOT_SPAM = 0x0080;
Paul Westbrook77eee622012-07-10 13:41:57 -0700834
835 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -0800836 * For accounts that support mute, this will indicate if a mute is performed from within
837 * this folder, the action is destructive.
838 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700839 public static final int DESTRUCTIVE_MUTE = 0x0100;
Marc Blanka8352052012-04-04 11:37:48 -0700840
841 /**
842 * Indicates that a folder supports settings (sync lookback, etc.)
843 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700844 public static final int SUPPORTS_SETTINGS = 0x0200;
Vikram Aggarwal04dc8192012-04-09 13:07:19 -0700845 /**
846 * All the messages in this folder are important.
847 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700848 public static final int ONLY_IMPORTANT = 0x0400;
Marc Blank386243f2012-05-25 10:40:59 -0700849 /**
850 * Deletions in this folder can't be undone (could include archive if desirable)
851 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700852 public static final int DELETE_ACTION_FINAL = 0x0800;
Marc Blanka6b671d2012-05-25 12:52:02 -0700853 /**
854 * This folder is virtual, i.e. contains conversations potentially pulled from other
855 * folders, potentially even from different accounts. Examples might be a "starred"
856 * folder, or an "unread" folder (per account or provider-wide)
857 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700858 public static final int IS_VIRTUAL = 0x1000;
Paul Westbrook76b20622012-07-12 11:45:43 -0700859
860 /**
861 * For accounts that support report phishing, this will indicate that this folder supports
862 * the report phishing functionality.
863 */
Paul Westbrook6102c7d2012-08-19 13:20:24 -0700864 public static final int REPORT_PHISHING = 0x2000;
Mindy Pereira0973b202011-12-21 15:48:12 -0800865 }
866
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800867 public static final class FolderColumns {
Paul Westbrook0b63e8d2012-03-13 11:52:42 -0700868 /**
Paul Westbrook0b63e8d2012-03-13 11:52:42 -0700869 * This string column contains the uri of the folder.
870 */
Mindy Pereira77528642012-02-17 15:51:10 -0800871 public static final String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800872 /**
873 * This string column contains the human visible name for the folder.
874 */
875 public static final String NAME = "name";
876 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800877 * This int column represents the capabilities of the folder specified by
878 * FolderCapabilities flags.
879 */
880 public static String CAPABILITIES = "capabilities";
881 /**
Mindy Pereirafc2277e2012-01-11 10:23:44 -0800882 * This int column represents whether or not this folder has any
Mindy Pereira750cc732011-12-21 13:32:29 -0800883 * child folders.
884 */
885 public static String HAS_CHILDREN = "hasChildren";
886 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800887 * This int column represents how large the sync window is.
888 */
889 public static String SYNC_WINDOW = "syncWindow";
890 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800891 * This string column contains the content provider uri to return the
892 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800893 */
894 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800895 /**
896 * This string column contains the content provider uri to return the
897 * list of child folders of this folder.
898 */
Mindy Pereira77528642012-02-17 15:51:10 -0800899 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800900
Mindy Pereira77528642012-02-17 15:51:10 -0800901 public static final String UNREAD_COUNT = "unreadCount";
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800902
Mindy Pereira77528642012-02-17 15:51:10 -0800903 public static final String TOTAL_COUNT = "totalCount";
Mindy Pereira9c002102012-02-17 14:45:58 -0800904 /**
905 * This string column contains the content provider uri to force a
906 * refresh of this folder.
907 */
Mindy Pereira77528642012-02-17 15:51:10 -0800908 public static final String REFRESH_URI = "refreshUri";
909 /**
Marc Blank9ace18a2012-02-21 16:34:07 -0800910 * This int column contains current sync status of the folder; some combination of the
911 * SyncStatus bits defined above
Mindy Pereira77528642012-02-17 15:51:10 -0800912 */
Marc Blank9ace18a2012-02-21 16:34:07 -0800913 public static final String SYNC_STATUS = "syncStatus";
914 /**
915 * This int column contains the sync status of the last sync attempt; one of the
916 * LastSyncStatus values defined above
917 */
918 public static final String LAST_SYNC_RESULT = "lastSyncResult";
Mindy Pereira78664722012-03-05 13:53:07 -0800919 /**
920 * This long column contains the icon res id for this folder, or 0 if there is none.
921 */
922 public static final String ICON_RES_ID = "iconResId";
923 /**
924 * This int column contains the type of the folder. Zero is default.
925 */
926 public static final String TYPE = "type";
Mindy Pereira9275a062012-03-08 15:12:14 -0800927 /**
928 * String representing the integer background color associated with this
929 * folder, or null.
930 */
931 public static final String BG_COLOR = "bgColor";
932 /**
933 * String representing the integer of the foreground color associated
934 * with this folder, or null.
935 */
936 public static final String FG_COLOR = "fgColor";
Marc Blank48a4aed2012-03-10 14:07:00 -0800937 /**
938 * String with the content provider Uri used to request more items in the folder, or null.
939 */
940 public static final String LOAD_MORE_URI = "loadMoreUri";
Vikram Aggarwal27d89ad2012-06-12 13:38:40 -0700941
Mindy Pereirac1e87902012-06-26 11:51:41 -0700942 /**
943 * Possibly empty string that describes the full hierarchy of a folder
944 * along with its name.
945 */
946 public static final String HIERARCHICAL_DESC = "hierarchicalDesc";
947
Vikram Aggarwalff7d02a2012-01-11 16:37:45 -0800948 public FolderColumns() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800949 }
950
Mindy Pereiraa1406072011-12-22 10:54:06 -0800951 // We define a "folder" as anything that contains a list of conversations.
952 public static final String CONVERSATION_LIST_TYPE =
953 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
954 public static final String CONVERSATION_TYPE =
955 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
956
Mindy Pereira9cdc4062012-02-02 14:18:08 -0800957
Mindy Pereiraa1406072011-12-22 10:54:06 -0800958 public static final String[] CONVERSATION_PROJECTION = {
959 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800960 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800961 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800962 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800963 ConversationColumns.SNIPPET,
Mindy Pereira648df3f2012-07-19 09:20:26 -0700964 ConversationColumns.CONVERSATION_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800965 ConversationColumns.DATE_RECEIVED_MS,
Mindy Pereira4db59c52012-01-12 09:45:13 -0800966 ConversationColumns.HAS_ATTACHMENTS,
967 ConversationColumns.NUM_MESSAGES,
968 ConversationColumns.NUM_DRAFTS,
969 ConversationColumns.SENDING_STATE,
Marc Blankc8a99422012-01-19 14:27:47 -0800970 ConversationColumns.PRIORITY,
971 ConversationColumns.READ,
Mindy Pereira36b6c8b2012-02-03 14:16:07 -0800972 ConversationColumns.STARRED,
Mindy Pereira22657522012-03-14 13:27:59 -0700973 ConversationColumns.RAW_FOLDERS,
974 ConversationColumns.FLAGS,
Mindy Pereira87d535f2012-03-23 11:15:56 -0700975 ConversationColumns.PERSONAL_LEVEL,
976 ConversationColumns.SPAM,
Paul Westbrook76b20622012-07-12 11:45:43 -0700977 ConversationColumns.PHISHING,
Marc Blank92939fc2012-04-30 14:58:40 -0700978 ConversationColumns.MUTED,
Marc Blanka6b671d2012-05-25 12:52:02 -0700979 ConversationColumns.COLOR,
Mindy Pereira648df3f2012-07-19 09:20:26 -0700980 ConversationColumns.ACCOUNT_URI,
Paul Westbrook41dca182012-08-07 10:43:42 -0700981 ConversationColumns.SENDER_INFO,
Andy Huangf98bc892012-08-07 18:22:09 -0700982 ConversationColumns.CONVERSATION_BASE_URI,
983 ConversationColumns.REMOTE
Mindy Pereiraa1406072011-12-22 10:54:06 -0800984 };
985
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800986 // These column indexes only work when the caller uses the
987 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800988 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800989 public static final int CONVERSATION_URI_COLUMN = 1;
990 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
991 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
992 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
Mindy Pereira648df3f2012-07-19 09:20:26 -0700993 public static final int CONVERSATION_INFO_COLUMN = 5;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800994 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
995 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereira4db59c52012-01-12 09:45:13 -0800996 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
997 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
998 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
999 public static final int CONVERSATION_PRIORITY_COLUMN = 11;
Marc Blankc8a99422012-01-19 14:27:47 -08001000 public static final int CONVERSATION_READ_COLUMN = 12;
1001 public static final int CONVERSATION_STARRED_COLUMN = 13;
Mindy Pereira00ffece2012-07-27 08:49:56 -07001002 public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 14;
1003 public static final int CONVERSATION_FLAGS_COLUMN = 15;
1004 public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 16;
1005 public static final int CONVERSATION_IS_SPAM_COLUMN = 17;
1006 public static final int CONVERSATION_IS_PHISHING_COLUMN = 18;
1007 public static final int CONVERSATION_MUTED_COLUMN = 19;
1008 public static final int CONVERSATION_COLOR_COLUMN = 20;
1009 public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 21;
1010 public static final int CONVERSATION_SENDER_INFO_COLUMN = 22;
Paul Westbrook41dca182012-08-07 10:43:42 -07001011 public static final int CONVERSATION_BASE_URI_COLUMN = 23;
Paul Westbrookb8361c92012-09-27 10:57:14 -07001012 public static final int CONVERSATION_REMOTE_COLUMN = 24;
Mindy Pereira4db59c52012-01-12 09:45:13 -08001013
1014 public static final class ConversationSendingState {
Mindy Pereiraa4571372012-01-12 14:04:21 -08001015 public static final int OTHER = 0;
Paul Westbrook2c636302012-08-03 10:12:41 -07001016 public static final int QUEUED = 1;
1017 public static final int SENDING = 2;
1018 public static final int SENT = 3;
Mindy Pereira4db59c52012-01-12 09:45:13 -08001019 public static final int SEND_ERROR = -1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -08001020 }
Mindy Pereira4db59c52012-01-12 09:45:13 -08001021
1022 public static final class ConversationPriority {
Mindy Pereira22657522012-03-14 13:27:59 -07001023 public static final int DEFAULT = 0;
1024 public static final int IMPORTANT = 1;
Mindy Pereira4db59c52012-01-12 09:45:13 -08001025 public static final int LOW = 0;
1026 public static final int HIGH = 1;
Vikram Aggarwal859681b2012-02-03 10:02:24 -08001027 }
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -08001028
Mindy Pereira22657522012-03-14 13:27:59 -07001029 public static final class ConversationPersonalLevel {
1030 public static final int NOT_TO_ME = 0;
1031 public static final int TO_ME_AND_OTHERS = 1;
1032 public static final int ONLY_TO_ME = 2;
1033 }
1034
Marc Blankc8a99422012-01-19 14:27:47 -08001035 public static final class ConversationFlags {
Marc Blankc8a99422012-01-19 14:27:47 -08001036 public static final int REPLIED = 1<<2;
1037 public static final int FORWARDED = 1<<3;
Mindy Pereirad69f5ad2012-03-14 13:20:24 -07001038 public static final int CALENDAR_INVITE = 1<<4;
Vikram Aggarwal859681b2012-02-03 10:02:24 -08001039 }
Marc Blankc8a99422012-01-19 14:27:47 -08001040
Paul Westbrook76b20622012-07-12 11:45:43 -07001041 public static final class ConversationPhishing {
1042 public static final int NOT_PHISHING = 0;
1043 public static final int PHISHING = 1;
1044 }
1045
Vikram Aggarwal531488e2012-05-29 16:36:52 -07001046 /**
1047 * Names of columns representing fields in a Conversation.
1048 */
Mindy Pereiraa1406072011-12-22 10:54:06 -08001049 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -08001050 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -08001051 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -08001052 * This string column contains the content provider uri to return the
1053 * list of messages for this conversation.
Paul Westbrook9cf43892012-03-15 15:43:47 -07001054 * The cursor returned by this query can return a {@link android.os.Bundle}
1055 * from a call to {@link android.database.Cursor#getExtras()}. This Bundle may have
1056 * values with keys listed in {@link CursorExtraKeys}
Mindy Pereiraa1406072011-12-22 10:54:06 -08001057 */
1058 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -08001059 /**
1060 * This string column contains the subject string for a conversation.
1061 */
1062 public static final String SUBJECT = "subject";
1063 /**
1064 * This string column contains the snippet string for a conversation.
1065 */
1066 public static final String SNIPPET = "snippet";
1067 /**
Mindy Pereira648df3f2012-07-19 09:20:26 -07001068 * @deprecated
Mindy Pereira27a0cf02011-12-22 13:16:32 -08001069 */
1070 public static final String SENDER_INFO = "senderInfo";
1071 /**
Andy Huang351ad4e2012-12-06 16:04:58 -08001072 * This blob column contains the byte-array representation of the Parceled
1073 * ConversationInfo object for a conversation.
Mindy Pereira648df3f2012-07-19 09:20:26 -07001074 */
1075 public static final String CONVERSATION_INFO = "conversationInfo";
1076 /**
Mindy Pereira27a0cf02011-12-22 13:16:32 -08001077 * This long column contains the time in ms of the latest update to a
1078 * conversation.
1079 */
1080 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
1081
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001082 /**
1083 * This boolean column contains whether any messages in this conversation
1084 * have attachments.
1085 */
1086 public static final String HAS_ATTACHMENTS = "hasAttachments";
1087
Mindy Pereira4db59c52012-01-12 09:45:13 -08001088 /**
1089 * This int column contains the number of messages in this conversation.
1090 * For unthreaded, this will always be 1.
1091 */
1092 public static String NUM_MESSAGES = "numMessages";
1093
1094 /**
1095 * This int column contains the number of drafts associated with this
1096 * conversation.
1097 */
1098 public static String NUM_DRAFTS = "numDrafts";
1099
1100 /**
1101 * This int column contains the state of drafts and replies associated
1102 * with this conversation. Use ConversationSendingState to interpret
1103 * this field.
1104 */
1105 public static String SENDING_STATE = "sendingState";
1106
1107 /**
1108 * This int column contains the priority of this conversation. Use
1109 * ConversationPriority to interpret this field.
1110 */
1111 public static String PRIORITY = "priority";
1112
Marc Blankc8a99422012-01-19 14:27:47 -08001113 /**
Mindy Pereira87d535f2012-03-23 11:15:56 -07001114 * This int column indicates whether the conversation has been read
Marc Blankc8a99422012-01-19 14:27:47 -08001115 */
1116 public static String READ = "read";
Marc Blankc8a99422012-01-19 14:27:47 -08001117 /**
Mindy Pereira87d535f2012-03-23 11:15:56 -07001118 * This int column indicates whether the conversation has been starred
Marc Blankc8a99422012-01-19 14:27:47 -08001119 */
1120 public static String STARRED = "starred";
1121
Mindy Pereira36b6c8b2012-02-03 14:16:07 -08001122 /**
Andy Huangb2033d82012-12-07 19:30:57 -08001123 * This blob column contains the marshalled form of a Parceled
1124 * {@FolderList} object. Ideally, only ever use this for
1125 * rendering the folder list for a conversation.
Mindy Pereiracc8211d2012-03-12 10:35:37 -07001126 */
Mindy Pereira183718b2012-03-12 11:00:14 -07001127 public static final String RAW_FOLDERS = "rawFolders";
Mindy Pereira22657522012-03-14 13:27:59 -07001128 public static final String FLAGS = "conversationFlags";
Andy Huang1284fd62012-07-12 16:48:06 -07001129 /**
1130 * This int column indicates the personal level of a conversation per
1131 * {@link ConversationPersonalLevel}.
1132 */
Mindy Pereira22657522012-03-14 13:27:59 -07001133 public static final String PERSONAL_LEVEL = "personalLevel";
Mindy Pereira87d535f2012-03-23 11:15:56 -07001134
1135 /**
1136 * This int column indicates whether the conversation is marked spam.
1137 */
1138 public static final String SPAM = "spam";
1139
1140 /**
Paul Westbrook76b20622012-07-12 11:45:43 -07001141 * This int column indicates whether the conversation is marked phishing.
1142 */
1143 public static final String PHISHING = "phishing";
1144
1145 /**
Mindy Pereira87d535f2012-03-23 11:15:56 -07001146 * This int column indicates whether the conversation was muted.
1147 */
1148 public static final String MUTED = "muted";
1149
Marc Blank92939fc2012-04-30 14:58:40 -07001150 /**
1151 * This int column contains a color for the conversation (used in Email only)
1152 */
1153 public static final String COLOR = "color";
1154
Marc Blanka6b671d2012-05-25 12:52:02 -07001155 /**
1156 * This String column contains the Uri for this conversation's account
1157 */
1158 public static final String ACCOUNT_URI = "accountUri";
Vikram Aggarwal66bc2aa2012-08-02 10:47:03 -07001159 /**
Andy Huangf98bc892012-08-07 18:22:09 -07001160 * This int column indicates whether a conversation is remote (non-local), and would require
1161 * a network fetch to load.
1162 */
1163 public static final String REMOTE = "remote";
1164 /**
Vikram Aggarwal66bc2aa2012-08-02 10:47:03 -07001165 * This int column indicates whether the conversation was displayed on the UI and the
1166 * user got a chance to read it. The UI does not read this value, it is meant only to
1167 * write the status back to the provider. As a result, it is not available in the
1168 * {@link Conversation} object.
1169 */
Andy Huangf98bc892012-08-07 18:22:09 -07001170 public static final String VIEWED = "viewed";
Paul Westbrook41dca182012-08-07 10:43:42 -07001171 /**
1172 * This String column contains the base uri for this conversation. This uri can be used
1173 * when handling relative urls in the message content
1174 */
1175 public static final String CONVERSATION_BASE_URI = "conversationBaseUri";
1176
Paul Westbrook334e64a2012-02-23 13:26:35 -08001177 private ConversationColumns() {
Andy Huang732600e2012-01-10 17:47:17 -08001178 }
Mindy Pereiraa1406072011-12-22 10:54:06 -08001179 }
1180
Andy Huangca854412012-04-20 19:55:38 -07001181 public static final class ConversationCursorCommand {
1182
1183 public static final String COMMAND_RESPONSE_OK = "ok";
1184 public static final String COMMAND_RESPONSE_FAILED = "failed";
1185
1186 /**
1187 * This bundle key has a boolean value: true to allow cursor network access (whether this
1188 * is true by default is up to the provider), false to temporarily disable network access.
1189 * <p>
1190 * A provider that implements this command should include this key in its response with a
1191 * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
1192 */
1193 public static final String COMMAND_KEY_ALLOW_NETWORK_ACCESS = "allowNetwork";
1194
Paul Westbrook9f119c72012-04-24 16:10:59 -07001195 /**
1196 * This bundle key has a boolean value: true to indicate that this cursor has been shown
1197 * to the user.
Vikram Aggarwal69b5c302012-09-05 11:11:13 -07001198 * <p>
1199 * A provider that implements this command should include this key in its response with a
1200 * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
Paul Westbrook9f119c72012-04-24 16:10:59 -07001201 */
1202 public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility";
1203
Vikram Aggarwal69b5c302012-09-05 11:11:13 -07001204 /**
1205 * This key has a boolean value: true to indicate that this folder list is shown to the user
1206 * either on first call (launcher/widget/notification) or after switching from an existing
1207 * folder: Inbox -> Folder. Repeated calls are sent when switching back to the folder. Inbox
1208 * -> Folder -> Spam -> Folder will generate two calls to respond() with the value true for
1209 * "Folder".
1210 * <p>
1211 * A provider that implements this command should include the
1212 * {@link #COMMAND_KEY_SET_VISIBILITY} key in its response with a value of
1213 * {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. This is <b>always</b>
1214 * set with {@link #COMMAND_KEY_SET_VISIBILITY} because this is only set when the folder
1215 * list is made visible.
1216 */
1217 public static final String COMMAND_KEY_ENTERED_FOLDER = "enteredFolder";
1218
Andy Huangca854412012-04-20 19:55:38 -07001219 private ConversationCursorCommand() {}
1220 }
1221
Mindy Pereira6f92de62011-12-19 11:31:48 -08001222 /**
Paul Westbrook334e64a2012-02-23 13:26:35 -08001223 * List of operations that can can be performed on a conversation. These operations are applied
1224 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1225 * where the conversation uri is specified, and the ContentValues specifies the operation to
1226 * be performed.
1227 * <p/>
1228 * The operation to be performed is specified in the ContentValues by
1229 * the {@link ConversationOperations#OPERATION_KEY}
1230 * <p/>
1231 * Note not all UI providers will support these operations. {@link AccountCapabilities} can
1232 * be used to determine which operations are supported.
Mindy Pereira6f92de62011-12-19 11:31:48 -08001233 */
Paul Westbrook334e64a2012-02-23 13:26:35 -08001234 public static final class ConversationOperations {
1235 /**
1236 * ContentValues key used to specify the operation to be performed
1237 */
1238 public static final String OPERATION_KEY = "operation";
1239
1240 /**
1241 * Archive operation
1242 */
1243 public static final String ARCHIVE = "archive";
1244
1245 /**
1246 * Mute operation
1247 */
1248 public static final String MUTE = "mute";
1249
1250 /**
1251 * Report spam operation
1252 */
1253 public static final String REPORT_SPAM = "report_spam";
1254
Paul Westbrook77eee622012-07-10 13:41:57 -07001255 /**
1256 * Report not spam operation
1257 */
1258 public static final String REPORT_NOT_SPAM = "report_not_spam";
1259
Paul Westbrook76b20622012-07-12 11:45:43 -07001260 /**
1261 * Report phishing operation
1262 */
1263 public static final String REPORT_PHISHING = "report_phishing";
1264
Paul Westbrookef362542012-08-27 14:53:32 -07001265 /**
1266 * Discard drafts operation
1267 */
1268 public static final String DISCARD_DRAFTS = "discard_drafts";
1269
mindypcb0b30e2012-11-30 10:16:35 -08001270 /**
1271 * Update conversation folder(s) operation. ContentValues passed as part
1272 * of this update will be of the format (FOLDERS_UPDATED, csv of updated
1273 * folders) where the comma separated values of the updated folders will
1274 * be of the format: folderuri/ADD_VALUE. ADD_VALUE will be true if the
1275 * folder was added, false if it was removed.
1276 */
1277 public static final String FOLDERS_UPDATED = "folders_updated";
1278 public static final String FOLDERS_UPDATED_SPLIT_PATTERN = ",";
Paul Westbrook5109c512012-11-05 11:00:30 -08001279
1280 public static final class Parameters {
1281 /**
1282 * Boolean indicating whether the undo for this operation should be suppressed
1283 */
1284 public static final String SUPPRESS_UNDO = "suppress_undo";
1285
1286 private Parameters() {}
1287 }
1288
Paul Westbrook334e64a2012-02-23 13:26:35 -08001289 private ConversationOperations() {
1290 }
1291 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001292
Paul Westbrook72e2ea82012-10-22 16:25:22 -07001293 /**
1294 * Methods that can be "called" using the account uri, through
1295 * {@link android.content.ContentResolver#call()} Note, the arg parmateter of call should be
1296 * the account uri.
1297 */
1298 public static final class AccountCallMethods {
1299 /**
1300 * Save message method. The Bundle for the call to
1301 * {@link android.content.ContentResolver#call()} should have the columns specified in
1302 * {@link MessageColumns}, and if this is a save for an existing message, an entry for the
1303 * {@link MessageColumns#URI} should reference the existing message
1304 *
1305 * The Bundle returned will contain the message uri in the returned bundled with the
1306 * {@link MessageColumns#URI} key.
1307 */
1308 public static final String SAVE_MESSAGE = "save_message";
1309
1310 /**
1311 * Send message method. The Bundle for the call to
1312 * {@link android.content.ContentResolver#call()} should have the columns specified in
1313 * {@link MessageColumns}, and if this is a send of an existing message, an entry for the
1314 * {@link MessageColumns#URI} should reference the existing message
1315 *
1316 * The Bundle returned will contain the message uri in the returned bundled with the
1317 * {@link MessageColumns#URI} key.
1318 */
1319 public static final String SEND_MESSAGE = "send_message";
1320
Scott Banachowski53a615d2012-12-19 15:31:20 -08001321 /**
1322 * Change account method. The Bundle for the call to
1323 * {@link android.content.ContentResolver#call()} should have the columns specified in
1324 * {@link SetCurrentAccountColumns}
1325 *
1326 * The Bundle returned will be empty.
1327 */
1328 public static final String SET_CURRENT_ACCOUNT = "set_current_account";
1329
Paul Westbrook72e2ea82012-10-22 16:25:22 -07001330 private AccountCallMethods() {}
1331 }
1332
Paul Westbrook3c7f94d2012-10-23 14:13:00 -07001333 /**
1334 * Keys used for parameters to {@link AccountCallMethods#SEND_MESSAGE} or
1335 * {@link AccountCallMethods#SAVE_MESSAGE} methods.
1336 */
1337 public static final class SendOrSaveMethodParamKeys {
1338 /**
1339 * Bundle key used to store any opened file descriptors.
1340 * The keys of this Bundle are the contentUri for each attachment, and the
1341 * values are {@link android.os.ParcelFileDescriptor} objects.
1342 */
1343 public static final String OPENED_FD_MAP = "opened_fds";
1344
1345 private SendOrSaveMethodParamKeys() {}
1346 }
1347
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001348 public static final class DraftType {
Andy Huang97c25be2012-01-12 15:12:09 -08001349 public static final int NOT_A_DRAFT = 0;
1350 public static final int COMPOSE = 1;
1351 public static final int REPLY = 2;
1352 public static final int REPLY_ALL = 3;
1353 public static final int FORWARD = 4;
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001354
1355 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -08001356 }
1357
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001358 /**
1359 * Class for the enum values to determine whether this
1360 * string should be displayed as a high priority warning
1361 * or a low priority warning. The current design has
1362 * high priority warnings in red while low priority warnings
1363 * are grey.
1364 */
1365 public static final class SpamWarningLevel {
1366 public static final int NO_WARNING = 0;
1367 public static final int LOW_WARNING = 1;
1368 public static final int HIGH_WARNING = 2;
1369
1370 private SpamWarningLevel() {}
1371 }
1372
1373 /**
1374 * Class for the enum values to determine which type
1375 * of link to show in the spam warning.
1376 */
1377 public static final class SpamWarningLinkType {
1378 public static final int NO_LINK = 0;
1379 public static final int IGNORE_WARNING = 1;
1380 public static final int REPORT_PHISHING = 2;
1381
1382 private SpamWarningLinkType() {}
1383 }
1384
Mindy Pereiraa1406072011-12-22 10:54:06 -08001385 public static final String[] MESSAGE_PROJECTION = {
1386 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -08001387 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -08001388 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -08001389 MessageColumns.CONVERSATION_ID,
1390 MessageColumns.SUBJECT,
1391 MessageColumns.SNIPPET,
1392 MessageColumns.FROM,
1393 MessageColumns.TO,
1394 MessageColumns.CC,
1395 MessageColumns.BCC,
1396 MessageColumns.REPLY_TO,
1397 MessageColumns.DATE_RECEIVED_MS,
1398 MessageColumns.BODY_HTML,
1399 MessageColumns.BODY_TEXT,
1400 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
1401 MessageColumns.REF_MESSAGE_ID,
1402 MessageColumns.DRAFT_TYPE,
Mindy Pereira3ce64e72012-01-13 14:29:45 -08001403 MessageColumns.APPEND_REF_MESSAGE_CONTENT,
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001404 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -08001405 MessageColumns.ATTACHMENT_LIST_URI,
Mindy Pereiraf944e962012-01-17 11:43:36 -08001406 MessageColumns.MESSAGE_FLAGS,
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001407 MessageColumns.JOINED_ATTACHMENT_INFOS,
1408 MessageColumns.SAVE_MESSAGE_URI,
Paul Westbrook104f7292012-02-28 16:07:07 -08001409 MessageColumns.SEND_MESSAGE_URI,
Mindy Pereirae8caf122012-03-20 15:23:31 -07001410 MessageColumns.ALWAYS_SHOW_IMAGES,
Andy Huangd8e249e2012-03-21 17:01:37 -07001411 MessageColumns.READ,
1412 MessageColumns.STARRED,
Andy Huang5a929072012-03-23 20:17:10 -07001413 MessageColumns.QUOTE_START_POS,
Mindy Pereira92551d02012-04-05 11:31:12 -07001414 MessageColumns.ATTACHMENTS,
Mindy Pereira62de1b12012-04-06 12:17:56 -07001415 MessageColumns.CUSTOM_FROM_ADDRESS,
Marc Blank3842af92012-04-27 09:06:09 -07001416 MessageColumns.MESSAGE_ACCOUNT_URI,
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001417 MessageColumns.EVENT_INTENT_URI,
1418 MessageColumns.SPAM_WARNING_STRING,
1419 MessageColumns.SPAM_WARNING_LEVEL,
Andrew Sappersteind5b369b2012-07-13 12:38:46 -07001420 MessageColumns.SPAM_WARNING_LINK_TYPE,
Andy Huang47aa9c92012-07-31 15:37:21 -07001421 MessageColumns.VIA_DOMAIN,
1422 MessageColumns.IS_SENDING
Mindy Pereiraa1406072011-12-22 10:54:06 -08001423 };
1424
Mindy Pereiraf944e962012-01-17 11:43:36 -08001425 /** Separates attachment info parts in strings in a message. */
Andy Huang5c5fd572012-04-08 18:19:29 -07001426 @Deprecated
Mindy Pereiraf944e962012-01-17 11:43:36 -08001427 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
Mindy Pereiraa1406072011-12-22 10:54:06 -08001428 public static final String MESSAGE_LIST_TYPE =
1429 "vnd.android.cursor.dir/vnd.com.android.mail.message";
1430 public static final String MESSAGE_TYPE =
1431 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -08001432
Mindy Pereira6349a042012-01-04 11:25:01 -08001433 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -08001434 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
1435 public static final int MESSAGE_URI_COLUMN = 2;
Marc Blank26846d82012-03-22 18:12:54 -07001436 public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3;
Mindy Pereira326c6602012-01-04 15:32:42 -08001437 public static final int MESSAGE_SUBJECT_COLUMN = 4;
1438 public static final int MESSAGE_SNIPPET_COLUMN = 5;
1439 public static final int MESSAGE_FROM_COLUMN = 6;
1440 public static final int MESSAGE_TO_COLUMN = 7;
1441 public static final int MESSAGE_CC_COLUMN = 8;
1442 public static final int MESSAGE_BCC_COLUMN = 9;
1443 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
1444 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
Mindy Pereira16668162012-01-11 16:11:19 -08001445 public static final int MESSAGE_BODY_HTML_COLUMN = 12;
1446 public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
Mindy Pereira326c6602012-01-04 15:32:42 -08001447 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
1448 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
1449 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
Mindy Pereira3ce64e72012-01-13 14:29:45 -08001450 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
1451 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
1452 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
1453 public static final int MESSAGE_FLAGS_COLUMN = 20;
Mindy Pereiraf944e962012-01-17 11:43:36 -08001454 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001455 public static final int MESSAGE_SAVE_URI_COLUMN = 22;
1456 public static final int MESSAGE_SEND_URI_COLUMN = 23;
Andy Huangd8e249e2012-03-21 17:01:37 -07001457 public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 24;
1458 public static final int MESSAGE_READ_COLUMN = 25;
1459 public static final int MESSAGE_STARRED_COLUMN = 26;
Mindy Pereira4b8e44b2012-03-21 17:20:10 -07001460 public static final int QUOTED_TEXT_OFFSET_COLUMN = 27;
Andy Huang5a929072012-03-23 20:17:10 -07001461 public static final int MESSAGE_ATTACHMENTS_COLUMN = 28;
Mindy Pereira92551d02012-04-05 11:31:12 -07001462 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 29;
Mindy Pereira62de1b12012-04-06 12:17:56 -07001463 public static final int MESSAGE_ACCOUNT_URI_COLUMN = 30;
Marc Blank3842af92012-04-27 09:06:09 -07001464 public static final int MESSAGE_EVENT_INTENT_COLUMN = 31;
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001465 public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 32;
1466 public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 33;
1467 public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 34;
Andrew Sappersteind5b369b2012-07-13 12:38:46 -07001468 public static final int MESSAGE_VIA_DOMAIN_COLUMN = 35;
Andy Huang47aa9c92012-07-31 15:37:21 -07001469 public static final int MESSAGE_IS_SENDING_COLUMN = 36;
Paul Westbrook9cf43892012-03-15 15:43:47 -07001470
1471 public static final class CursorStatus {
1472 // The cursor is actively loading more data
1473 public static final int LOADING = 1 << 0;
1474
1475 // The cursor is currently not loading more data, but more data may be available
1476 public static final int LOADED = 1 << 1;
1477
1478 // An error occured while loading data
1479 public static final int ERROR = 1 << 2;
1480
1481 // The cursor is loaded, and there will be no more data
1482 public static final int COMPLETE = 1 << 3;
Paul Westbrook573b9e62012-08-02 14:56:17 -07001483
1484 public static boolean isWaitingForResults(int cursorStatus) {
1485 return 0 != (cursorStatus & LOADING);
1486 }
Paul Westbrook9cf43892012-03-15 15:43:47 -07001487 }
1488
1489
1490 public static final class CursorExtraKeys {
1491 /**
1492 * This integer column contains the staus of the message cursor. The value will be
1493 * one defined in {@link CursorStatus}.
1494 */
Paul Westbrook7a3e6572012-08-02 16:33:58 -07001495 public static final String EXTRA_STATUS = "cursor_status";
Paul Westbrook9cf43892012-03-15 15:43:47 -07001496
1497 /**
1498 * Used for finding the cause of an error.
1499 * TODO: define these values
1500 */
Paul Westbrook7a3e6572012-08-02 16:33:58 -07001501 public static final String EXTRA_ERROR = "cursor_error";
Paul Westbrook9cf43892012-03-15 15:43:47 -07001502
1503 }
1504
Paul Westbrook2388c5d2012-03-25 12:29:11 -07001505 public static final class AccountCursorExtraKeys {
1506 /**
1507 * This integer column contains the staus of the account cursor. The value will be
1508 * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully
1509 * initialized
1510 */
1511 public static final String ACCOUNTS_LOADED = "accounts_loaded";
1512 }
1513
Paul Westbrook9cf43892012-03-15 15:43:47 -07001514
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001515 public static final class MessageFlags {
Andy Huang47aa9c92012-07-31 15:37:21 -07001516 public static final int REPLIED = 1 << 2;
1517 public static final int FORWARDED = 1 << 3;
1518 public static final int CALENDAR_INVITE = 1 << 4;
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001519 }
1520
Mindy Pereira6f92de62011-12-19 11:31:48 -08001521 public static final class MessageColumns {
Andy Huangdb977472012-01-11 19:53:25 -08001522 /**
1523 * This string column contains a content provider URI that points to this single message.
1524 */
Mindy Pereira6349a042012-01-04 11:25:01 -08001525 public static final String URI = "messageUri";
Andy Huangdb977472012-01-11 19:53:25 -08001526 /**
1527 * This string column contains a server-assigned ID for this message.
1528 */
1529 public static final String SERVER_ID = "serverMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001530 public static final String CONVERSATION_ID = "conversationId";
Andy Huangdb977472012-01-11 19:53:25 -08001531 /**
1532 * This string column contains the subject of a message.
1533 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001534 public static final String SUBJECT = "subject";
Andy Huangdb977472012-01-11 19:53:25 -08001535 /**
1536 * This string column contains a snippet of the message body.
1537 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001538 public static final String SNIPPET = "snippet";
Andy Huangdb977472012-01-11 19:53:25 -08001539 /**
1540 * This string column contains the single email address (and optionally name) of the sender.
1541 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001542 public static final String FROM = "fromAddress";
Andy Huangdb977472012-01-11 19:53:25 -08001543 /**
1544 * This string column contains a comma-delimited list of "To:" recipient email addresses.
1545 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001546 public static final String TO = "toAddresses";
Andy Huangdb977472012-01-11 19:53:25 -08001547 /**
1548 * This string column contains a comma-delimited list of "CC:" recipient email addresses.
1549 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001550 public static final String CC = "ccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -08001551 /**
1552 * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
1553 * This value will be null for incoming messages.
1554 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001555 public static final String BCC = "bccAddresses";
Andy Huangdb977472012-01-11 19:53:25 -08001556 /**
1557 * This string column contains the single email address (and optionally name) of the
1558 * sender's reply-to address.
1559 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001560 public static final String REPLY_TO = "replyToAddress";
Andy Huangdb977472012-01-11 19:53:25 -08001561 /**
1562 * This long column contains the timestamp (in millis) of receipt of the message.
1563 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001564 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Andy Huangdb977472012-01-11 19:53:25 -08001565 /**
1566 * This string column contains the HTML form of the message body, if available. If not,
1567 * a provider must populate BODY_TEXT.
1568 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001569 public static final String BODY_HTML = "bodyHtml";
Andy Huangdb977472012-01-11 19:53:25 -08001570 /**
1571 * This string column contains the plaintext form of the message body, if HTML is not
1572 * otherwise available. If HTML is available, this value should be left empty (null).
1573 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001574 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -08001575 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
Mindy Pereira3ce64e72012-01-13 14:29:45 -08001576 /**
1577 * This string column contains an opaque string used by the sendMessage api.
1578 */
Mindy Pereira6f92de62011-12-19 11:31:48 -08001579 public static final String REF_MESSAGE_ID = "refMessageId";
Andy Huangdb977472012-01-11 19:53:25 -08001580 /**
Andy Huang97c25be2012-01-12 15:12:09 -08001581 * This integer column contains the type of this draft, or zero (0) if this message is not a
1582 * draft. See {@link DraftType} for possible values.
Andy Huangdb977472012-01-11 19:53:25 -08001583 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -08001584 public static final String DRAFT_TYPE = "draftType";
Andy Huangdb977472012-01-11 19:53:25 -08001585 /**
1586 * This boolean column indicates whether an outgoing message should trigger special quoted
1587 * text processing upon send. The value should default to zero (0) for protocols that do
1588 * not support or require this flag, and for all incoming messages.
1589 */
Mindy Pereira3ce64e72012-01-13 14:29:45 -08001590 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
Andy Huangdb977472012-01-11 19:53:25 -08001591 /**
1592 * This boolean column indicates whether a message has attachments. The list of attachments
1593 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
1594 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001595 public static final String HAS_ATTACHMENTS = "hasAttachments";
Andy Huangdb977472012-01-11 19:53:25 -08001596 /**
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001597 * This string column contains the content provider URI for the list of
1598 * attachments associated with this message.
Andy Huangdb977472012-01-11 19:53:25 -08001599 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001600 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
Andy Huangdb977472012-01-11 19:53:25 -08001601 /**
1602 * This long column is a bit field of flags defined in {@link MessageFlags}.
1603 */
Andy Huang732600e2012-01-10 17:47:17 -08001604 public static final String MESSAGE_FLAGS = "messageFlags";
Mindy Pereiraf944e962012-01-17 11:43:36 -08001605 /**
1606 * This string column contains a specially formatted string representing all
1607 * attachments that we added to a message that is being sent or saved.
Andy Huang5a929072012-03-23 20:17:10 -07001608 *
Andy Huang5c5fd572012-04-08 18:19:29 -07001609 * TODO: remove this and use {@link #ATTACHMENTS} instead
Mindy Pereiraf944e962012-01-17 11:43:36 -08001610 */
Andy Huang5c5fd572012-04-08 18:19:29 -07001611 @Deprecated
Mindy Pereira84554ec2012-01-17 14:44:44 -08001612 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001613 /**
1614 * This string column contains the content provider URI for saving this
1615 * message.
1616 */
Paul Westbrook72e2ea82012-10-22 16:25:22 -07001617 @Deprecated
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001618 public static final String SAVE_MESSAGE_URI = "saveMessageUri";
1619 /**
1620 * This string column contains content provider URI for sending this
1621 * message.
1622 */
Paul Westbrook72e2ea82012-10-22 16:25:22 -07001623 @Deprecated
Mindy Pereira7ed1c112012-01-18 10:59:25 -08001624 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira6f92de62011-12-19 11:31:48 -08001625
Paul Westbrook104f7292012-02-28 16:07:07 -08001626 /**
1627 * This integer column represents whether the user has specified that images should always
1628 * be shown. The value of "1" indicates that the user has specified that images should be
1629 * shown, while the value of "0" indicates that the user should be prompted before loading
1630 * any external images.
1631 */
1632 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
1633
Mindy Pereirae8caf122012-03-20 15:23:31 -07001634 /**
Andy Huangd8e249e2012-03-21 17:01:37 -07001635 * This boolean column indicates whether the message has been read
1636 */
1637 public static String READ = "read";
1638
1639 /**
1640 * This boolean column indicates whether the message has been starred
1641 */
1642 public static String STARRED = "starred";
1643
1644 /**
Mindy Pereirae8caf122012-03-20 15:23:31 -07001645 * This integer column represents the offset in the message of quoted
1646 * text. If include_quoted_text is zero, the value contained in this
1647 * column is invalid.
1648 */
1649 public static final String QUOTE_START_POS = "quotedTextStartPos";
1650
Andy Huang5a929072012-03-23 20:17:10 -07001651 /**
1652 * This string columns contains a JSON array of serialized {@link Attachment} objects.
1653 */
1654 public static final String ATTACHMENTS = "attachments";
Mindy Pereira92551d02012-04-05 11:31:12 -07001655 public static final String CUSTOM_FROM_ADDRESS = "customFrom";
Mindy Pereira62de1b12012-04-06 12:17:56 -07001656 /**
1657 * Uri of the account associated with this message. Except in the case
1658 * of showing a combined view, this column is almost always empty.
1659 */
1660 public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri";
Marc Blank3842af92012-04-27 09:06:09 -07001661 /**
Andy Huange623a0f2012-07-12 15:01:23 -07001662 * Intent Uri to launch when the user wants to view an event in their calendar, or null.
Marc Blank3842af92012-04-27 09:06:09 -07001663 */
1664 public static final String EVENT_INTENT_URI = "eventIntentUri";
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001665 /**
Andrew Sappersteind5b369b2012-07-13 12:38:46 -07001666 * This string column contains the string for the spam
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001667 * warning of this message, or null if there is no spam warning for the message.
1668 */
1669 public static final String SPAM_WARNING_STRING = "spamWarningString";
1670 /**
1671 * This integer column contains the level of spam warning of this message,
1672 * or zero (0) if this message does not have a warning level.
1673 * See {@link SpamWarningLevel} for possible values.
1674 */
1675 public static final String SPAM_WARNING_LEVEL = "spamWarningLevel";
1676 /**
1677 * This integer column contains the type of link for the spam warning
1678 * of this message, or zero (0) if this message does not have a link type.
1679 * See {@link SpamWarningLinkType} for possible values.
1680 */
1681 public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType";
Andrew Sappersteind5b369b2012-07-13 12:38:46 -07001682 /**
1683 * This string column contains the string for the via domain
1684 * to be included if this message was sent via an alternate
1685 * domain. This column should be null if no via domain exists.
1686 */
1687 public static final String VIA_DOMAIN = "viaDomain";
Andy Huang47aa9c92012-07-31 15:37:21 -07001688 /**
1689 * This boolean column indicates whether the message is an outgoing message in the process
1690 * of being sent (will be zero for incoming messages and messages that are already sent).
1691 */
1692 public static final String IS_SENDING = "isSending";
Andrew Sapperstein3b08c512012-07-11 16:51:07 -07001693
Mindy Pereira6f92de62011-12-19 11:31:48 -08001694 private MessageColumns() {}
1695 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001696
Scott Banachowski53a615d2012-12-19 15:31:20 -08001697 public static final class SetCurrentAccountColumns {
1698 /**
1699 * This column contains the Account object Parcelable.
1700 */
1701 public static final String ACCOUNT = "account";
1702
1703 private SetCurrentAccountColumns() {}
1704 }
1705
Marc Blank922c3eb2012-04-24 08:41:53 -07001706 /**
1707 * List of operations that can can be performed on a message. These operations are applied
1708 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1709 * where the message uri is specified, and the ContentValues specifies the operation to
1710 * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT)
1711 * <p/>
1712 * Note not all UI providers will support these operations.
1713 */
1714 public static final class MessageOperations {
1715 /**
1716 * Respond to a calendar invitation
1717 */
1718 public static final String RESPOND_COLUMN = "respond";
1719
1720 public static final int RESPOND_ACCEPT = 1;
1721 public static final int RESPOND_TENTATIVE = 2;
1722 public static final int RESPOND_DECLINE = 3;
1723
1724 private MessageOperations() {
1725 }
1726 }
1727
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001728 public static final String ATTACHMENT_LIST_TYPE =
1729 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
1730 public static final String ATTACHMENT_TYPE =
1731 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
1732
1733 public static final String[] ATTACHMENT_PROJECTION = {
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001734 AttachmentColumns.NAME,
1735 AttachmentColumns.SIZE,
Mindy Pereira7a07fb42012-01-11 10:32:48 -08001736 AttachmentColumns.URI,
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001737 AttachmentColumns.CONTENT_TYPE,
Andy Huange0b83b82012-03-06 19:57:04 -08001738 AttachmentColumns.STATE,
1739 AttachmentColumns.DESTINATION,
1740 AttachmentColumns.DOWNLOADED_SIZE,
1741 AttachmentColumns.CONTENT_URI,
1742 AttachmentColumns.THUMBNAIL_URI,
Mark Weibbe74ae2012-11-19 11:20:09 -08001743 AttachmentColumns.PREVIEW_INTENT_URI,
1744 AttachmentColumns.PROVIDER_DATA
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001745 };
Mindy Pereira82cc5662012-01-09 17:29:30 -08001746 private static final String EMAIL_SEPARATOR_PATTERN = "\n";
Andy Huang109369d2012-03-07 20:05:31 -08001747 public static final int ATTACHMENT_NAME_COLUMN = 0;
1748 public static final int ATTACHMENT_SIZE_COLUMN = 1;
1749 public static final int ATTACHMENT_URI_COLUMN = 2;
1750 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
1751 public static final int ATTACHMENT_STATE_COLUMN = 4;
1752 public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
1753 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
1754 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
1755 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
1756 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001757
Andy Huange0b83b82012-03-06 19:57:04 -08001758 /**
1759 * Valid states for the {@link AttachmentColumns#STATE} column.
1760 *
1761 */
1762 public static final class AttachmentState {
1763 /**
1764 * The full attachment is not present on device. When used as a command,
1765 * setting this state will tell the provider to cancel a download in
1766 * progress.
1767 * <p>
1768 * Valid next states: {@link #DOWNLOADING}
1769 */
1770 public static final int NOT_SAVED = 0;
1771 /**
1772 * The most recent attachment download attempt failed. The current UI
1773 * design does not require providers to persist this state, but
1774 * providers must return this state at least once after a download
1775 * failure occurs. This state may not be used as a command.
1776 * <p>
1777 * Valid next states: {@link #DOWNLOADING}
1778 */
1779 public static final int FAILED = 1;
1780 /**
1781 * The attachment is currently being downloaded by the provider.
1782 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1783 * download progress while in this state. When used as a command,
1784 * setting this state will tell the provider to initiate a download to
1785 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1786 * .
1787 * <p>
1788 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
1789 * {@link #SAVED}
1790 */
1791 public static final int DOWNLOADING = 2;
1792 /**
1793 * The attachment was successfully downloaded to the destination in
1794 * {@link AttachmentColumns#DESTINATION}. If a provider later detects
1795 * that a download is missing, it should reset the state to
1796 * {@link #NOT_SAVED}. This state may not be used as a command on its
1797 * own. To move a file from cache to external, update
1798 * {@link AttachmentColumns#DESTINATION}.
1799 * <p>
1800 * Valid next states: {@link #NOT_SAVED}
1801 */
1802 public static final int SAVED = 3;
Mark Wei47ca4e22012-10-17 16:20:15 -07001803 /**
1804 * This is only used as a command, not as a state. The attachment is
1805 * currently being redownloaded by the provider.
1806 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1807 * download progress while in this state. When used as a command,
1808 * setting this state will tell the provider to initiate a download to
1809 * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1810 * .
1811 * <p>
1812 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
1813 * {@link #SAVED}
1814 */
1815 public static final int REDOWNLOADING = 4;
Andy Huange0b83b82012-03-06 19:57:04 -08001816
1817 private AttachmentState() {}
1818 }
1819
1820 public static final class AttachmentDestination {
1821
1822 /**
1823 * The attachment will be or is already saved to the app-private cache partition.
1824 */
1825 public static final int CACHE = 0;
1826 /**
1827 * The attachment will be or is already saved to external shared device storage.
1828 */
1829 public static final int EXTERNAL = 1;
1830
1831 private AttachmentDestination() {}
1832 }
1833
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001834 public static final class AttachmentColumns {
Andy Huange0b83b82012-03-06 19:57:04 -08001835 /**
1836 * This string column is the attachment's file name, intended for display in UI. It is not
1837 * the full path of the file.
1838 */
Paul Westbrookc97d8ac2012-03-23 15:21:48 -07001839 public static final String NAME = OpenableColumns.DISPLAY_NAME;
Andy Huange0b83b82012-03-06 19:57:04 -08001840 /**
1841 * This integer column is the file size of the attachment, in bytes.
1842 */
Paul Westbrookc97d8ac2012-03-23 15:21:48 -07001843 public static final String SIZE = OpenableColumns.SIZE;
Andy Huange0b83b82012-03-06 19:57:04 -08001844 /**
Mark Wei1aee17e2013-01-14 14:47:16 -08001845 * This column is a {@link android.net.Uri} that can be queried to
1846 * monitor download state and progress for this individual attachment
1847 * (resulting cursor has one single row for this attachment).
Andy Huange0b83b82012-03-06 19:57:04 -08001848 */
Mindy Pereira7a07fb42012-01-11 10:32:48 -08001849 public static final String URI = "uri";
Andy Huange0b83b82012-03-06 19:57:04 -08001850 /**
1851 * This string column is the MIME type of the attachment.
1852 */
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001853 public static final String CONTENT_TYPE = "contentType";
Andy Huange0b83b82012-03-06 19:57:04 -08001854 /**
1855 * This integer column is the current downloading state of the
1856 * attachment as defined in {@link AttachmentState}.
1857 * <p>
Andy Huangd8e249e2012-03-21 17:01:37 -07001858 * Providers must accept updates to {@link #URI} with new values of
Andy Huange0b83b82012-03-06 19:57:04 -08001859 * this column to initiate or cancel downloads.
1860 */
1861 public static final String STATE = "state";
1862 /**
1863 * This integer column is the file destination for the current download
1864 * in progress (when {@link #STATE} is
1865 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
1866 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
1867 * in {@link AttachmentDestination}. This value is undefined in any
1868 * other state.
1869 * <p>
Andy Huangd8e249e2012-03-21 17:01:37 -07001870 * Providers must accept updates to {@link #URI} with new values of
Andy Huange0b83b82012-03-06 19:57:04 -08001871 * this column to move an existing downloaded file.
1872 */
1873 public static final String DESTINATION = "destination";
1874 /**
1875 * This integer column is the current number of bytes downloaded when
1876 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
1877 * undefined in any other state.
1878 */
1879 public static final String DOWNLOADED_SIZE = "downloadedSize";
1880 /**
Mark Wei1aee17e2013-01-14 14:47:16 -08001881 * This column is a {@link android.net.Uri} that points to the
1882 * downloaded local file when {@link #STATE} is
1883 * {@link AttachmentState#SAVED}. This value is undefined in any other
1884 * state.
Andy Huange0b83b82012-03-06 19:57:04 -08001885 */
1886 public static final String CONTENT_URI = "contentUri";
1887 /**
Mark Wei1aee17e2013-01-14 14:47:16 -08001888 * This column is a {@link android.net.Uri} that points to a local
1889 * thumbnail file for the attachment. Providers that do not support
1890 * downloading attachment thumbnails may leave this null.
Andy Huange0b83b82012-03-06 19:57:04 -08001891 */
1892 public static final String THUMBNAIL_URI = "thumbnailUri";
1893 /**
Mark Wei1aee17e2013-01-14 14:47:16 -08001894 * This column is an {@link android.net.Uri} used in an
1895 * {@link android.content.Intent#ACTION_VIEW} Intent to launch a preview
1896 * activity that allows the user to efficiently view an attachment
1897 * without having to first download the entire file. Providers that do
1898 * not support previewing attachments may leave this null.
Andy Huange0b83b82012-03-06 19:57:04 -08001899 */
Paul Westbrookd49db8e2012-08-03 17:58:46 -07001900 public static final String PREVIEW_INTENT_URI = "previewIntentUri";
Mark Weibbe74ae2012-11-19 11:20:09 -08001901 /**
1902 * This column contains provider-specific private data as JSON string.
1903 */
1904 public static final String PROVIDER_DATA = "providerData";
Andy Huange0b83b82012-03-06 19:57:04 -08001905
1906 private AttachmentColumns() {}
Mindy Pereiraf30cc092011-12-29 14:02:40 -08001907 }
Mindy Pereira013194c2012-01-06 15:09:33 -08001908
Mark Wei1aee17e2013-01-14 14:47:16 -08001909 public static final class AttachmentContentValueKeys {
1910 public static final String RENDITION = "rendition";
Mark Wei26745352013-01-17 21:40:34 -08001911 public static final String ADDITIONAL_PRIORITY = "additionalPriority";
1912 public static final String DELAY_DOWNLOAD = "delayDownload";
Mark Wei1aee17e2013-01-14 14:47:16 -08001913 }
1914
1915 /**
1916 * Indicates a version of an attachment.
1917 */
1918 public static final class AttachmentRendition {
1919
1920 /** A smaller or simpler version of the attachment, such as a scaled-down image or an HTML
1921 * version of a document. Not always available.
1922 */
1923 public static final int SIMPLE = 0;
1924 /**
1925 * The full version of an attachment if it can be handled on the device, otherwise the
1926 * preview.
1927 */
1928 public static final int BEST = 1;
1929
1930 public static int parseRendition(String rendition) {
1931 return rendition.equalsIgnoreCase("BEST") ? BEST : SIMPLE;
1932 }
1933
1934 public static String toString(int rendition) {
1935 return rendition == BEST ? "BEST" : "SIMPLE";
1936 }
1937 }
1938
Mindy Pereira013194c2012-01-06 15:09:33 -08001939 public static String getAttachmentTypeSetting() {
1940 // TODO: query the account to see what kinds of attachments it supports?
1941 return "com.google.android.gm.allowAddAnyAttachment";
1942 }
Mindy Pereira82cc5662012-01-09 17:29:30 -08001943
1944 public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1945 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1946 ArrayList<String> recipients = new ArrayList<String>();
mindyp845f87e2012-09-24 15:14:49 -07001947 if (TextUtils.isEmpty(addressString)) {
1948 return;
1949 }
1950 Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(addressString);
1951 for (int i = 0; i < tokens.length;i++) {
1952 recipients.add(tokens[i].getAddress());
Mindy Pereira82cc5662012-01-09 17:29:30 -08001953 }
1954 statsUpdater.updateWithAddress(recipients);
1955 }
Marc Blankb31ab5a2012-02-01 12:28:29 -08001956
1957 public static final String[] UNDO_PROJECTION = {
1958 ConversationColumns.MESSAGE_LIST_URI
1959 };
1960 public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
Marc Blankdd10bc82012-02-01 19:10:46 -08001961
1962 // Parameter used to indicate the sequence number for an undoable operation
1963 public static final String SEQUENCE_QUERY_PARAMETER = "seq";
Paul Westbrook63eef792012-02-27 14:01:06 -08001964
Scott Kennedy1007e702012-12-20 11:18:45 -08001965 /**
1966 * Parameter used to force UI notifications in an operation involving
1967 * {@link ConversationOperations#OPERATION_KEY}.
1968 */
1969 public static final String FORCE_UI_NOTIFICATIONS_QUERY_PARAMETER = "forceUiNotifications";
1970
Scott Kennedy0d0f8b02012-10-12 15:18:18 -07001971 public static final String AUTO_ADVANCE_MODE_OLDER = "older";
1972 public static final String AUTO_ADVANCE_MODE_NEWER = "newer";
1973 public static final String AUTO_ADVANCE_MODE_LIST = "list";
1974
Vikram Aggarwalc7694222012-04-23 13:37:01 -07001975 /**
1976 * Settings for auto advancing when the current conversation has been destroyed.
1977 */
Paul Westbrook63eef792012-02-27 14:01:06 -08001978 public static final class AutoAdvance {
Vikram Aggarwalc7694222012-04-23 13:37:01 -07001979 /** No setting specified. */
Paul Westbrook63eef792012-02-27 14:01:06 -08001980 public static final int UNSET = 0;
Vikram Aggarwalc7694222012-04-23 13:37:01 -07001981 /** Go to the older message (if available) */
Paul Westbrook63eef792012-02-27 14:01:06 -08001982 public static final int OLDER = 1;
Vikram Aggarwalc7694222012-04-23 13:37:01 -07001983 /** Go to the newer message (if available) */
Paul Westbrook63eef792012-02-27 14:01:06 -08001984 public static final int NEWER = 2;
Vikram Aggarwalc7694222012-04-23 13:37:01 -07001985 /** Go back to conversation list*/
Paul Westbrook63eef792012-02-27 14:01:06 -08001986 public static final int LIST = 3;
Vikram Aggarwal82d37502013-01-10 16:18:49 -08001987 /** The default option is to go to the list */
1988 public static final int DEFAULT = LIST;
Scott Kennedy0d0f8b02012-10-12 15:18:18 -07001989
1990 /**
1991 * Gets the int value for the given auto advance setting.
1992 *
1993 * @param autoAdvanceSetting The string setting, such as "newer", "older", "list"
1994 */
1995 public static int getAutoAdvanceInt(final String autoAdvanceSetting) {
1996 final int autoAdvance;
1997
1998 if (AUTO_ADVANCE_MODE_NEWER.equals(autoAdvanceSetting)) {
1999 autoAdvance = UIProvider.AutoAdvance.NEWER;
2000 } else if (AUTO_ADVANCE_MODE_OLDER.equals(autoAdvanceSetting)) {
2001 autoAdvance = UIProvider.AutoAdvance.OLDER;
2002 } else if (AUTO_ADVANCE_MODE_LIST.equals(autoAdvanceSetting)) {
2003 autoAdvance = UIProvider.AutoAdvance.LIST;
2004 } else {
2005 autoAdvance = UIProvider.AutoAdvance.UNSET;
2006 }
2007
2008 return autoAdvance;
2009 }
Paul Westbrook63eef792012-02-27 14:01:06 -08002010 }
2011
Mindy Pereira71a8f5e2012-07-25 14:33:18 -07002012 /**
2013 * Settings for what swipe should do.
2014 */
2015 public static final class Swipe {
2016 /** Archive or remove label, if available. */
2017 public static final int ARCHIVE = 0;
2018 /** Delete */
2019 public static final int DELETE = 1;
2020 /** No swipe */
2021 public static final int DISABLED = 2;
Mindy Pereirae58222b2012-07-25 14:33:18 -07002022 /** Default is delete */
Mindy Pereira1c605fe2012-07-25 16:17:15 -07002023 public static final int DEFAULT = ARCHIVE;
Mindy Pereira71a8f5e2012-07-25 14:33:18 -07002024 }
2025
Paul Westbrookfa255c02012-10-13 14:32:52 -07002026 /**
2027 * Settings for Conversation view mode.
2028 */
2029 public static final class ConversationViewMode {
2030 /**
2031 * The user hasn't specified a mode.
2032 */
2033 public static final int UNDEFINED = -1;
2034 /**
2035 * Default to fit the conversation to screen view
2036 */
2037 public static final int OVERVIEW = 0;
2038 /**
2039 * Conversation text size should be the device default, and wide conversations may
2040 * require panning
2041 */
2042 public static final int READING = 1;
2043 }
2044
Paul Westbrook63eef792012-02-27 14:01:06 -08002045 public static final class SnapHeaderValue {
2046 public static final int ALWAYS = 0;
2047 public static final int PORTRAIT_ONLY = 1;
2048 public static final int NEVER = 2;
2049 }
2050
2051 public static final class MessageTextSize {
2052 public static final int TINY = -2;
2053 public static final int SMALL = -1;
2054 public static final int NORMAL = 0;
2055 public static final int LARGE = 1;
2056 public static final int HUGE = 2;
2057 }
2058
2059 public static final class DefaultReplyBehavior {
2060 public static final int REPLY = 0;
2061 public static final int REPLY_ALL = 1;
2062 }
2063
Paul Westbrookee0fda72012-03-19 10:13:36 -07002064 /**
Marc Blankbc6ba052012-03-19 10:46:07 -07002065 * Action for an intent used to update/create new notifications. The mime type of this
Paul Westbrookee0fda72012-03-19 10:13:36 -07002066 * intent should be set to the mimeType of the account that is generating this notification.
2067 * An intent of this action is required to have the following extras:
Andy Huangd8e249e2012-03-21 17:01:37 -07002068 * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT}
Paul Westbrookee0fda72012-03-19 10:13:36 -07002069 */
2070 public static final String ACTION_UPDATE_NOTIFICATION =
2071 "com.android.mail.action.update_notification";
2072
Marc Blankbc6ba052012-03-19 10:46:07 -07002073 public static final class UpdateNotificationExtras {
2074 /**
Paul Westbrook6ead20d2012-03-19 14:48:14 -07002075 * Parcelable extra containing a {@link Uri} to a {@link Folder}
Marc Blankbc6ba052012-03-19 10:46:07 -07002076 */
2077 public static final String EXTRA_FOLDER = "notification_extra_folder";
Paul Westbrookee0fda72012-03-19 10:13:36 -07002078
Marc Blankbc6ba052012-03-19 10:46:07 -07002079 /**
Paul Westbrook6ead20d2012-03-19 14:48:14 -07002080 * Parcelable extra containing a {@link Uri} to an {@link Account}
Marc Blankbc6ba052012-03-19 10:46:07 -07002081 */
2082 public static final String EXTRA_ACCOUNT = "notification_extra_account";
Paul Westbrook6ead20d2012-03-19 14:48:14 -07002083
2084 /**
2085 * Integer extra containing the update unread count for the account/folder.
2086 * If this value is 0, the UI will not block the intent to allow code to clear notifications
2087 * to run.
2088 */
2089 public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count";
Marc Blankbc6ba052012-03-19 10:46:07 -07002090 }
Paul Westbrooke5503552012-03-28 00:35:57 -07002091
2092 public static final class EditSettingsExtras {
2093 /**
2094 * Parcelable extra containing account for which the user wants to
2095 * modify settings
2096 */
2097 public static final String EXTRA_ACCOUNT = "extra_account";
2098
2099 /**
2100 * Parcelable extra containing folder for which the user wants to
2101 * modify settings
2102 */
2103 public static final String EXTRA_FOLDER = "extra_folder";
Paul Westbrook18babd22012-04-09 22:17:08 -07002104
2105 /**
2106 * Boolean extra which is set true if the user wants to "manage folders"
2107 */
2108 public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders";
Paul Westbrooke5503552012-03-28 00:35:57 -07002109 }
Paul Westbrook17beb0b2012-08-20 13:34:37 -07002110
2111 public static final class SendFeedbackExtras {
2112 /**
2113 * Optional boolean extras which indicates that the user is reporting a problem.
2114 */
2115 public static final String EXTRA_REPORTING_PROBLEM = "reporting_problem";
2116 }
Mark Wei9982fdb2012-08-30 18:27:46 -07002117
2118 public static final class ViewProxyExtras {
2119 /**
2120 * Uri extra passed to the proxy which indicates the original Uri that was intended to be
2121 * viewed.
2122 */
2123 public static final String EXTRA_ORIGINAL_URI = "original_uri";
2124 /**
2125 * Parcelable extra passed to the proxy which indicates the account being viewed from.
2126 */
2127 public static final String EXTRA_ACCOUNT = "account";
2128 /**
2129 * String extra passed from the proxy which indicates the salt used to generate the digest.
2130 */
2131 public static final String EXTRA_SALT = "salt";
2132 /**
2133 * Byte[] extra passed from the proxy which indicates the digest of the salted account name.
2134 */
2135 public static final String EXTRA_ACCOUNT_DIGEST = "digest";
2136 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -08002137}