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