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