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