UIProvider.java revision f33d7d469f861f8ebbe108c4ef90ef3fb348f224
1/******************************************************************************* 2 * Copyright (C) 2011 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 *******************************************************************************/ 17 18package com.android.mail.providers; 19 20import android.content.ContentProvider; 21import android.content.ContentValues; 22import android.database.Cursor; 23import android.net.Uri; 24import android.os.Bundle; 25import android.os.Parcelable; 26import android.provider.BaseColumns; 27import android.provider.OpenableColumns; 28import android.text.TextUtils; 29 30import com.google.common.collect.ImmutableMap; 31 32import java.util.Map; 33import java.util.regex.Pattern; 34 35public class UIProvider { 36 public static final String EMAIL_SEPARATOR = ","; 37 public static final long INVALID_CONVERSATION_ID = -1; 38 public static final long INVALID_MESSAGE_ID = -1; 39 40 /** 41 * Values for the current state of a Folder/Account; note that it's possible that more than one 42 * sync is in progress 43 */ 44 public static final class SyncStatus { 45 /** 46 * No sync in progress 47 */ 48 public static final int NO_SYNC = 0; 49 /** 50 * A user-requested sync/refresh is in progress. This occurs when the user taps on the 51 * refresh icon in the action bar. 52 */ 53 public static final int USER_REFRESH = 1<<0; 54 /** 55 * A user-requested live query is in progress. This occurs when the user goes past the end 56 * of the fetched results in the conversation list. 57 */ 58 public static final int LIVE_QUERY = 1<<1; 59 /** Please use the constant {@link #LIVE_QUERY} instead. */ 60 @Deprecated 61 public static final int USER_QUERY = 1<<1; 62 /** 63 * A background sync is in progress. This happens on <b>no</b> user interaction. 64 */ 65 public static final int BACKGROUND_SYNC = 1<<2; 66 /** 67 * An initial sync is needed for this Account/Folder to be used. This is account-wide, when 68 * the user has added an account, and the first sync has not completed successfully. 69 */ 70 public static final int INITIAL_SYNC_NEEDED = 1<<3; 71 /** 72 * Manual sync is required. This is account-wide, when the user has disabled sync on the 73 * Gmail account. 74 */ 75 public static final int MANUAL_SYNC_REQUIRED = 1<<4; 76 /** 77 * Account initialization is required. 78 */ 79 public static final int ACCOUNT_INITIALIZATION_REQUIRED = 1<<5; 80 81 public static boolean isSyncInProgress(int syncStatus) { 82 return 0 != (syncStatus & (BACKGROUND_SYNC | 83 USER_REFRESH | 84 LIVE_QUERY)); 85 } 86 } 87 88 /** 89 * Values for the result of the last attempted sync of a Folder/Account 90 */ 91 public static final class LastSyncResult { 92 /** The sync completed successfully */ 93 public static final int SUCCESS = 0; 94 /** The sync wasn't completed due to a connection error */ 95 public static final int CONNECTION_ERROR = 1; 96 /** The sync wasn't completed due to an authentication error */ 97 public static final int AUTH_ERROR = 2; 98 /** The sync wasn't completed due to a security error */ 99 public static final int SECURITY_ERROR = 3; 100 /** The sync wasn't completed due to a low memory condition */ 101 public static final int STORAGE_ERROR = 4; 102 /** The sync wasn't completed due to an internal error/exception */ 103 public static final int INTERNAL_ERROR = 5; 104 } 105 106 // The actual content provider should define its own authority 107 public static final String AUTHORITY = "com.android.mail.providers"; 108 109 public static final String ACCOUNT_LIST_TYPE = 110 "vnd.android.cursor.dir/vnd.com.android.mail.account"; 111 public static final String ACCOUNT_TYPE = 112 "vnd.android.cursor.item/vnd.com.android.mail.account"; 113 114 /** 115 * Query parameter key that can be used to control the behavior of list queries. The value 116 * must be a serialized {@link ListParams} object. UIProvider implementations are not 117 * required to respect this query parameter 118 */ 119 public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams"; 120 public static final String LABEL_QUERY_PARAMETER = "label"; 121 public static final String SEEN_QUERY_PARAMETER = "seen"; 122 123 /** 124 * Query parameter that can be used to specify a parent for a the returned folder object from a 125 * query. When set, if a folder is returned that does not have a true parent, it will use this 126 * uri as its parent uri. 127 */ 128 public static final String DEFAULT_PARENT_QUERY_PARAMETER = "defaultParent"; 129 130 public static final Map<String, Class<?>> ACCOUNTS_COLUMNS_NO_CAPABILITIES = 131 new ImmutableMap.Builder<String, Class<?>>() 132 .put(AccountColumns._ID, Integer.class) 133 .put(AccountColumns.NAME, String.class) 134 .put(AccountColumns.TYPE, String.class) 135 .put(AccountColumns.PROVIDER_VERSION, Integer.class) 136 .put(AccountColumns.URI, String.class) 137 .put(AccountColumns.FOLDER_LIST_URI, String.class) 138 .put(AccountColumns.FULL_FOLDER_LIST_URI, String.class) 139 .put(AccountColumns.SEARCH_URI, String.class) 140 .put(AccountColumns.ACCOUNT_FROM_ADDRESSES, String.class) 141 .put(AccountColumns.EXPUNGE_MESSAGE_URI, String.class) 142 .put(AccountColumns.UNDO_URI, String.class) 143 .put(AccountColumns.SETTINGS_INTENT_URI, String.class) 144 .put(AccountColumns.SYNC_STATUS, Integer.class) 145 .put(AccountColumns.HELP_INTENT_URI, String.class) 146 .put(AccountColumns.SEND_FEEDBACK_INTENT_URI, String.class) 147 .put(AccountColumns.REAUTHENTICATION_INTENT_URI, String.class) 148 .put(AccountColumns.COMPOSE_URI, String.class) 149 .put(AccountColumns.MIME_TYPE, String.class) 150 .put(AccountColumns.RECENT_FOLDER_LIST_URI, String.class) 151 .put(AccountColumns.COLOR, Integer.class) 152 .put(AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI, String.class) 153 .put(AccountColumns.MANUAL_SYNC_URI, String.class) 154 .put(AccountColumns.VIEW_INTENT_PROXY_URI, String.class) 155 .put(AccountColumns.ACCOUNT_COOKIE_QUERY_URI, String.class) 156 .put(AccountColumns.SettingsColumns.SIGNATURE, String.class) 157 .put(AccountColumns.SettingsColumns.AUTO_ADVANCE, Integer.class) 158 .put(AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE, Integer.class) 159 .put(AccountColumns.SettingsColumns.SNAP_HEADERS, Integer.class) 160 .put(AccountColumns.SettingsColumns.REPLY_BEHAVIOR, Integer.class) 161 .put(AccountColumns.SettingsColumns.CONV_LIST_ICON, Integer.class) 162 .put(AccountColumns.SettingsColumns.CONV_LIST_ATTACHMENT_PREVIEWS, Integer.class) 163 .put(AccountColumns.SettingsColumns.CONFIRM_DELETE, Integer.class) 164 .put(AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, Integer.class) 165 .put(AccountColumns.SettingsColumns.CONFIRM_SEND, Integer.class) 166 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX, String.class) 167 .put(AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, String.class) 168 .put(AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT, Integer.class) 169 .put(AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE, Integer.class) 170 .put(AccountColumns.SettingsColumns.SWIPE, Integer.class) 171 .put(AccountColumns.SettingsColumns.PRIORITY_ARROWS_ENABLED, Integer.class) 172 .put(AccountColumns.SettingsColumns.SETUP_INTENT_URI, String.class) 173 .put(AccountColumns.SettingsColumns.CONVERSATION_VIEW_MODE, Integer.class) 174 .put(AccountColumns.SettingsColumns.VEILED_ADDRESS_PATTERN, String.class) 175 .put(AccountColumns.UPDATE_SETTINGS_URI, String.class) 176 .put(AccountColumns.ENABLE_MESSAGE_TRANSFORMS, Integer.class) 177 .put(AccountColumns.SYNC_AUTHORITY, String.class) 178 .put(AccountColumns.QUICK_RESPONSE_URI, String.class) 179 .put(AccountColumns.SettingsColumns.MOVE_TO_INBOX, String.class) 180 .build(); 181 182 public static final Map<String, Class<?>> ACCOUNTS_COLUMNS = 183 new ImmutableMap.Builder<String, Class<?>>() 184 .putAll(ACCOUNTS_COLUMNS_NO_CAPABILITIES) 185 .put(AccountColumns.CAPABILITIES, Integer.class) 186 .build(); 187 188 // pull out the keyset from above to form the projection 189 public static final String[] ACCOUNTS_PROJECTION = 190 ACCOUNTS_COLUMNS.keySet().toArray(new String[ACCOUNTS_COLUMNS.size()]); 191 192 public static final 193 String[] ACCOUNTS_PROJECTION_NO_CAPABILITIES = ACCOUNTS_COLUMNS_NO_CAPABILITIES.keySet() 194 .toArray(new String[ACCOUNTS_COLUMNS_NO_CAPABILITIES.size()]); 195 196 public static final class AccountCapabilities { 197 /** 198 * Whether folders can be synchronized back to the server. 199 */ 200 public static final int SYNCABLE_FOLDERS = 0x0001; 201 /** 202 * Whether the server allows reporting spam back. 203 */ 204 public static final int REPORT_SPAM = 0x0002; 205 /** 206 * Whether the server allows reporting phishing back. 207 */ 208 public static final int REPORT_PHISHING = 0x0004; 209 /** 210 * Whether the server supports a concept of Archive: removing mail from the Inbox but 211 * keeping it around. 212 */ 213 public static final int ARCHIVE = 0x0008; 214 /** 215 * Whether the server will stop notifying on updates to this thread? This requires 216 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored. 217 */ 218 public static final int MUTE = 0x0010; 219 /** 220 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS 221 * to be true, otherwise it should be ignored. 222 */ 223 public static final int SERVER_SEARCH = 0x0020; 224 /** 225 * Whether the server supports constraining search to a single folder. Requires 226 * SYNCABLE_FOLDERS, otherwise it should be ignored. 227 */ 228 public static final int FOLDER_SERVER_SEARCH = 0x0040; 229 /** 230 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML). 231 */ 232 public static final int SANITIZED_HTML = 0x0080; 233 /** 234 * Whether the server allows synchronization of draft messages. This does NOT require 235 * SYNCABLE_FOLDERS to be set. 236 */ 237 public static final int DRAFT_SYNCHRONIZATION = 0x0100; 238 /** 239 * Does the server allow the user to compose mails (and reply) using addresses other than 240 * their account name? For instance, GMail allows users to set FROM addresses that are 241 * different from account@gmail.com address. For instance, user@gmail.com could have another 242 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he 243 * can compose (and reply) using either address. 244 */ 245 public static final int MULTIPLE_FROM_ADDRESSES = 0x0200; 246 /** 247 * Whether the server allows the original message to be included in the reply by setting a 248 * flag on the reply. If we can avoid including the entire previous message, we save on 249 * bandwidth (replies are shorter). 250 */ 251 public static final int SMART_REPLY = 0x0400; 252 /** 253 * Does this account support searching locally, on the device? This requires the backend 254 * storage to support a mechanism for searching. 255 */ 256 public static final int LOCAL_SEARCH = 0x0800; 257 /** 258 * Whether the server supports a notion of threaded conversations: where replies to messages 259 * are tagged to keep conversations grouped. This could be full threading (each message 260 * lists its parent) or conversation-level threading (each message lists one conversation 261 * which it belongs to) 262 */ 263 public static final int THREADED_CONVERSATIONS = 0x1000; 264 /** 265 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows 266 * multiple folders on a single conversation) 267 */ 268 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000; 269 /** 270 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar. 271 */ 272 public static final int UNDO = 0x4000; 273 /** 274 * Whether the account provides help content. 275 */ 276 public static final int HELP_CONTENT = 0x8000; 277 /** 278 * Whether the account provides a way to send feedback content. 279 */ 280 public static final int SEND_FEEDBACK = 0x10000; 281 /** 282 * Whether the account provides a mechanism for marking conversations as important. 283 */ 284 public static final int MARK_IMPORTANT = 0x20000; 285 /** 286 * Whether initial conversation queries should use a limit parameter 287 */ 288 public static final int INITIAL_CONVERSATION_LIMIT = 0x40000; 289 /** 290 * Whether the account cannot be used for sending 291 */ 292 public static final int SENDING_UNAVAILABLE = 0x80000; 293 /** 294 * Whether the account supports discarding drafts from a conversation. This should be 295 * removed when all providers support this capability 296 */ 297 public static final int DISCARD_CONVERSATION_DRAFTS = 0x100000; 298 /** 299 * Whether the account supports emptying the trash folder 300 */ 301 public static final int EMPTY_TRASH = 0x200000; 302 /** 303 * Whether the account supports emptying the spam folder 304 */ 305 public static final int EMPTY_SPAM = 0x400000; 306 } 307 308 public static final class AccountColumns implements BaseColumns { 309 /** 310 * This string column contains the human visible name for the account. 311 */ 312 public static final String NAME = "name"; 313 314 /** 315 * This integer contains the type of the account: Google versus non google. This is not 316 * returned by the UIProvider, rather this is a notion in the system. 317 */ 318 public static final String TYPE = "type"; 319 320 /** 321 * This integer column returns the version of the UI provider schema from which this 322 * account provider will return results. 323 */ 324 public static final String PROVIDER_VERSION = "providerVersion"; 325 326 /** 327 * This string column contains the uri to directly access the information for this account. 328 */ 329 public static final String URI = "accountUri"; 330 331 /** 332 * This integer column contains a bit field of the possible capabilities that this account 333 * supports. 334 */ 335 public static final String CAPABILITIES = "capabilities"; 336 337 /** 338 * This string column contains the content provider uri to return the 339 * list of top level folders for this account. 340 */ 341 public static final String FOLDER_LIST_URI = "folderListUri"; 342 343 /** 344 * This string column contains the content provider uri to return the 345 * list of all folders for this account. 346 */ 347 public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri"; 348 349 /** 350 * This string column contains the content provider uri that can be queried for search 351 * results. 352 * The supported query parameters are limited to those listed 353 * in {@link SearchQueryParameters} 354 * The cursor returned from this query is expected have one row, where the columnm are a 355 * subset of the columns specified in {@link FolderColumns} 356 */ 357 public static final String SEARCH_URI = "searchUri"; 358 359 /** 360 * This string column contains a json array of json objects representing 361 * custom from addresses for this account or null if there are none. 362 */ 363 public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses"; 364 365 /** 366 * This string column contains the content provider uri that can be used 367 * to expunge a message from this account. NOTE: This might be better to 368 * be an update operation on the messageUri. 369 * When {@link android.content.ContentResolver#update(Uri, ContentValues, String, String[])} 370 * is called with this uri, the {@link ContentValues} object is expected to have 371 * {@link BaseColumns#_ID} specified with the local message id of the message. 372 */ 373 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri"; 374 375 /** 376 * This string column contains the content provider uri that can be used 377 * to undo the last committed action. 378 */ 379 public static final String UNDO_URI = "undoUri"; 380 381 /** 382 * Uri for EDIT intent that will cause the settings screens for this account type to be 383 * shown. 384 * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate 385 * which settings the user wants to edit. 386 * TODO: When we want to support a heterogeneous set of account types, this value may need 387 * to be moved to a global content provider. 388 */ 389 public static final String SETTINGS_INTENT_URI = "accountSettingsIntentUri"; 390 391 /** 392 * Uri for VIEW intent that will cause the help screens for this account type to be 393 * shown. 394 * TODO: When we want to support a heterogeneous set of account types, this value may need 395 * to be moved to a global content provider. 396 */ 397 public static final String HELP_INTENT_URI = "helpIntentUri"; 398 399 /** 400 * Uri for VIEW intent that will cause the send feedback for this account type to be 401 * shown. 402 * TODO: When we want to support a heterogeneous set of account types, this value may need 403 * to be moved to a global content provider. 404 */ 405 public static final String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri"; 406 407 /** 408 * Uri for VIEW intent that will cause the user to be prompted for authentication for 409 * this account. startActivityForResult() will be called with this intent. Activities that 410 * handle this intent are expected to return {@link android.app.Activity#RESULT_OK} if the 411 * user successfully authenticated. 412 */ 413 public static final String REAUTHENTICATION_INTENT_URI = "reauthenticationUri"; 414 415 /** 416 * This int column contains the current sync status of the account (the logical AND of the 417 * sync status of folders in this account) 418 */ 419 public static final String SYNC_STATUS = "syncStatus"; 420 /** 421 * Uri for VIEW intent that will cause the compose screens for this type 422 * of account to be shown. 423 */ 424 public static final String COMPOSE_URI = "composeUri"; 425 /** 426 * Mime-type defining this account. 427 */ 428 public static final String MIME_TYPE = "mimeType"; 429 /** 430 * URI for location of recent folders viewed on this account. 431 */ 432 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri"; 433 /** 434 * URI for default recent folders for this account, if any. 435 */ 436 public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri"; 437 /** 438 * Color (integer) used for this account (for Email/Combined view) 439 */ 440 public static final String COLOR = "color"; 441 /** 442 * URI for forcing a manual sync of this account. 443 */ 444 public static final String MANUAL_SYNC_URI = "manualSyncUri"; 445 /** 446 * Optional URI of this account for proxying view intents. 447 */ 448 public static final String VIEW_INTENT_PROXY_URI = "viewProxyUri"; 449 /** 450 * Optional URI for querying for the cookie needed for accessing inline content. The cookie 451 * specified here will be set on the uri specified in the 452 * {@link ConversationColumns#CONVERSATION_BASE_URI} column. The cursor returned from this 453 * query is expected have one row, where the columns are specified in 454 * {@link AccountCookieColumns} 455 */ 456 public static final String ACCOUNT_COOKIE_QUERY_URI = "accountCookieUri"; 457 /** 458 * URI to be used with an update() ContentResolver call with a {@link ContentValues} object 459 * where the keys are from the {@link AccountColumns.SettingsColumns}, and the values are 460 * the new values. 461 */ 462 public static final String UPDATE_SETTINGS_URI = "updateSettingsUri"; 463 /** 464 * Whether message transforms (HTML DOM manipulation) should be enabled. 465 */ 466 public static final String ENABLE_MESSAGE_TRANSFORMS = "enableMessageTransforms"; 467 /** 468 * Sync authority to use. 469 */ 470 public static final String SYNC_AUTHORITY = "syncAuthority"; 471 /** 472 * URI for querying this account's quick responses 473 */ 474 public static final String QUICK_RESPONSE_URI = "quickResponseUri"; 475 476 public static final class SettingsColumns { 477 /** 478 * String column containing the contents of the signature for this account. If no 479 * signature has been specified, the value will be null. 480 */ 481 public static final String SIGNATURE = "signature"; 482 483 /** 484 * Integer column containing the user's specified auto-advance policy. This value will 485 * be one of the values in {@link UIProvider.AutoAdvance} 486 */ 487 public static final String AUTO_ADVANCE = "auto_advance"; 488 489 /** 490 * Integer column containing the user's specified message text size preference. This 491 * value will be one of the values in {@link UIProvider.MessageTextSize} 492 */ 493 public static final String MESSAGE_TEXT_SIZE = "message_text_size"; 494 495 /** 496 * Integer column contaning the user's specified snap header preference. This value 497 * will be one of the values in {@link UIProvider.SnapHeaderValue} 498 */ 499 public static final String SNAP_HEADERS = "snap_headers"; 500 501 /** 502 * Integer column containing the user's specified default reply behavior. This value 503 * will be one of the values in {@link UIProvider.DefaultReplyBehavior} 504 */ 505 public static final String REPLY_BEHAVIOR = "reply_behavior"; 506 507 /** 508 * Integer column containing the user's preference for whether to show sender images 509 * or not in the conversation list view. This value will be one of the values in 510 * {@link UIProvider.ConversationListIcon}. 511 */ 512 public static final String CONV_LIST_ICON = "conversation_list_icon"; 513 514 /** 515 * Integer column containing the user's preference for whether to show attachment 516 * previews or not in the conversation list view. A non zero value indicates that 517 * attachment previews should be displayed. 518 */ 519 public static final String CONV_LIST_ATTACHMENT_PREVIEWS 520 = "conversation_list_attachment_previews"; 521 522 /** 523 * Integer column containing the user's specified confirm delete preference value. 524 * A non zero value indicates that the user has indicated that a confirmation should 525 * be shown when a delete action is performed. 526 */ 527 public static final String CONFIRM_DELETE = "confirm_delete"; 528 529 /** 530 * Integer column containing the user's specified confirm archive preference value. 531 * A non zero value indicates that the user has indicated that a confirmation should 532 * be shown when an archive action is performed. 533 */ 534 public static final String CONFIRM_ARCHIVE = "confirm_archive"; 535 536 /** 537 * Integer column containing the user's specified confirm send preference value. 538 * A non zero value indicates that the user has indicated that a confirmation should 539 * be shown when a send action is performed. 540 */ 541 public static final String CONFIRM_SEND = "confirm_send"; 542 /** 543 * String containing the URI for the default inbox for this account. 544 */ 545 public static final String DEFAULT_INBOX = "default_inbox"; 546 /** 547 * String containing the name of the default Inbox for this account 548 */ 549 public static final String DEFAULT_INBOX_NAME = "default_inbox_name"; 550 /** 551 * Integer column containing a non zero value if replies should always be sent from 552 * a default address instead of a recipient. 553 */ 554 public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default"; 555 /** 556 * Integer column containing the max attachment size in kb. 557 */ 558 public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size"; 559 /** 560 * Integer column containing a value matching one of the constants from {@link Swipe} 561 */ 562 public static final String SWIPE = "swipe"; 563 /** 564 * Integer column containing whether priority inbox arrows are enabled. 565 */ 566 public static final String PRIORITY_ARROWS_ENABLED = "priority_inbox_arrows_enabled"; 567 /** 568 * Uri for EDIT intent that will cause account-specific setup UI to be shown. If not 569 * null, this intent should be used when an account is "entered" (i.e. viewing a folder 570 * in the account, etc.) 571 */ 572 public static final String SETUP_INTENT_URI = "setup_intent_uri"; 573 /** 574 * The regex that defines a veiled address, something that must be hidden from user 575 * view because it is temporary, long and clumsy. 576 */ 577 public static final String VEILED_ADDRESS_PATTERN = "veiled_address_pattern"; 578 /** 579 * Integer column containing the Conversation view mode. This value will match one of 580 * constants from {@link ConversationViewMode} 581 */ 582 public static final String CONVERSATION_VIEW_MODE = "conversation_view_mode"; 583 /** 584 * String containing the URI for the inbox conversations should be moved to for this 585 * account. 586 */ 587 public static final String MOVE_TO_INBOX = "move_to_inbox"; 588 } 589 } 590 591 public static final String[] QUICK_RESPONSE_PROJECTION = { 592 BaseColumns._ID, 593 QuickResponseColumns.TEXT, 594 QuickResponseColumns.URI 595 }; 596 597 public static final class QuickResponseColumns { 598 /** 599 * Text of the Quick Response 600 */ 601 public static final String TEXT = "quickResponse"; 602 /** 603 * URI to access this row directly 604 */ 605 public static final String URI = "uri"; 606 } 607 608 public static final String[] ACCOUNT_COOKIE_PROJECTION = { 609 AccountCookieColumns.COOKIE 610 }; 611 612 public static final class AccountCookieColumns { 613 /** 614 * String column containing the cookie string for this account. 615 */ 616 public static final String COOKIE = "cookie"; 617 } 618 619 public static final class SearchQueryParameters { 620 /** 621 * Parameter used to specify the search query. 622 */ 623 public static final String QUERY = "query"; 624 625 private SearchQueryParameters() {} 626 } 627 628 public static final class ConversationListQueryParameters { 629 public static final String DEFAULT_LIMIT = "50"; 630 /** 631 * Parameter used to limit the number of rows returned by a conversation list query 632 */ 633 public static final String LIMIT = "limit"; 634 635 /** 636 * Parameter used to control whether the this query a remote server. 637 */ 638 public static final String USE_NETWORK = "use_network"; 639 640 /** 641 * Parameter used to allow the caller to indicate desire to receive all notifications. 642 * (Including ones for user initiated actions) 643 */ 644 public static final String ALL_NOTIFICATIONS = "all_notifications"; 645 646 private ConversationListQueryParameters() {} 647 } 648 649 // We define a "folder" as anything that contains a list of conversations. 650 public static final String FOLDER_LIST_TYPE = 651 "vnd.android.cursor.dir/vnd.com.android.mail.folder"; 652 public static final String FOLDER_TYPE = 653 "vnd.android.cursor.item/vnd.com.android.mail.folder"; 654 655 public static final String[] FOLDERS_PROJECTION = { 656 BaseColumns._ID, 657 FolderColumns.PERSISTENT_ID, 658 FolderColumns.URI, 659 FolderColumns.NAME, 660 FolderColumns.HAS_CHILDREN, 661 FolderColumns.CAPABILITIES, 662 FolderColumns.SYNC_WINDOW, 663 FolderColumns.CONVERSATION_LIST_URI, 664 FolderColumns.CHILD_FOLDERS_LIST_URI, 665 FolderColumns.UNSEEN_COUNT, 666 FolderColumns.UNREAD_COUNT, 667 FolderColumns.TOTAL_COUNT, 668 FolderColumns.REFRESH_URI, 669 FolderColumns.SYNC_STATUS, 670 FolderColumns.LAST_SYNC_RESULT, 671 FolderColumns.TYPE, 672 FolderColumns.ICON_RES_ID, 673 FolderColumns.NOTIFICATION_ICON_RES_ID, 674 FolderColumns.BG_COLOR, 675 FolderColumns.FG_COLOR, 676 FolderColumns.LOAD_MORE_URI, 677 FolderColumns.HIERARCHICAL_DESC, 678 FolderColumns.LAST_MESSAGE_TIMESTAMP, 679 FolderColumns.PARENT_URI 680 }; 681 682 public static final int FOLDER_ID_COLUMN = 0; 683 public static final int FOLDER_PERSISTENT_ID_COLUMN = 1; 684 public static final int FOLDER_URI_COLUMN = 2; 685 public static final int FOLDER_NAME_COLUMN = 3; 686 public static final int FOLDER_HAS_CHILDREN_COLUMN = 4; 687 public static final int FOLDER_CAPABILITIES_COLUMN = 5; 688 public static final int FOLDER_SYNC_WINDOW_COLUMN = 6; 689 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 7; 690 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 8; 691 public static final int FOLDER_UNSEEN_COUNT_COLUMN = 9; 692 public static final int FOLDER_UNREAD_COUNT_COLUMN = 10; 693 public static final int FOLDER_TOTAL_COUNT_COLUMN = 11; 694 public static final int FOLDER_REFRESH_URI_COLUMN = 12; 695 public static final int FOLDER_SYNC_STATUS_COLUMN = 13; 696 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 14; 697 public static final int FOLDER_TYPE_COLUMN = 15; 698 public static final int FOLDER_ICON_RES_ID_COLUMN = 16; 699 public static final int FOLDER_NOTIFICATION_ICON_RES_ID_COLUMN = 17; 700 public static final int FOLDER_BG_COLOR_COLUMN = 18; 701 public static final int FOLDER_FG_COLOR_COLUMN = 19; 702 public static final int FOLDER_LOAD_MORE_URI_COLUMN = 20; 703 public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 21; 704 public static final int FOLDER_LAST_MESSAGE_TIMESTAMP_COLUMN = 22; 705 public static final int FOLDER_PARENT_URI_COLUMN = 23; 706 707 public static final class FolderType { 708 /** A user defined label. */ 709 public static final int DEFAULT = 1 << 0; 710 /** A system defined inbox */ 711 public static final int INBOX = 1 << 1; 712 /** A system defined containing mails to be edited before sending. */ 713 public static final int DRAFT = 1 << 2; 714 /** A system defined folder containing mails <b>to be</b> sent */ 715 public static final int OUTBOX = 1 << 3; 716 /** A system defined folder containing sent mails */ 717 public static final int SENT = 1 << 4; 718 /** A system defined trash folder */ 719 public static final int TRASH = 1 << 5; 720 /** A system defined spam folder */ 721 public static final int SPAM = 1 << 6; 722 /** A system defined starred folder */ 723 public static final int STARRED = 1 << 7; 724 /** Any other system label that we do not have a specific name for. */ 725 public static final int OTHER_PROVIDER_FOLDER = 1 << 8; 726 /** All mail folder */ 727 public static final int ALL_MAIL = 1 << 9; 728 /** Gmail's inbox sections */ 729 public static final int INBOX_SECTION = 1 << 10; 730 /** A system defined unread folder */ 731 public static final int UNREAD = 1 << 11; 732 } 733 734 public static final class FolderCapabilities { 735 public static final int SYNCABLE = 0x0001; 736 public static final int PARENT = 0x0002; 737 // FEEL FREE TO USE 0x0004 - was previous CAN_HOLD_MAIL but that was true for all 738 // folders so we removed that value 739 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; 740 /** 741 * For accounts that support archive, this will indicate that this folder supports 742 * the archive functionality. 743 */ 744 public static final int ARCHIVE = 0x0010; 745 746 /** 747 * This will indicated that this folder supports the delete functionality. 748 */ 749 public static final int DELETE = 0x0020; 750 751 /** 752 * For accounts that support report spam, this will indicate that this folder supports 753 * the report spam functionality. 754 */ 755 public static final int REPORT_SPAM = 0x0040; 756 757 /** 758 * For accounts that support report spam, this will indicate that this folder supports 759 * the mark not spam functionality. 760 */ 761 public static final int MARK_NOT_SPAM = 0x0080; 762 763 /** 764 * For accounts that support mute, this will indicate if a mute is performed from within 765 * this folder, the action is destructive. 766 */ 767 public static final int DESTRUCTIVE_MUTE = 0x0100; 768 769 /** 770 * Indicates that a folder supports settings (sync lookback, etc.) 771 */ 772 public static final int SUPPORTS_SETTINGS = 0x0200; 773 /** 774 * All the messages in this folder are important. 775 */ 776 public static final int ONLY_IMPORTANT = 0x0400; 777 /** 778 * Deletions in this folder can't be undone (could include archive if desirable) 779 */ 780 public static final int DELETE_ACTION_FINAL = 0x0800; 781 /** 782 * This folder is virtual, i.e. contains conversations potentially pulled from other 783 * folders, potentially even from different accounts. Examples might be a "starred" 784 * folder, or an "unread" folder (per account or provider-wide) 785 */ 786 public static final int IS_VIRTUAL = 0x1000; 787 788 /** 789 * For accounts that support report phishing, this will indicate that this folder supports 790 * the report phishing functionality. 791 */ 792 public static final int REPORT_PHISHING = 0x2000; 793 794 /** 795 * The flag indicates that the user has the ability to move conversations 796 * from this folder. 797 */ 798 public static final int ALLOWS_REMOVE_CONVERSATION = 0x4000; 799 800 /** 801 * The flag indicates that the user has the ability to move conversations to or from this 802 * Folder in the same operation as other Folder changes (usually through 803 * {@link com.android.mail.ui.MultiFoldersSelectionDialog}). 804 */ 805 public static final int MULTI_MOVE = 0x8000; 806 807 /** 808 * This flag indicates that a conversation may be moved from this folder into the account's 809 * inbox. 810 */ 811 public static final int ALLOWS_MOVE_TO_INBOX = 0x10000; 812 } 813 814 public static final class FolderColumns { 815 /** 816 * This string column contains an id for the folder that is constant across devices, or 817 * null if there is no constant id. 818 */ 819 public static final String PERSISTENT_ID = "persistentId"; 820 /** 821 * This string column contains the uri of the folder. 822 */ 823 public static final String URI = "folderUri"; 824 /** 825 * This string column contains the human visible name for the folder. 826 */ 827 public static final String NAME = "name"; 828 /** 829 * This int column represents the capabilities of the folder specified by 830 * FolderCapabilities flags. 831 */ 832 public static final String CAPABILITIES = "capabilities"; 833 /** 834 * This int column represents whether or not this folder has any 835 * child folders. 836 */ 837 public static final String HAS_CHILDREN = "hasChildren"; 838 /** 839 * This int column represents how large the sync window is. 840 */ 841 public static final String SYNC_WINDOW = "syncWindow"; 842 /** 843 * This string column contains the content provider uri to return the 844 * list of conversations for this folder. 845 */ 846 public static final String CONVERSATION_LIST_URI = "conversationListUri"; 847 /** 848 * This string column contains the content provider uri to return the 849 * list of child folders of this folder. 850 */ 851 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri"; 852 /** 853 * This int column contains the current unseen count for the folder, if known. 854 */ 855 public static final String UNSEEN_COUNT = "unseenCount"; 856 /** 857 * This int column contains the current unread count for the folder. 858 */ 859 public static final String UNREAD_COUNT = "unreadCount"; 860 861 public static final String TOTAL_COUNT = "totalCount"; 862 /** 863 * This string column contains the content provider uri to force a 864 * refresh of this folder. 865 */ 866 public static final String REFRESH_URI = "refreshUri"; 867 /** 868 * This int column contains current sync status of the folder; some combination of the 869 * SyncStatus bits defined above 870 */ 871 public static final String SYNC_STATUS = "syncStatus"; 872 /** 873 * This int column contains the sync status of the last sync attempt; one of the 874 * LastSyncStatus values defined above 875 */ 876 public static final String LAST_SYNC_RESULT = "lastSyncResult"; 877 /** 878 * This int column contains the icon res id for this folder, or 0 if there is none. 879 */ 880 public static final String ICON_RES_ID = "iconResId"; 881 /** 882 * This int column contains the notification icon res id for this folder, or 0 if there is 883 * none. 884 */ 885 public static final String NOTIFICATION_ICON_RES_ID = "notificationIconResId"; 886 /** 887 * This int column contains the type of the folder. Zero is default. 888 */ 889 public static final String TYPE = "type"; 890 /** 891 * String representing the integer background color associated with this 892 * folder, or null. 893 */ 894 public static final String BG_COLOR = "bgColor"; 895 /** 896 * String representing the integer of the foreground color associated 897 * with this folder, or null. 898 */ 899 public static final String FG_COLOR = "fgColor"; 900 /** 901 * String with the content provider Uri used to request more items in the folder, or null. 902 */ 903 public static final String LOAD_MORE_URI = "loadMoreUri"; 904 905 /** 906 * Possibly empty string that describes the full hierarchy of a folder 907 * along with its name. 908 */ 909 public static final String HIERARCHICAL_DESC = "hierarchicalDesc"; 910 911 /** 912 * The timestamp of the last message received in this folder. 913 */ 914 public static final String LAST_MESSAGE_TIMESTAMP = "lastMessageTimestamp"; 915 916 /** 917 * The URI, possibly null, of the parent folder. 918 */ 919 public static final String PARENT_URI = "parentUri"; 920 921 public FolderColumns() {} 922 } 923 924 // We define a "folder" as anything that contains a list of conversations. 925 public static final String CONVERSATION_LIST_TYPE = 926 "vnd.android.cursor.dir/vnd.com.android.mail.conversation"; 927 public static final String CONVERSATION_TYPE = 928 "vnd.android.cursor.item/vnd.com.android.mail.conversation"; 929 930 931 public static final String[] CONVERSATION_PROJECTION = { 932 BaseColumns._ID, 933 ConversationColumns.URI, 934 ConversationColumns.MESSAGE_LIST_URI, 935 ConversationColumns.SUBJECT, 936 ConversationColumns.SNIPPET, 937 ConversationColumns.CONVERSATION_INFO, 938 ConversationColumns.DATE_RECEIVED_MS, 939 ConversationColumns.HAS_ATTACHMENTS, 940 ConversationColumns.NUM_MESSAGES, 941 ConversationColumns.NUM_DRAFTS, 942 ConversationColumns.SENDING_STATE, 943 ConversationColumns.PRIORITY, 944 ConversationColumns.READ, 945 ConversationColumns.SEEN, 946 ConversationColumns.STARRED, 947 ConversationColumns.RAW_FOLDERS, 948 ConversationColumns.FLAGS, 949 ConversationColumns.PERSONAL_LEVEL, 950 ConversationColumns.SPAM, 951 ConversationColumns.PHISHING, 952 ConversationColumns.MUTED, 953 ConversationColumns.COLOR, 954 ConversationColumns.ACCOUNT_URI, 955 ConversationColumns.SENDER_INFO, 956 ConversationColumns.CONVERSATION_BASE_URI, 957 ConversationColumns.REMOTE, 958 ConversationColumns.ATTACHMENT_PREVIEW_URI0, 959 ConversationColumns.ATTACHMENT_PREVIEW_URI1, 960 ConversationColumns.ATTACHMENT_PREVIEW_STATES, 961 ConversationColumns.ATTACHMENT_PREVIEWS_COUNT, 962 }; 963 964 /** 965 * This integer corresponds to the number of rows of queries that specify the 966 * {@link UIProvider#CONVERSATION_PROJECTION} projection will fit in a single 967 * {@link android.database.CursorWindow} 968 */ 969 public static final int CONVERSATION_PROJECTION_QUERY_CURSOR_WINDOW_LIMT = 1500; 970 971 // These column indexes only work when the caller uses the 972 // default CONVERSATION_PROJECTION defined above. 973 public static final int CONVERSATION_ID_COLUMN = 0; 974 public static final int CONVERSATION_URI_COLUMN = 1; 975 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2; 976 public static final int CONVERSATION_SUBJECT_COLUMN = 3; 977 public static final int CONVERSATION_SNIPPET_COLUMN = 4; 978 public static final int CONVERSATION_INFO_COLUMN = 5; 979 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6; 980 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7; 981 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8; 982 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9; 983 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10; 984 public static final int CONVERSATION_PRIORITY_COLUMN = 11; 985 public static final int CONVERSATION_READ_COLUMN = 12; 986 public static final int CONVERSATION_SEEN_COLUMN = 13; 987 public static final int CONVERSATION_STARRED_COLUMN = 14; 988 public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 15; 989 public static final int CONVERSATION_FLAGS_COLUMN = 16; 990 public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 17; 991 public static final int CONVERSATION_IS_SPAM_COLUMN = 18; 992 public static final int CONVERSATION_IS_PHISHING_COLUMN = 19; 993 public static final int CONVERSATION_MUTED_COLUMN = 20; 994 public static final int CONVERSATION_COLOR_COLUMN = 21; 995 public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 22; 996 public static final int CONVERSATION_SENDER_INFO_COLUMN = 23; 997 public static final int CONVERSATION_BASE_URI_COLUMN = 24; 998 public static final int CONVERSATION_REMOTE_COLUMN = 25; 999 public static final int CONVERSATION_ATTACHMENT_PREVIEW_URI0_COLUMN = 26; 1000 public static final int CONVERSATION_ATTACHMENT_PREVIEW_URI1_COLUMN = 27; 1001 public static final int CONVERSATION_ATTACHMENT_PREVIEW_STATES_COLUMN = 28; 1002 public static final int CONVERSATION_ATTACHMENT_PREVIEWS_COUNT_COLUMN = 29; 1003 1004 public static final class ConversationSendingState { 1005 public static final int OTHER = 0; 1006 public static final int QUEUED = 1; 1007 public static final int SENDING = 2; 1008 public static final int SENT = 3; 1009 public static final int SEND_ERROR = -1; 1010 } 1011 1012 public static final class ConversationPriority { 1013 public static final int DEFAULT = 0; 1014 public static final int IMPORTANT = 1; 1015 public static final int LOW = 0; 1016 public static final int HIGH = 1; 1017 } 1018 1019 public static final class ConversationPersonalLevel { 1020 public static final int NOT_TO_ME = 0; 1021 public static final int TO_ME_AND_OTHERS = 1; 1022 public static final int ONLY_TO_ME = 2; 1023 } 1024 1025 public static final class ConversationFlags { 1026 public static final int REPLIED = 1<<2; 1027 public static final int FORWARDED = 1<<3; 1028 public static final int CALENDAR_INVITE = 1<<4; 1029 } 1030 1031 public static final class ConversationPhishing { 1032 public static final int NOT_PHISHING = 0; 1033 public static final int PHISHING = 1; 1034 } 1035 1036 /** 1037 * Names of columns representing fields in a Conversation. 1038 */ 1039 public static final class ConversationColumns { 1040 public static final String URI = "conversationUri"; 1041 /** 1042 * This string column contains the content provider uri to return the 1043 * list of messages for this conversation. 1044 * The cursor returned by this query can return a {@link android.os.Bundle} 1045 * from a call to {@link android.database.Cursor#getExtras()}. This Bundle may have 1046 * values with keys listed in {@link CursorExtraKeys} 1047 */ 1048 public static final String MESSAGE_LIST_URI = "messageListUri"; 1049 /** 1050 * This string column contains the subject string for a conversation. 1051 */ 1052 public static final String SUBJECT = "subject"; 1053 /** 1054 * This string column contains the snippet string for a conversation. 1055 */ 1056 public static final String SNIPPET = "snippet"; 1057 /** 1058 * @deprecated 1059 */ 1060 @Deprecated 1061 public static final String SENDER_INFO = "senderInfo"; 1062 /** 1063 * This blob column contains the byte-array representation of the Parceled 1064 * ConversationInfo object for a conversation. 1065 * 1066 * @deprecated providers should implement 1067 * {@link ConversationCursorCommand#COMMAND_GET_CONVERSATION_INFO} instead. 1068 */ 1069 @Deprecated 1070 public static final String CONVERSATION_INFO = "conversationInfo"; 1071 /** 1072 * This long column contains the time in ms of the latest update to a 1073 * conversation. 1074 */ 1075 public static final String DATE_RECEIVED_MS = "dateReceivedMs"; 1076 1077 /** 1078 * This boolean column contains whether any messages in this conversation 1079 * have attachments. 1080 */ 1081 public static final String HAS_ATTACHMENTS = "hasAttachments"; 1082 1083 /** 1084 * This int column contains the number of messages in this conversation. 1085 * For unthreaded, this will always be 1. 1086 */ 1087 public static final String NUM_MESSAGES = "numMessages"; 1088 1089 /** 1090 * This int column contains the number of drafts associated with this 1091 * conversation. 1092 */ 1093 public static final String NUM_DRAFTS = "numDrafts"; 1094 1095 /** 1096 * This int column contains the state of drafts and replies associated 1097 * with this conversation. Use ConversationSendingState to interpret 1098 * this field. 1099 */ 1100 public static final String SENDING_STATE = "sendingState"; 1101 1102 /** 1103 * This int column contains the priority of this conversation. Use 1104 * ConversationPriority to interpret this field. 1105 */ 1106 public static final String PRIORITY = "priority"; 1107 1108 /** 1109 * This int column indicates whether the conversation has been read 1110 */ 1111 public static final String READ = "read"; 1112 1113 /** 1114 * This int column indicates whether the conversation has been seen 1115 */ 1116 public static final String SEEN = "seen"; 1117 1118 /** 1119 * This int column indicates whether the conversation has been starred 1120 */ 1121 public static final String STARRED = "starred"; 1122 1123 /** 1124 * This blob column contains the marshalled form of a Parceled 1125 * {@FolderList} object. Ideally, only ever use this for 1126 * rendering the folder list for a conversation. 1127 * 1128 * @deprecated providers should implement 1129 * {@link ConversationCursorCommand#COMMAND_GET_RAW_FOLDERS} instead. 1130 */ 1131 @Deprecated 1132 public static final String RAW_FOLDERS = "rawFolders"; 1133 public static final String FLAGS = "conversationFlags"; 1134 /** 1135 * This int column indicates the personal level of a conversation per 1136 * {@link ConversationPersonalLevel}. 1137 */ 1138 public static final String PERSONAL_LEVEL = "personalLevel"; 1139 1140 /** 1141 * This int column indicates whether the conversation is marked spam. 1142 */ 1143 public static final String SPAM = "spam"; 1144 1145 /** 1146 * This int column indicates whether the conversation is marked phishing. 1147 */ 1148 public static final String PHISHING = "phishing"; 1149 1150 /** 1151 * This int column indicates whether the conversation was muted. 1152 */ 1153 public static final String MUTED = "muted"; 1154 1155 /** 1156 * This int column contains a color for the conversation (used in Email only) 1157 */ 1158 public static final String COLOR = "color"; 1159 1160 /** 1161 * This String column contains the Uri for this conversation's account 1162 */ 1163 public static final String ACCOUNT_URI = "accountUri"; 1164 /** 1165 * This int column indicates whether a conversation is remote (non-local), and would require 1166 * a network fetch to load. 1167 */ 1168 public static final String REMOTE = "remote"; 1169 /** 1170 * This int column indicates whether the conversation was displayed on the UI and the 1171 * user got a chance to read it. The UI does not read this value, it is meant only to 1172 * write the status back to the provider. As a result, it is not available in the 1173 * {@link Conversation} object. 1174 */ 1175 public static final String VIEWED = "viewed"; 1176 /** 1177 * This String column contains the base uri for this conversation. This uri can be used 1178 * when handling relative urls in the message content 1179 */ 1180 public static final String CONVERSATION_BASE_URI = "conversationBaseUri"; 1181 1182 /** 1183 * This string column contains the uri of the first attachment preview of the first unread 1184 * message, denoted by UNREAD_MESSAGE_ID. 1185 */ 1186 public static final String ATTACHMENT_PREVIEW_URI0 = "attachmentPreviewUri0"; 1187 1188 /** 1189 * This string column contains the uri of the second attachment preview of the first unread 1190 * message, denoted by UNREAD_MESSAGE_ID. 1191 */ 1192 public static final String ATTACHMENT_PREVIEW_URI1 = "attachmentPreviewUri1"; 1193 1194 /** 1195 * This int column contains the states of the attachment previews of the first unread 1196 * message, the same message used for the snippet. The states is a packed int, 1197 * where the first and second bits represent the SIMPLE and BEST state of the first 1198 * attachment preview, while the third and fourth bits represent those states for the 1199 * second attachment preview. For each bit, a one means that rendition of that attachment 1200 * preview is downloaded. 1201 */ 1202 public static final String ATTACHMENT_PREVIEW_STATES = "attachmentPreviewStates"; 1203 1204 /** 1205 * This int column contains the total count of images in the first unread message. The 1206 * total count may be higher than the number of ATTACHMENT_PREVIEW_URI columns. 1207 */ 1208 public static final String ATTACHMENT_PREVIEWS_COUNT = "attachmentPreviewsCount"; 1209 1210 private ConversationColumns() { 1211 } 1212 } 1213 1214 public static final class ConversationCursorCommand { 1215 1216 public static final String COMMAND_RESPONSE_OK = "ok"; 1217 public static final String COMMAND_RESPONSE_FAILED = "failed"; 1218 1219 /** 1220 * Incoming bundles may include this key with an Integer bitfield value. See below for bit 1221 * values. 1222 */ 1223 public static final String COMMAND_KEY_OPTIONS = "options"; 1224 1225 /** 1226 * Clients must set this bit when the {@link Cursor#respond(Bundle)} call is being used to 1227 * fetch a {@link Parcelable}. It serves as a hint that this call requires the cursor 1228 * position to first safely be moved. 1229 */ 1230 public static final int OPTION_MOVE_POSITION = 0x01; 1231 1232 /** 1233 * This bundle key has a boolean value: true to indicate that this cursor has been shown 1234 * to the user. 1235 * <p> 1236 * A provider that implements this command should include this key in its response with a 1237 * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. 1238 */ 1239 public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility"; 1240 1241 /** 1242 * This key has a boolean value: true to indicate that this folder list is shown to the user 1243 * either on first call (launcher/widget/notification) or after switching from an existing 1244 * folder: Inbox -> Folder. Repeated calls are sent when switching back to the folder. Inbox 1245 * -> Folder -> Spam -> Folder will generate two calls to respond() with the value true for 1246 * "Folder". 1247 * <p> 1248 * A provider that implements this command should include the 1249 * {@link #COMMAND_KEY_SET_VISIBILITY} key in its response with a value of 1250 * {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. This is <b>always</b> 1251 * set with {@link #COMMAND_KEY_SET_VISIBILITY} because this is only set when the folder 1252 * list is made visible. 1253 */ 1254 public static final String COMMAND_KEY_ENTERED_FOLDER = "enteredFolder"; 1255 1256 /** 1257 * This key has an int value, indicating the position that the UI wants to notify the 1258 * provider that the data from a specified row is being shown to the user. 1259 * <p> 1260 * A provider that implements this command should include the 1261 * {@link #COMMAND_NOTIFY_CURSOR_UI_POSITION_CHANGE} key in its response with a value of 1262 * {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. 1263 */ 1264 public static final String COMMAND_NOTIFY_CURSOR_UI_POSITION_CHANGE = "uiPositionChange"; 1265 1266 /** 1267 * Rather than jamming a {@link ConversationInfo} into a byte-array blob to be read out of 1268 * a cursor, providers can optionally implement this command to directly return the object 1269 * in a Bundle. 1270 * <p> 1271 * The requestor (UI code) will place a meaningless value in the request Bundle. The UI will 1272 * also move the cursor position to the desired place prior to calling respond(). Providers 1273 * should just use {@link Bundle#containsKey(String)} to check for this kind of request and 1274 * generate an object at the current cursor position. 1275 * <p> 1276 * A provider that implements this command should include the 1277 * {@link #COMMAND_GET_CONVERSATION_INFO} key in its response with a 1278 * {@link ConversationInfo} Parcelable object as its value. 1279 */ 1280 public static final String COMMAND_GET_CONVERSATION_INFO = 1281 ConversationColumns.CONVERSATION_INFO; 1282 1283 /** 1284 * Rather than jamming a {@link FolderList} into a byte-array blob to be read out of 1285 * a cursor, providers can optionally implement this command to directly return the object 1286 * in a Bundle. 1287 * <p> 1288 * The requestor (UI code) will place a meaningless value in the request Bundle. The UI will 1289 * also move the cursor position to the desired place prior to calling respond(). Providers 1290 * should just use {@link Bundle#containsKey(String)} to check for this kind of request and 1291 * generate an object at the current cursor position. 1292 * <p> 1293 * A provider that implements this command should include the 1294 * {@link #COMMAND_GET_RAW_FOLDERS} key in its response with a 1295 * {@link FolderList} Parcelable object as its value. 1296 */ 1297 public static final String COMMAND_GET_RAW_FOLDERS = ConversationColumns.RAW_FOLDERS; 1298 1299 private ConversationCursorCommand() {} 1300 } 1301 1302 /** 1303 * List of operations that can can be performed on a conversation. These operations are applied 1304 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} 1305 * where the conversation uri is specified, and the ContentValues specifies the operation to 1306 * be performed. 1307 * <p/> 1308 * The operation to be performed is specified in the ContentValues by 1309 * the {@link ConversationOperations#OPERATION_KEY} 1310 * <p/> 1311 * Note not all UI providers will support these operations. {@link AccountCapabilities} can 1312 * be used to determine which operations are supported. 1313 */ 1314 public static final class ConversationOperations { 1315 /** 1316 * ContentValues key used to specify the operation to be performed 1317 */ 1318 public static final String OPERATION_KEY = "operation"; 1319 1320 /** 1321 * Archive operation 1322 */ 1323 public static final String ARCHIVE = "archive"; 1324 1325 /** 1326 * Mute operation 1327 */ 1328 public static final String MUTE = "mute"; 1329 1330 /** 1331 * Report spam operation 1332 */ 1333 public static final String REPORT_SPAM = "report_spam"; 1334 1335 /** 1336 * Report not spam operation 1337 */ 1338 public static final String REPORT_NOT_SPAM = "report_not_spam"; 1339 1340 /** 1341 * Report phishing operation 1342 */ 1343 public static final String REPORT_PHISHING = "report_phishing"; 1344 1345 /** 1346 * Discard drafts operation 1347 */ 1348 public static final String DISCARD_DRAFTS = "discard_drafts"; 1349 1350 /** 1351 * Update conversation folder(s) operation. ContentValues passed as part 1352 * of this update will be of the format (FOLDERS_UPDATED, csv of updated 1353 * folders) where the comma separated values of the updated folders will 1354 * be of the format: folderuri/ADD_VALUE. ADD_VALUE will be true if the 1355 * folder was added, false if it was removed. 1356 */ 1357 public static final String FOLDERS_UPDATED = "folders_updated"; 1358 public static final String FOLDERS_UPDATED_SPLIT_PATTERN = ","; 1359 1360 public static final class Parameters { 1361 /** 1362 * Boolean indicating whether the undo for this operation should be suppressed 1363 */ 1364 public static final String SUPPRESS_UNDO = "suppress_undo"; 1365 1366 private Parameters() {} 1367 } 1368 1369 private ConversationOperations() { 1370 } 1371 } 1372 1373 /** 1374 * Methods that can be "called" using the account uri, through 1375 * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} 1376 * Note, the arg parmateter of call should be the account uri. 1377 */ 1378 public static final class AccountCallMethods { 1379 /** 1380 * Save message method. The Bundle for the call to 1381 * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the 1382 * columns specified in {@link MessageColumns}, and if this is a save for an existing 1383 * message, an entry for the {@link MessageColumns#URI} should reference the existing 1384 * message 1385 * 1386 * The Bundle returned will contain the message uri in the returned bundled with the 1387 * {@link MessageColumns#URI} key. 1388 */ 1389 public static final String SAVE_MESSAGE = "save_message"; 1390 1391 /** 1392 * Send message method. The Bundle for the call to 1393 * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the 1394 * columns specified in {@link MessageColumns}, and if this is a send of an existing 1395 * message, an entry for the {@link MessageColumns#URI} should reference the existing 1396 * message 1397 * 1398 * The Bundle returned will contain the message uri in the returned bundled with the 1399 * {@link MessageColumns#URI} key. 1400 */ 1401 public static final String SEND_MESSAGE = "send_message"; 1402 1403 /** 1404 * Change account method. The Bundle for the call to 1405 * {@link android.content.ContentResolver#call(Uri,String,String,Bundle)} should have the 1406 * columns specified in {@link SetCurrentAccountColumns} 1407 * 1408 * The Bundle returned will be empty. 1409 */ 1410 public static final String SET_CURRENT_ACCOUNT = "set_current_account"; 1411 1412 private AccountCallMethods() {} 1413 } 1414 1415 /** 1416 * Keys used for parameters to {@link AccountCallMethods#SEND_MESSAGE} or 1417 * {@link AccountCallMethods#SAVE_MESSAGE} methods. 1418 */ 1419 public static final class SendOrSaveMethodParamKeys { 1420 /** 1421 * Bundle key used to store any opened file descriptors. 1422 * The keys of this Bundle are the contentUri for each attachment, and the 1423 * values are {@link android.os.ParcelFileDescriptor} objects. 1424 */ 1425 public static final String OPENED_FD_MAP = "opened_fds"; 1426 1427 private SendOrSaveMethodParamKeys() {} 1428 } 1429 1430 public static final class DraftType { 1431 public static final int NOT_A_DRAFT = 0; 1432 public static final int COMPOSE = 1; 1433 public static final int REPLY = 2; 1434 public static final int REPLY_ALL = 3; 1435 public static final int FORWARD = 4; 1436 1437 private DraftType() {} 1438 } 1439 1440 /** 1441 * Class for the enum values to determine whether this 1442 * string should be displayed as a high priority warning 1443 * or a low priority warning. The current design has 1444 * high priority warnings in red while low priority warnings 1445 * are grey. 1446 */ 1447 public static final class SpamWarningLevel { 1448 public static final int NO_WARNING = 0; 1449 public static final int LOW_WARNING = 1; 1450 public static final int HIGH_WARNING = 2; 1451 1452 private SpamWarningLevel() {} 1453 } 1454 1455 /** 1456 * Class for the enum values to determine which type 1457 * of link to show in the spam warning. 1458 */ 1459 public static final class SpamWarningLinkType { 1460 public static final int NO_LINK = 0; 1461 public static final int IGNORE_WARNING = 1; 1462 public static final int REPORT_PHISHING = 2; 1463 1464 private SpamWarningLinkType() {} 1465 } 1466 1467 public static final String[] MESSAGE_PROJECTION = { 1468 BaseColumns._ID, 1469 MessageColumns.SERVER_ID, 1470 MessageColumns.URI, 1471 MessageColumns.CONVERSATION_ID, 1472 MessageColumns.SUBJECT, 1473 MessageColumns.SNIPPET, 1474 MessageColumns.FROM, 1475 MessageColumns.TO, 1476 MessageColumns.CC, 1477 MessageColumns.BCC, 1478 MessageColumns.REPLY_TO, 1479 MessageColumns.DATE_RECEIVED_MS, 1480 MessageColumns.BODY_HTML, 1481 MessageColumns.BODY_TEXT, 1482 MessageColumns.EMBEDS_EXTERNAL_RESOURCES, 1483 MessageColumns.REF_MESSAGE_ID, 1484 MessageColumns.DRAFT_TYPE, 1485 MessageColumns.APPEND_REF_MESSAGE_CONTENT, 1486 MessageColumns.HAS_ATTACHMENTS, 1487 MessageColumns.ATTACHMENT_LIST_URI, 1488 MessageColumns.MESSAGE_FLAGS, 1489 MessageColumns.ALWAYS_SHOW_IMAGES, 1490 MessageColumns.READ, 1491 MessageColumns.SEEN, 1492 MessageColumns.STARRED, 1493 MessageColumns.QUOTE_START_POS, 1494 MessageColumns.ATTACHMENTS, 1495 MessageColumns.CUSTOM_FROM_ADDRESS, 1496 MessageColumns.MESSAGE_ACCOUNT_URI, 1497 MessageColumns.EVENT_INTENT_URI, 1498 MessageColumns.SPAM_WARNING_STRING, 1499 MessageColumns.SPAM_WARNING_LEVEL, 1500 MessageColumns.SPAM_WARNING_LINK_TYPE, 1501 MessageColumns.VIA_DOMAIN, 1502 MessageColumns.IS_SENDING 1503 }; 1504 1505 /** Separates attachment info parts in strings in a message. */ 1506 @Deprecated 1507 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n"; 1508 public static final String MESSAGE_LIST_TYPE = 1509 "vnd.android.cursor.dir/vnd.com.android.mail.message"; 1510 public static final String MESSAGE_TYPE = 1511 "vnd.android.cursor.item/vnd.com.android.mail.message"; 1512 1513 public static final int MESSAGE_ID_COLUMN = 0; 1514 public static final int MESSAGE_SERVER_ID_COLUMN = 1; 1515 public static final int MESSAGE_URI_COLUMN = 2; 1516 public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3; 1517 public static final int MESSAGE_SUBJECT_COLUMN = 4; 1518 public static final int MESSAGE_SNIPPET_COLUMN = 5; 1519 public static final int MESSAGE_FROM_COLUMN = 6; 1520 public static final int MESSAGE_TO_COLUMN = 7; 1521 public static final int MESSAGE_CC_COLUMN = 8; 1522 public static final int MESSAGE_BCC_COLUMN = 9; 1523 public static final int MESSAGE_REPLY_TO_COLUMN = 10; 1524 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11; 1525 public static final int MESSAGE_BODY_HTML_COLUMN = 12; 1526 public static final int MESSAGE_BODY_TEXT_COLUMN = 13; 1527 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14; 1528 public static final int MESSAGE_REF_MESSAGE_URI_COLUMN = 15; 1529 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16; 1530 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17; 1531 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18; 1532 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19; 1533 public static final int MESSAGE_FLAGS_COLUMN = 20; 1534 public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 21; 1535 public static final int MESSAGE_READ_COLUMN = 22; 1536 public static final int MESSAGE_SEEN_COLUMN = 23; 1537 public static final int MESSAGE_STARRED_COLUMN = 24; 1538 public static final int QUOTED_TEXT_OFFSET_COLUMN = 25; 1539 public static final int MESSAGE_ATTACHMENTS_COLUMN = 26; 1540 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 27; 1541 public static final int MESSAGE_ACCOUNT_URI_COLUMN = 28; 1542 public static final int MESSAGE_EVENT_INTENT_COLUMN = 29; 1543 public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 30; 1544 public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 31; 1545 public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 32; 1546 public static final int MESSAGE_VIA_DOMAIN_COLUMN = 33; 1547 public static final int MESSAGE_IS_SENDING_COLUMN = 34; 1548 1549 public static final class CursorStatus { 1550 // The cursor is actively loading more data 1551 public static final int LOADING = 1 << 0; 1552 1553 // The cursor is currently not loading more data, but more data may be available 1554 public static final int LOADED = 1 << 1; 1555 1556 // An error occured while loading data 1557 public static final int ERROR = 1 << 2; 1558 1559 // The cursor is loaded, and there will be no more data 1560 public static final int COMPLETE = 1 << 3; 1561 1562 public static boolean isWaitingForResults(int cursorStatus) { 1563 return 0 != (cursorStatus & LOADING); 1564 } 1565 } 1566 1567 1568 public static final class CursorExtraKeys { 1569 /** 1570 * This integer column contains the staus of the message cursor. The value will be 1571 * one defined in {@link CursorStatus}. 1572 */ 1573 public static final String EXTRA_STATUS = "cursor_status"; 1574 1575 /** 1576 * Used for finding the cause of an error. 1577 * TODO: define these values 1578 */ 1579 public static final String EXTRA_ERROR = "cursor_error"; 1580 1581 1582 /** 1583 * This integer column contains the total message count for this folder. 1584 */ 1585 public static final String EXTRA_TOTAL_COUNT = "cursor_total_count"; 1586 } 1587 1588 public static final class AccountCursorExtraKeys { 1589 /** 1590 * This integer column contains the staus of the account cursor. The value will be 1591 * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully 1592 * initialized 1593 */ 1594 public static final String ACCOUNTS_LOADED = "accounts_loaded"; 1595 } 1596 1597 1598 public static final class MessageFlags { 1599 public static final int REPLIED = 1 << 2; 1600 public static final int FORWARDED = 1 << 3; 1601 public static final int CALENDAR_INVITE = 1 << 4; 1602 } 1603 1604 public static final class MessageColumns { 1605 /** 1606 * This string column contains a content provider URI that points to this single message. 1607 */ 1608 public static final String URI = "messageUri"; 1609 /** 1610 * This string column contains a server-assigned ID for this message. 1611 */ 1612 public static final String SERVER_ID = "serverMessageId"; 1613 public static final String CONVERSATION_ID = "conversationId"; 1614 /** 1615 * This string column contains the subject of a message. 1616 */ 1617 public static final String SUBJECT = "subject"; 1618 /** 1619 * This string column contains a snippet of the message body. 1620 */ 1621 public static final String SNIPPET = "snippet"; 1622 /** 1623 * This string column contains the single email address (and optionally name) of the sender. 1624 */ 1625 public static final String FROM = "fromAddress"; 1626 /** 1627 * This string column contains a comma-delimited list of "To:" recipient email addresses. 1628 */ 1629 public static final String TO = "toAddresses"; 1630 /** 1631 * This string column contains a comma-delimited list of "CC:" recipient email addresses. 1632 */ 1633 public static final String CC = "ccAddresses"; 1634 /** 1635 * This string column contains a comma-delimited list of "BCC:" recipient email addresses. 1636 * This value will be null for incoming messages. 1637 */ 1638 public static final String BCC = "bccAddresses"; 1639 /** 1640 * This string column contains the single email address (and optionally name) of the 1641 * sender's reply-to address. 1642 */ 1643 public static final String REPLY_TO = "replyToAddress"; 1644 /** 1645 * This long column contains the timestamp (in millis) of receipt of the message. 1646 */ 1647 public static final String DATE_RECEIVED_MS = "dateReceivedMs"; 1648 /** 1649 * This string column contains the HTML form of the message body, if available. If not, 1650 * a provider must populate BODY_TEXT. 1651 */ 1652 public static final String BODY_HTML = "bodyHtml"; 1653 /** 1654 * This string column contains the plaintext form of the message body, if HTML is not 1655 * otherwise available. If HTML is available, this value should be left empty (null). 1656 */ 1657 public static final String BODY_TEXT = "bodyText"; 1658 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources"; 1659 /** 1660 * This string column contains an opaque string used by the sendMessage api. 1661 */ 1662 public static final String REF_MESSAGE_ID = "refMessageId"; 1663 /** 1664 * This integer column contains the type of this draft, or zero (0) if this message is not a 1665 * draft. See {@link DraftType} for possible values. 1666 */ 1667 public static final String DRAFT_TYPE = "draftType"; 1668 /** 1669 * This boolean column indicates whether an outgoing message should trigger special quoted 1670 * text processing upon send. The value should default to zero (0) for protocols that do 1671 * not support or require this flag, and for all incoming messages. 1672 */ 1673 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent"; 1674 /** 1675 * This boolean column indicates whether a message has attachments. The list of attachments 1676 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}. 1677 */ 1678 public static final String HAS_ATTACHMENTS = "hasAttachments"; 1679 /** 1680 * This string column contains the content provider URI for the list of 1681 * attachments associated with this message. 1682 */ 1683 public static final String ATTACHMENT_LIST_URI = "attachmentListUri"; 1684 /** 1685 * This long column is a bit field of flags defined in {@link MessageFlags}. 1686 */ 1687 public static final String MESSAGE_FLAGS = "messageFlags"; 1688 /** 1689 * This integer column represents whether the user has specified that images should always 1690 * be shown. The value of "1" indicates that the user has specified that images should be 1691 * shown, while the value of "0" indicates that the user should be prompted before loading 1692 * any external images. 1693 */ 1694 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages"; 1695 1696 /** 1697 * This boolean column indicates whether the message has been read 1698 */ 1699 public static final String READ = "read"; 1700 1701 /** 1702 * This boolean column indicates whether the message has been seen 1703 */ 1704 public static final String SEEN = "seen"; 1705 1706 /** 1707 * This boolean column indicates whether the message has been starred 1708 */ 1709 public static final String STARRED = "starred"; 1710 1711 /** 1712 * This integer column represents the offset in the message of quoted 1713 * text. If include_quoted_text is zero, the value contained in this 1714 * column is invalid. 1715 */ 1716 public static final String QUOTE_START_POS = "quotedTextStartPos"; 1717 1718 /** 1719 * This string columns contains a JSON array of serialized {@link Attachment} objects. 1720 */ 1721 public static final String ATTACHMENTS = "attachments"; 1722 public static final String CUSTOM_FROM_ADDRESS = "customFrom"; 1723 /** 1724 * Uri of the account associated with this message. Except in the case 1725 * of showing a combined view, this column is almost always empty. 1726 */ 1727 public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri"; 1728 /** 1729 * Intent Uri to launch when the user wants to view an event in their calendar, or null. 1730 */ 1731 public static final String EVENT_INTENT_URI = "eventIntentUri"; 1732 /** 1733 * This string column contains the string for the spam 1734 * warning of this message, or null if there is no spam warning for the message. 1735 */ 1736 public static final String SPAM_WARNING_STRING = "spamWarningString"; 1737 /** 1738 * This integer column contains the level of spam warning of this message, 1739 * or zero (0) if this message does not have a warning level. 1740 * See {@link SpamWarningLevel} for possible values. 1741 */ 1742 public static final String SPAM_WARNING_LEVEL = "spamWarningLevel"; 1743 /** 1744 * This integer column contains the type of link for the spam warning 1745 * of this message, or zero (0) if this message does not have a link type. 1746 * See {@link SpamWarningLinkType} for possible values. 1747 */ 1748 public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType"; 1749 /** 1750 * This string column contains the string for the via domain 1751 * to be included if this message was sent via an alternate 1752 * domain. This column should be null if no via domain exists. 1753 */ 1754 public static final String VIA_DOMAIN = "viaDomain"; 1755 /** 1756 * This boolean column indicates whether the message is an outgoing message in the process 1757 * of being sent (will be zero for incoming messages and messages that are already sent). 1758 */ 1759 public static final String IS_SENDING = "isSending"; 1760 1761 private MessageColumns() {} 1762 } 1763 1764 public static final class SetCurrentAccountColumns { 1765 /** 1766 * This column contains the Account object Parcelable. 1767 */ 1768 public static final String ACCOUNT = "account"; 1769 1770 private SetCurrentAccountColumns() {} 1771 } 1772 1773 /** 1774 * List of operations that can can be performed on a message. These operations are applied 1775 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} 1776 * where the message uri is specified, and the ContentValues specifies the operation to 1777 * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT) 1778 * <p/> 1779 * Note not all UI providers will support these operations. 1780 */ 1781 public static final class MessageOperations { 1782 /** 1783 * Respond to a calendar invitation 1784 */ 1785 public static final String RESPOND_COLUMN = "respond"; 1786 1787 public static final int RESPOND_ACCEPT = 1; 1788 public static final int RESPOND_TENTATIVE = 2; 1789 public static final int RESPOND_DECLINE = 3; 1790 1791 private MessageOperations() { 1792 } 1793 } 1794 1795 public static final String ATTACHMENT_LIST_TYPE = 1796 "vnd.android.cursor.dir/vnd.com.android.mail.attachment"; 1797 public static final String ATTACHMENT_TYPE = 1798 "vnd.android.cursor.item/vnd.com.android.mail.attachment"; 1799 1800 public static final String[] ATTACHMENT_PROJECTION = { 1801 AttachmentColumns.NAME, 1802 AttachmentColumns.SIZE, 1803 AttachmentColumns.URI, 1804 AttachmentColumns.CONTENT_TYPE, 1805 AttachmentColumns.STATE, 1806 AttachmentColumns.DESTINATION, 1807 AttachmentColumns.DOWNLOADED_SIZE, 1808 AttachmentColumns.CONTENT_URI, 1809 AttachmentColumns.THUMBNAIL_URI, 1810 AttachmentColumns.PREVIEW_INTENT_URI, 1811 AttachmentColumns.PROVIDER_DATA, 1812 AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, 1813 AttachmentColumns.TYPE 1814 }; 1815 public static final int ATTACHMENT_NAME_COLUMN = 0; 1816 public static final int ATTACHMENT_SIZE_COLUMN = 1; 1817 public static final int ATTACHMENT_URI_COLUMN = 2; 1818 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3; 1819 public static final int ATTACHMENT_STATE_COLUMN = 4; 1820 public static final int ATTACHMENT_DESTINATION_COLUMN = 5; 1821 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6; 1822 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7; 1823 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8; 1824 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9; 1825 public static final int ATTACHMENT_SUPPORTS_DOWNLOAD_AGAIN_COLUMN = 10; 1826 public static final int ATTACHMENT_TYPE_COLUMN = 11; 1827 1828 /** Separates attachment info parts in strings in the database. */ 1829 public static final String ATTACHMENT_INFO_SEPARATOR = "\n"; // use to join 1830 public static final Pattern ATTACHMENT_INFO_SEPARATOR_PATTERN = 1831 Pattern.compile(ATTACHMENT_INFO_SEPARATOR); // use to split 1832 public static final String ATTACHMENT_INFO_DELIMITER = "|"; // use to join 1833 // use to split 1834 public static final Pattern ATTACHMENT_INFO_DELIMITER_PATTERN = Pattern.compile("\\|"); 1835 1836 /** 1837 * Valid states for the {@link AttachmentColumns#STATE} column. 1838 * 1839 */ 1840 public static final class AttachmentState { 1841 /** 1842 * The full attachment is not present on device. When used as a command, 1843 * setting this state will tell the provider to cancel a download in 1844 * progress. 1845 * <p> 1846 * Valid next states: {@link #DOWNLOADING}, {@link #PAUSED} 1847 */ 1848 public static final int NOT_SAVED = 0; 1849 /** 1850 * The most recent attachment download attempt failed. The current UI 1851 * design does not require providers to persist this state, but 1852 * providers must return this state at least once after a download 1853 * failure occurs. This state may not be used as a command. 1854 * <p> 1855 * Valid next states: {@link #DOWNLOADING} 1856 */ 1857 public static final int FAILED = 1; 1858 /** 1859 * The attachment is currently being downloaded by the provider. 1860 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current 1861 * download progress while in this state. When used as a command, 1862 * setting this state will tell the provider to initiate a download to 1863 * the accompanying destination in {@link AttachmentColumns#DESTINATION} 1864 * . 1865 * <p> 1866 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED}, 1867 * {@link #SAVED} 1868 */ 1869 public static final int DOWNLOADING = 2; 1870 /** 1871 * The attachment was successfully downloaded to the destination in 1872 * {@link AttachmentColumns#DESTINATION}. If a provider later detects 1873 * that a download is missing, it should reset the state to 1874 * {@link #NOT_SAVED}. This state may not be used as a command on its 1875 * own. To move a file from cache to external, update 1876 * {@link AttachmentColumns#DESTINATION}. 1877 * <p> 1878 * Valid next states: {@link #NOT_SAVED}, {@link #PAUSED} 1879 */ 1880 public static final int SAVED = 3; 1881 /** 1882 * This is only used as a command, not as a state. The attachment is 1883 * currently being redownloaded by the provider. 1884 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current 1885 * download progress while in this state. When used as a command, 1886 * setting this state will tell the provider to initiate a download to 1887 * the accompanying destination in {@link AttachmentColumns#DESTINATION} 1888 * . 1889 */ 1890 public static final int REDOWNLOADING = 4; 1891 /** 1892 * The attachment is either pending or paused in the download manager. 1893 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current 1894 * download progress while in this state. This state may not be used as 1895 * a command on its own. 1896 * <p> 1897 * Valid next states: {@link #DOWNLOADING}, {@link #FAILED} 1898 */ 1899 public static final int PAUSED = 5; 1900 1901 private AttachmentState() {} 1902 } 1903 1904 public static final class AttachmentDestination { 1905 1906 /** 1907 * The attachment will be or is already saved to the app-private cache partition. 1908 */ 1909 public static final int CACHE = 0; 1910 /** 1911 * The attachment will be or is already saved to external shared device storage. 1912 * This value should be 1 since saveToSd is often used in a similar way 1913 */ 1914 public static final int EXTERNAL = 1; 1915 1916 private AttachmentDestination() {} 1917 } 1918 1919 public static final class AttachmentColumns { 1920 /** 1921 * This string column is the attachment's file name, intended for display in UI. It is not 1922 * the full path of the file. 1923 */ 1924 public static final String NAME = OpenableColumns.DISPLAY_NAME; 1925 /** 1926 * This integer column is the file size of the attachment, in bytes. 1927 */ 1928 public static final String SIZE = OpenableColumns.SIZE; 1929 /** 1930 * This column is a {@link android.net.Uri} that can be queried to 1931 * monitor download state and progress for this individual attachment 1932 * (resulting cursor has one single row for this attachment). 1933 */ 1934 public static final String URI = "uri"; 1935 /** 1936 * This string column is the MIME type of the attachment. 1937 */ 1938 public static final String CONTENT_TYPE = "contentType"; 1939 /** 1940 * This integer column is the current downloading state of the 1941 * attachment as defined in {@link AttachmentState}. 1942 * <p> 1943 * Providers must accept updates to {@link #URI} with new values of 1944 * this column to initiate or cancel downloads. 1945 */ 1946 public static final String STATE = "state"; 1947 /** 1948 * This integer column is the file destination for the current download 1949 * in progress (when {@link #STATE} is 1950 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file 1951 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined 1952 * in {@link AttachmentDestination}. This value is undefined in any 1953 * other state. 1954 * <p> 1955 * Providers must accept updates to {@link #URI} with new values of 1956 * this column to move an existing downloaded file. 1957 */ 1958 public static final String DESTINATION = "destination"; 1959 /** 1960 * This integer column is the current number of bytes downloaded when 1961 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is 1962 * undefined in any other state. 1963 */ 1964 public static final String DOWNLOADED_SIZE = "downloadedSize"; 1965 /** 1966 * This column is a {@link android.net.Uri} that points to the 1967 * downloaded local file when {@link #STATE} is 1968 * {@link AttachmentState#SAVED}. This value is undefined in any other 1969 * state. 1970 */ 1971 public static final String CONTENT_URI = "contentUri"; 1972 /** 1973 * This column is a {@link android.net.Uri} that points to a local 1974 * thumbnail file for the attachment. Providers that do not support 1975 * downloading attachment thumbnails may leave this null. 1976 */ 1977 public static final String THUMBNAIL_URI = "thumbnailUri"; 1978 /** 1979 * This column is an {@link android.net.Uri} used in an 1980 * {@link android.content.Intent#ACTION_VIEW} Intent to launch a preview 1981 * activity that allows the user to efficiently view an attachment 1982 * without having to first download the entire file. Providers that do 1983 * not support previewing attachments may leave this null. 1984 */ 1985 public static final String PREVIEW_INTENT_URI = "previewIntentUri"; 1986 /** 1987 * This column contains provider-specific private data as JSON string. 1988 */ 1989 public static final String PROVIDER_DATA = "providerData"; 1990 1991 /** 1992 * This column represents whether this attachment supports the ability to be downloaded 1993 * again. 1994 */ 1995 public static final String SUPPORTS_DOWNLOAD_AGAIN = "supportsDownloadAgain"; 1996 /** 1997 * This column represents the visibility type of this attachment. One of the 1998 * {@link AttachmentType} constants. 1999 */ 2000 public static final String TYPE = "type"; 2001 2002 private AttachmentColumns() {} 2003 } 2004 2005 public static final class AttachmentContentValueKeys { 2006 public static final String RENDITION = "rendition"; 2007 public static final String ADDITIONAL_PRIORITY = "additionalPriority"; 2008 public static final String DELAY_DOWNLOAD = "delayDownload"; 2009 } 2010 2011 /** 2012 * Indicates a version of an attachment. 2013 */ 2014 public static final class AttachmentRendition { 2015 2016 /** A smaller or simpler version of the attachment, such as a scaled-down image or an HTML 2017 * version of a document. Not always available. 2018 */ 2019 public static final int SIMPLE = 0; 2020 /** 2021 * The full version of an attachment if it can be handled on the device, otherwise the 2022 * preview. 2023 */ 2024 public static final int BEST = 1; 2025 2026 private static final String SIMPLE_STRING = "SIMPLE"; 2027 private static final String BEST_STRING = "BEST"; 2028 2029 /** 2030 * Prefer renditions in this order. 2031 */ 2032 public static final int[] PREFERRED_RENDITIONS = new int[]{BEST, SIMPLE}; 2033 2034 public static int parseRendition(String rendition) { 2035 if (TextUtils.equals(rendition, SIMPLE_STRING)) { 2036 return SIMPLE; 2037 } else if (TextUtils.equals(rendition, BEST_STRING)) { 2038 return BEST; 2039 } 2040 2041 throw new IllegalArgumentException(String.format("Unknown rendition %s", rendition)); 2042 } 2043 2044 public static String toString(int rendition) { 2045 if (rendition == BEST) { 2046 return BEST_STRING; 2047 } else if (rendition == SIMPLE) { 2048 return SIMPLE_STRING; 2049 } 2050 2051 throw new IllegalArgumentException(String.format("Unknown rendition %d", rendition)); 2052 } 2053 } 2054 2055 /** 2056 * Indicates the visibility type of an attachment. 2057 */ 2058 public static final class AttachmentType { 2059 public static final int STANDARD = 0; 2060 public static final int INLINE_CURRENT_MESSAGE = 1; 2061 public static final int INLINE_QUOTED_MESSAGE = 2; 2062 } 2063 2064 public static final String[] UNDO_PROJECTION = { 2065 ConversationColumns.MESSAGE_LIST_URI 2066 }; 2067 public static final int UNDO_MESSAGE_LIST_COLUMN = 0; 2068 2069 // Parameter used to indicate the sequence number for an undoable operation 2070 public static final String SEQUENCE_QUERY_PARAMETER = "seq"; 2071 2072 /** 2073 * Parameter used to force UI notifications in an operation involving 2074 * {@link ConversationOperations#OPERATION_KEY}. 2075 */ 2076 public static final String FORCE_UI_NOTIFICATIONS_QUERY_PARAMETER = "forceUiNotifications"; 2077 2078 /** 2079 * Parameter used to allow returning hidden folders. 2080 */ 2081 public static final String ALLOW_HIDDEN_FOLDERS_QUERY_PARAM = "allowHiddenFolders"; 2082 2083 public static final String AUTO_ADVANCE_MODE_OLDER = "older"; 2084 public static final String AUTO_ADVANCE_MODE_NEWER = "newer"; 2085 public static final String AUTO_ADVANCE_MODE_LIST = "list"; 2086 2087 /** 2088 * Settings for auto advancing when the current conversation has been destroyed. 2089 */ 2090 public static final class AutoAdvance { 2091 /** No setting specified. */ 2092 public static final int UNSET = 0; 2093 /** Go to the older message (if available) */ 2094 public static final int OLDER = 1; 2095 /** Go to the newer message (if available) */ 2096 public static final int NEWER = 2; 2097 /** Go back to conversation list*/ 2098 public static final int LIST = 3; 2099 /** The default option is to go to the list */ 2100 public static final int DEFAULT = LIST; 2101 2102 /** 2103 * Gets the int value for the given auto advance setting. 2104 * 2105 * @param autoAdvanceSetting The string setting, such as "newer", "older", "list" 2106 */ 2107 public static int getAutoAdvanceInt(final String autoAdvanceSetting) { 2108 final int autoAdvance; 2109 2110 if (AUTO_ADVANCE_MODE_NEWER.equals(autoAdvanceSetting)) { 2111 autoAdvance = UIProvider.AutoAdvance.NEWER; 2112 } else if (AUTO_ADVANCE_MODE_OLDER.equals(autoAdvanceSetting)) { 2113 autoAdvance = UIProvider.AutoAdvance.OLDER; 2114 } else if (AUTO_ADVANCE_MODE_LIST.equals(autoAdvanceSetting)) { 2115 autoAdvance = UIProvider.AutoAdvance.LIST; 2116 } else { 2117 autoAdvance = UIProvider.AutoAdvance.UNSET; 2118 } 2119 2120 return autoAdvance; 2121 } 2122 } 2123 2124 /** 2125 * Settings for what swipe should do. 2126 */ 2127 public static final class Swipe { 2128 /** Archive or remove label, if available. */ 2129 public static final int ARCHIVE = 0; 2130 /** Delete */ 2131 public static final int DELETE = 1; 2132 /** No swipe */ 2133 public static final int DISABLED = 2; 2134 /** Default is delete */ 2135 public static final int DEFAULT = ARCHIVE; 2136 } 2137 2138 /** 2139 * Settings for Conversation view mode. 2140 */ 2141 public static final class ConversationViewMode { 2142 /** 2143 * The user hasn't specified a mode. 2144 */ 2145 public static final int UNDEFINED = -1; 2146 /** 2147 * Default to fit the conversation to screen view 2148 */ 2149 public static final int OVERVIEW = 0; 2150 /** 2151 * Conversation text size should be the device default, and wide conversations may 2152 * require panning 2153 */ 2154 public static final int READING = 1; 2155 public static final int DEFAULT = OVERVIEW; 2156 } 2157 2158 public static final class SnapHeaderValue { 2159 public static final int ALWAYS = 0; 2160 public static final int PORTRAIT_ONLY = 1; 2161 public static final int NEVER = 2; 2162 } 2163 2164 public static final class MessageTextSize { 2165 public static final int TINY = -2; 2166 public static final int SMALL = -1; 2167 public static final int NORMAL = 0; 2168 public static final int LARGE = 1; 2169 public static final int HUGE = 2; 2170 } 2171 2172 public static final class DefaultReplyBehavior { 2173 public static final int REPLY = 0; 2174 public static final int REPLY_ALL = 1; 2175 } 2176 2177 /** 2178 * Setting for whether to show sender images in conversation list. 2179 */ 2180 public static final class ConversationListIcon { 2181 public static final int SENDER_IMAGE = 1; 2182 public static final int NONE = 2; 2183 public static final int DEFAULT = 1; // Default to show sender image 2184 } 2185 2186 /** 2187 * Action for an intent used to update/create new notifications. The mime type of this 2188 * intent should be set to the mimeType of the account that is generating this notification. 2189 * An intent of this action is required to have the following extras: 2190 * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT} 2191 */ 2192 public static final String ACTION_UPDATE_NOTIFICATION = 2193 "com.android.mail.action.update_notification"; 2194 2195 public static final class UpdateNotificationExtras { 2196 /** 2197 * Parcelable extra containing a {@link Uri} to a {@link Folder} 2198 */ 2199 public static final String EXTRA_FOLDER = "notification_extra_folder"; 2200 2201 /** 2202 * Parcelable extra containing a {@link Uri} to an {@link Account} 2203 */ 2204 public static final String EXTRA_ACCOUNT = "notification_extra_account"; 2205 2206 /** 2207 * Integer extra containing the update unread count for the account/folder. 2208 * If this value is 0, the UI will not block the intent to allow code to clear notifications 2209 * to run. 2210 */ 2211 public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count"; 2212 } 2213 2214 public static final class EditSettingsExtras { 2215 /** 2216 * Parcelable extra containing account for which the user wants to 2217 * modify settings 2218 */ 2219 public static final String EXTRA_ACCOUNT = "extra_account"; 2220 2221 /** 2222 * Parcelable extra containing folder for which the user wants to 2223 * modify settings 2224 */ 2225 public static final String EXTRA_FOLDER = "extra_folder"; 2226 2227 /** 2228 * Boolean extra which is set true if the user wants to "manage folders" 2229 */ 2230 public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders"; 2231 } 2232 2233 public static final class SendFeedbackExtras { 2234 /** 2235 * Optional boolean extras which indicates that the user is reporting a problem. 2236 */ 2237 public static final String EXTRA_REPORTING_PROBLEM = "reporting_problem"; 2238 /** 2239 * Optional Parcelable extra containing the screenshot of the screen where the user 2240 * is reporting a problem. 2241 */ 2242 public static final String EXTRA_SCREEN_SHOT = "screen_shot"; 2243 } 2244 2245 public static final class ViewProxyExtras { 2246 /** 2247 * Uri extra passed to the proxy which indicates the original Uri that was intended to be 2248 * viewed. 2249 */ 2250 public static final String EXTRA_ORIGINAL_URI = "original_uri"; 2251 /** 2252 * Parcelable extra passed to the proxy which indicates the account being viewed from. 2253 */ 2254 public static final String EXTRA_ACCOUNT = "account"; 2255 /** 2256 * String extra passed from the proxy which indicates the salt used to generate the digest. 2257 */ 2258 public static final String EXTRA_SALT = "salt"; 2259 /** 2260 * Byte[] extra passed from the proxy which indicates the digest of the salted account name. 2261 */ 2262 public static final String EXTRA_ACCOUNT_DIGEST = "digest"; 2263 } 2264} 2265