UIProvider.java revision ef3625472596326b910a4445307d1a8eb8c9cc3f
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.content.Intent; 24import android.net.Uri; 25import android.provider.BaseColumns; 26import android.provider.OpenableColumns; 27import android.text.TextUtils; 28 29import com.android.common.contacts.DataUsageStatUpdater; 30 31import java.util.ArrayList; 32 33public class UIProvider { 34 public static final String EMAIL_SEPARATOR = ","; 35 public static final long INVALID_CONVERSATION_ID = -1; 36 public static final long INVALID_MESSAGE_ID = -1; 37 38 /** 39 * Values for the current state of a Folder/Account; note that it's possible that more than one 40 * sync is in progress 41 */ 42 public static final class SyncStatus { 43 // No sync in progress 44 public static final int NO_SYNC = 0; 45 // A user-requested sync/refresh is in progress 46 public static final int USER_REFRESH = 1<<0; 47 // A user-requested query is in progress 48 public static final int USER_QUERY = 1<<1; 49 // A user request for additional results is in progress 50 public static final int USER_MORE_RESULTS = 1<<2; 51 // A background sync is in progress 52 public static final int BACKGROUND_SYNC = 1<<3; 53 // An initial sync is needed for this Account/Folder to be used 54 public static final int INITIAL_SYNC_NEEDED = 1<<4; 55 // Manual sync is required 56 public static final int MANUAL_SYNC_REQUIRED = 1<<5; 57 58 public static boolean isSyncInProgress(int syncStatus) { 59 return 0 != (syncStatus & (BACKGROUND_SYNC | 60 USER_REFRESH | 61 USER_QUERY | 62 USER_MORE_RESULTS)); 63 } 64 } 65 66 /** 67 * Values for the result of the last attempted sync of a Folder/Account 68 */ 69 public static final class LastSyncResult { 70 // The sync completed successfully 71 public static final int SUCCESS = 0; 72 // The sync wasn't completed due to a connection error 73 public static final int CONNECTION_ERROR = 1; 74 // The sync wasn't completed due to an authentication error 75 public static final int AUTH_ERROR = 2; 76 // The sync wasn't completed due to a security error 77 public static final int SECURITY_ERROR = 3; 78 // The sync wasn't completed due to a low memory condition 79 public static final int STORAGE_ERROR = 4; 80 // The sync wasn't completed due to an internal error/exception 81 public static final int INTERNAL_ERROR = 5; 82 } 83 84 // The actual content provider should define its own authority 85 public static final String AUTHORITY = "com.android.mail.providers"; 86 87 public static final String ACCOUNT_LIST_TYPE = 88 "vnd.android.cursor.dir/vnd.com.android.mail.account"; 89 public static final String ACCOUNT_TYPE = 90 "vnd.android.cursor.item/vnd.com.android.mail.account"; 91 92 /** 93 * Query parameter key that can be used to control the behavior of list queries. The value 94 * must be a serialized {@link ListParams} object. UIProvider implementations are not 95 * required to respect this query parameter 96 */ 97 public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams"; 98 99 public static final String[] ACCOUNTS_PROJECTION = { 100 BaseColumns._ID, 101 AccountColumns.NAME, 102 AccountColumns.PROVIDER_VERSION, 103 AccountColumns.URI, 104 AccountColumns.CAPABILITIES, 105 AccountColumns.FOLDER_LIST_URI, 106 AccountColumns.FULL_FOLDER_LIST_URI, 107 AccountColumns.SEARCH_URI, 108 AccountColumns.ACCOUNT_FROM_ADDRESSES, 109 AccountColumns.SAVE_DRAFT_URI, 110 AccountColumns.SEND_MAIL_URI, 111 AccountColumns.EXPUNGE_MESSAGE_URI, 112 AccountColumns.UNDO_URI, 113 AccountColumns.SETTINGS_INTENT_URI, 114 AccountColumns.SYNC_STATUS, 115 AccountColumns.HELP_INTENT_URI, 116 AccountColumns.SEND_FEEDBACK_INTENT_URI, 117 AccountColumns.REAUTHENTICATION_INTENT_URI, 118 AccountColumns.COMPOSE_URI, 119 AccountColumns.MIME_TYPE, 120 AccountColumns.RECENT_FOLDER_LIST_URI, 121 AccountColumns.COLOR, 122 AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI, 123 AccountColumns.MANUAL_SYNC_URI, 124 AccountColumns.SettingsColumns.SIGNATURE, 125 AccountColumns.SettingsColumns.AUTO_ADVANCE, 126 AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE, 127 AccountColumns.SettingsColumns.SNAP_HEADERS, 128 AccountColumns.SettingsColumns.REPLY_BEHAVIOR, 129 AccountColumns.SettingsColumns.HIDE_CHECKBOXES, 130 AccountColumns.SettingsColumns.CONFIRM_DELETE, 131 AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, 132 AccountColumns.SettingsColumns.CONFIRM_SEND, 133 AccountColumns.SettingsColumns.DEFAULT_INBOX, 134 AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, 135 AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT, 136 AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE, 137 AccountColumns.SettingsColumns.SWIPE, 138 AccountColumns.SettingsColumns.PRIORITY_ARROWS_ENABLED 139 }; 140 141 public static final int ACCOUNT_ID_COLUMN = 0; 142 public static final int ACCOUNT_NAME_COLUMN = 1; 143 public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2; 144 public static final int ACCOUNT_URI_COLUMN = 3; 145 public static final int ACCOUNT_CAPABILITIES_COLUMN = 4; 146 public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5; 147 public static final int ACCOUNT_FULL_FOLDER_LIST_URI_COLUMN = 6; 148 public static final int ACCOUNT_SEARCH_URI_COLUMN = 7; 149 public static final int ACCOUNT_FROM_ADDRESSES_COLUMN = 8; 150 public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 9; 151 public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 10; 152 public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 11; 153 public static final int ACCOUNT_UNDO_URI_COLUMN = 12; 154 public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 13; 155 public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14; 156 public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15; 157 public static final int ACCOUNT_SEND_FEEDBACK_INTENT_URI_COLUMN = 16; 158 public static final int ACCOUNT_REAUTHENTICATION_INTENT_URI_COLUMN = 17; 159 public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 18; 160 public static final int ACCOUNT_MIME_TYPE_COLUMN = 19; 161 public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 20; 162 public static final int ACCOUNT_COLOR_COLUMN = 21; 163 public static final int ACCOUNT_DEFAULT_RECENT_FOLDER_LIST_URI_COLUMN = 22; 164 public static final int ACCOUNT_MANUAL_SYNC_URI_COLUMN = 23; 165 166 public static final int ACCOUNT_SETTINGS_SIGNATURE_COLUMN = 24; 167 public static final int ACCOUNT_SETTINGS_AUTO_ADVANCE_COLUMN = 25; 168 public static final int ACCOUNT_SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 26; 169 public static final int ACCOUNT_SETTINGS_SNAP_HEADERS_COLUMN = 27; 170 public static final int ACCOUNT_SETTINGS_REPLY_BEHAVIOR_COLUMN = 28; 171 public static final int ACCOUNT_SETTINGS_HIDE_CHECKBOXES_COLUMN = 29; 172 public static final int ACCOUNT_SETTINGS_CONFIRM_DELETE_COLUMN = 30; 173 public static final int ACCOUNT_SETTINGS_CONFIRM_ARCHIVE_COLUMN = 31; 174 public static final int ACCOUNT_SETTINGS_CONFIRM_SEND_COLUMN = 32; 175 public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_COLUMN = 33; 176 public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_NAME_COLUMN = 34; 177 public static final int ACCOUNT_SETTINGS_FORCE_REPLY_FROM_DEFAULT_COLUMN = 35; 178 public static final int ACCOUNT_SETTINGS_MAX_ATTACHMENT_SIZE_COLUMN = 36; 179 public static final int ACCOUNT_SETTINGS_SWIPE_COLUMN = 37; 180 public static final int ACCOUNT_SETTINGS_PRIORITY_ARROWS_ENABLED_COLUMN = 38; 181 182 public static final class AccountCapabilities { 183 /** 184 * Whether folders can be synchronized back to the server. 185 */ 186 public static final int SYNCABLE_FOLDERS = 0x0001; 187 /** 188 * Whether the server allows reporting spam back. 189 */ 190 public static final int REPORT_SPAM = 0x0002; 191 /** 192 * Whether the server allows reporting phishing back. 193 */ 194 public static final int REPORT_PHISHING = 0x0004; 195 /** 196 * Whether the server supports a concept of Archive: removing mail from the Inbox but 197 * keeping it around. 198 */ 199 public static final int ARCHIVE = 0x0008; 200 /** 201 * Whether the server will stop notifying on updates to this thread? This requires 202 * THREADED_CONVERSATIONS to be true, otherwise it should be ignored. 203 */ 204 public static final int MUTE = 0x0010; 205 /** 206 * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS 207 * to be true, otherwise it should be ignored. 208 */ 209 public static final int SERVER_SEARCH = 0x0020; 210 /** 211 * Whether the server supports constraining search to a single folder. Requires 212 * SYNCABLE_FOLDERS, otherwise it should be ignored. 213 */ 214 public static final int FOLDER_SERVER_SEARCH = 0x0040; 215 /** 216 * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML). 217 */ 218 public static final int SANITIZED_HTML = 0x0080; 219 /** 220 * Whether the server allows synchronization of draft messages. This does NOT require 221 * SYNCABLE_FOLDERS to be set. 222 */ 223 public static final int DRAFT_SYNCHRONIZATION = 0x0100; 224 /** 225 * Does the server allow the user to compose mails (and reply) using addresses other than 226 * their account name? For instance, GMail allows users to set FROM addresses that are 227 * different from account@gmail.com address. For instance, user@gmail.com could have another 228 * FROM: address like user@android.com. If the user has enabled multiple FROM address, he 229 * can compose (and reply) using either address. 230 */ 231 public static final int MULTIPLE_FROM_ADDRESSES = 0x0200; 232 /** 233 * Whether the server allows the original message to be included in the reply by setting a 234 * flag on the reply. If we can avoid including the entire previous message, we save on 235 * bandwidth (replies are shorter). 236 */ 237 public static final int SMART_REPLY = 0x0400; 238 /** 239 * Does this account support searching locally, on the device? This requires the backend 240 * storage to support a mechanism for searching. 241 */ 242 public static final int LOCAL_SEARCH = 0x0800; 243 /** 244 * Whether the server supports a notion of threaded conversations: where replies to messages 245 * are tagged to keep conversations grouped. This could be full threading (each message 246 * lists its parent) or conversation-level threading (each message lists one conversation 247 * which it belongs to) 248 */ 249 public static final int THREADED_CONVERSATIONS = 0x1000; 250 /** 251 * Whether the server supports allowing a conversation to be in multiple folders. (Or allows 252 * multiple folders on a single conversation) 253 */ 254 public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000; 255 /** 256 * Whether the provider supports undoing operations. If it doesn't, never show the undo bar. 257 */ 258 public static final int UNDO = 0x4000; 259 /** 260 * Whether the account provides help content. 261 */ 262 public static final int HELP_CONTENT = 0x8000; 263 /** 264 * Whether the account provides a way to send feedback content. 265 */ 266 public static final int SEND_FEEDBACK = 0x10000; 267 /** 268 * Whether the account provides a mechanism for marking conversations as important. 269 */ 270 public static final int MARK_IMPORTANT = 0x20000; 271 /** 272 * Whether initial conversation queries should use a limit parameter 273 */ 274 public static final int INITIAL_CONVERSATION_LIMIT = 0x40000; 275 /** 276 * Whether the account cannot be used for sending 277 */ 278 public static final int SENDING_UNAVAILABLE = 0x80000; 279 /** 280 * Whether the account supports discarding drafts from a conversation. This should be 281 * removed when all providers support this capability 282 */ 283 public static final int DISCARD_CONVERSATION_DRAFTS = 0x100000; 284 } 285 286 public static final class AccountColumns { 287 /** 288 * This string column contains the human visible name for the account. 289 */ 290 public static final String NAME = "name"; 291 292 /** 293 * This integer contains the type of the account: Google versus non google. This is not 294 * returned by the UIProvider, rather this is a notion in the system. 295 */ 296 public static final String TYPE = "type"; 297 298 /** 299 * This integer column returns the version of the UI provider schema from which this 300 * account provider will return results. 301 */ 302 public static final String PROVIDER_VERSION = "providerVersion"; 303 304 /** 305 * This string column contains the uri to directly access the information for this account. 306 */ 307 public static final String URI = "accountUri"; 308 309 /** 310 * This integer column contains a bit field of the possible capabilities that this account 311 * supports. 312 */ 313 public static final String CAPABILITIES = "capabilities"; 314 315 /** 316 * This string column contains the content provider uri to return the 317 * list of top level folders for this account. 318 */ 319 public static final String FOLDER_LIST_URI = "folderListUri"; 320 321 /** 322 * This string column contains the content provider uri to return the 323 * list of all folders for this account. 324 */ 325 public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri"; 326 327 /** 328 * This string column contains the content provider uri that can be queried for search 329 * results. 330 * The supported query parameters are limited to those listed 331 * in {@link SearchQueryParameters} 332 * The cursor returned from this query is expected have one row, where the columnm are a 333 * subset of the columns specified in {@link FolderColumns} 334 */ 335 public static final String SEARCH_URI = "searchUri"; 336 337 /** 338 * This string column contains a json array of json objects representing 339 * custom from addresses for this account or null if there are none. 340 */ 341 public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses"; 342 343 /** 344 * This string column contains the content provider uri that can be used to save (insert) 345 * new draft messages for this account. NOTE: This might be better to 346 * be an update operation on the messageUri. 347 */ 348 public static final String SAVE_DRAFT_URI = "saveDraftUri"; 349 350 /** 351 * This string column contains the content provider uri that can be used to send 352 * a message for this account. 353 * NOTE: This might be better to be an update operation on the messageUri. 354 */ 355 public static final String SEND_MAIL_URI = "sendMailUri"; 356 357 /** 358 * This string column contains the content provider uri that can be used 359 * to expunge a message from this account. NOTE: This might be better to 360 * be an update operation on the messageUri. 361 * When {@link android.content.ContentResolver#update()} is called with this uri, the 362 * {@link ContentValues} object is expected to have {@link BaseColumns._ID} specified with 363 * the local message id of the message. 364 */ 365 public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri"; 366 367 /** 368 * This string column contains the content provider uri that can be used 369 * to undo the last committed action. 370 */ 371 public static final String UNDO_URI = "undoUri"; 372 373 /** 374 * Uri for EDIT intent that will cause the settings screens for this account type to be 375 * shown. 376 * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate 377 * which settings the user wants to edit. 378 * TODO: When we want to support a heterogeneous set of account types, this value may need 379 * to be moved to a global content provider. 380 */ 381 public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri"; 382 383 /** 384 * Uri for VIEW intent that will cause the help screens for this account type to be 385 * shown. 386 * TODO: When we want to support a heterogeneous set of account types, this value may need 387 * to be moved to a global content provider. 388 */ 389 public static String HELP_INTENT_URI = "helpIntentUri"; 390 391 /** 392 * Uri for VIEW intent that will cause the send feedback for this account type to be 393 * shown. 394 * TODO: When we want to support a heterogeneous set of account types, this value may need 395 * to be moved to a global content provider. 396 */ 397 public static String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri"; 398 399 /** 400 * Uri for VIEW intent that will cause the user to be prompted for authentication for 401 * this account. startActivityForResult() will be called with this intent. Activities that 402 * handle this intent are expected to return {@link android.app.Activity.RESULT_OK} if the 403 * user successfully authenticated. 404 */ 405 public static String REAUTHENTICATION_INTENT_URI = "reauthenticationUri"; 406 407 /** 408 * This int column contains the current sync status of the account (the logical AND of the 409 * sync status of folders in this account) 410 */ 411 public static final String SYNC_STATUS = "syncStatus"; 412 /** 413 * Uri for VIEW intent that will cause the compose screens for this type 414 * of account to be shown. 415 */ 416 public static final String COMPOSE_URI = "composeUri"; 417 /** 418 * Mime-type defining this account. 419 */ 420 public static final String MIME_TYPE = "mimeType"; 421 /** 422 * URI for location of recent folders viewed on this account. 423 */ 424 public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri"; 425 /** 426 * URI for default recent folders for this account, if any. 427 */ 428 public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri"; 429 /** 430 * Color used for this account (for Email/Combined view) 431 */ 432 public static final String COLOR = "color"; 433 /** 434 * URI for forcing a manual sync of this account. 435 */ 436 public static final String MANUAL_SYNC_URI = "manualSyncUri"; 437 438 public static final class SettingsColumns { 439 /** 440 * String column containing the contents of the signature for this account. If no 441 * signature has been specified, the value will be null. 442 */ 443 public static final String SIGNATURE = "signature"; 444 445 /** 446 * Integer column containing the user's specified auto-advance policy. This value will 447 * be one of the values in {@link UIProvider.AutoAdvance} 448 */ 449 public static final String AUTO_ADVANCE = "auto_advance"; 450 451 /** 452 * Integer column containing the user's specified message text size preference. This 453 * value will be one of the values in {@link UIProvider.MessageTextSize} 454 */ 455 public static final String MESSAGE_TEXT_SIZE = "message_text_size"; 456 457 /** 458 * Integer column contaning the user's specified snap header preference. This value 459 * will be one of the values in {@link UIProvider.SnapHeaderValue} 460 */ 461 public static final String SNAP_HEADERS = "snap_headers"; 462 463 /** 464 * Integer column containing the user's specified default reply behavior. This value 465 * will be one of the values in {@link UIProvider.DefaultReplyBehavior} 466 */ 467 public static final String REPLY_BEHAVIOR = "reply_behavior"; 468 469 /** 470 * Integer column containing the user's specified checkbox preference. A 471 * non zero value means to hide checkboxes. 472 */ 473 public static final String HIDE_CHECKBOXES = "hide_checkboxes"; 474 475 /** 476 * Integer column containing the user's specified confirm delete preference value. 477 * A non zero value indicates that the user has indicated that a confirmation should 478 * be shown when a delete action is performed. 479 */ 480 public static final String CONFIRM_DELETE = "confirm_delete"; 481 482 /** 483 * Integer column containing the user's specified confirm archive preference value. 484 * A non zero value indicates that the user has indicated that a confirmation should 485 * be shown when an archive action is performed. 486 */ 487 public static final String CONFIRM_ARCHIVE = "confirm_archive"; 488 489 /** 490 * Integer column containing the user's specified confirm send preference value. 491 * A non zero value indicates that the user has indicated that a confirmation should 492 * be shown when a send action is performed. 493 */ 494 public static final String CONFIRM_SEND = "confirm_send"; 495 /** 496 * String containing the URI for the default inbox for this account. 497 */ 498 public static final String DEFAULT_INBOX = "default_inbox"; 499 /** 500 * String containing the name of the default Inbox for this account 501 */ 502 public static final String DEFAULT_INBOX_NAME = "default_inbox_name"; 503 /** 504 * Integer column containing a non zero value if replies should always be sent from 505 * a default address instead of a recipient. 506 */ 507 public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default"; 508 /** 509 * Integer column containing the max attachment size in kb. 510 */ 511 public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size"; 512 /** 513 * Integer column containing a value matching one of the constants from {@link Swipe} 514 */ 515 public static final String SWIPE = "swipe"; 516 /** 517 * Boolean column containing whether priority inbox arrows are enabled. 518 */ 519 public static final String PRIORITY_ARROWS_ENABLED = "priority_inbox_arrows_enabled"; 520 } 521 } 522 523 public static final class SearchQueryParameters { 524 /** 525 * Parameter used to specify the search query. 526 */ 527 public static final String QUERY = "query"; 528 529 /** 530 * If specified, the query results will be limited to this folder. 531 */ 532 public static final String FOLDER = "folder"; 533 534 private SearchQueryParameters() {} 535 } 536 537 public static final class ConversationListQueryParameters { 538 public static final String DEFAULT_LIMIT = "50"; 539 /** 540 * Parameter used to limit the number of rows returned by a conversation list query 541 */ 542 public static final String LIMIT = "limit"; 543 544 /** 545 * Parameter used to control whether the this query a remote server. 546 */ 547 public static final String USE_NETWORK = "use_network"; 548 549 /** 550 * Parameter used to allow the caller to indicate desire to receive all notifications. 551 * (Including ones for user initiated actions) 552 */ 553 public static final String ALL_NOTIFICATIONS = "all_notifications"; 554 555 private ConversationListQueryParameters() {} 556 } 557 558 // We define a "folder" as anything that contains a list of conversations. 559 public static final String FOLDER_LIST_TYPE = 560 "vnd.android.cursor.dir/vnd.com.android.mail.folder"; 561 public static final String FOLDER_TYPE = 562 "vnd.android.cursor.item/vnd.com.android.mail.folder"; 563 564 public static final String[] FOLDERS_PROJECTION = { 565 BaseColumns._ID, 566 FolderColumns.URI, 567 FolderColumns.NAME, 568 FolderColumns.HAS_CHILDREN, 569 FolderColumns.CAPABILITIES, 570 FolderColumns.SYNC_WINDOW, 571 FolderColumns.CONVERSATION_LIST_URI, 572 FolderColumns.CHILD_FOLDERS_LIST_URI, 573 FolderColumns.UNREAD_COUNT, 574 FolderColumns.TOTAL_COUNT, 575 FolderColumns.REFRESH_URI, 576 FolderColumns.SYNC_STATUS, 577 FolderColumns.LAST_SYNC_RESULT, 578 FolderColumns.TYPE, 579 FolderColumns.ICON_RES_ID, 580 FolderColumns.BG_COLOR, 581 FolderColumns.FG_COLOR, 582 FolderColumns.LOAD_MORE_URI, 583 FolderColumns.HIERARCHICAL_DESC 584 }; 585 586 public static final int FOLDER_ID_COLUMN = 0; 587 public static final int FOLDER_URI_COLUMN = 1; 588 public static final int FOLDER_NAME_COLUMN = 2; 589 public static final int FOLDER_HAS_CHILDREN_COLUMN = 3; 590 public static final int FOLDER_CAPABILITIES_COLUMN = 4; 591 public static final int FOLDER_SYNC_WINDOW_COLUMN = 5; 592 public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6; 593 public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7; 594 public static final int FOLDER_UNREAD_COUNT_COLUMN = 8; 595 public static final int FOLDER_TOTAL_COUNT_COLUMN = 9; 596 public static final int FOLDER_REFRESH_URI_COLUMN = 10; 597 public static final int FOLDER_SYNC_STATUS_COLUMN = 11; 598 public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12; 599 public static final int FOLDER_TYPE_COLUMN = 13; 600 public static final int FOLDER_ICON_RES_ID_COLUMN = 14; 601 public static final int FOLDER_BG_COLOR_COLUMN = 15; 602 public static final int FOLDER_FG_COLOR_COLUMN = 16; 603 public static final int FOLDER_LOAD_MORE_URI_COLUMN = 17; 604 public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 18; 605 606 public static final class FolderType { 607 public static final int DEFAULT = 0; 608 public static final int INBOX = 1; 609 public static final int DRAFT = 2; 610 public static final int OUTBOX = 3; 611 public static final int SENT = 4; 612 public static final int TRASH = 5; 613 public static final int SPAM = 6; 614 public static final int STARRED = 7; 615 public static final int OTHER_PROVIDER_FOLDER = 8; 616 } 617 618 public static final class FolderCapabilities { 619 public static final int SYNCABLE = 0x0001; 620 public static final int PARENT = 0x0002; 621 public static final int CAN_HOLD_MAIL = 0x0004; 622 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008; 623 /** 624 * For accounts that support archive, this will indicate that this folder supports 625 * the archive functionality. 626 */ 627 public static final int ARCHIVE = 0x0010; 628 629 /** 630 * This will indicated that this folder supports the delete functionality. 631 */ 632 public static final int DELETE = 0x0020; 633 634 /** 635 * For accounts that support report spam, this will indicate that this folder supports 636 * the report spam functionality. 637 */ 638 public static final int REPORT_SPAM = 0x0040; 639 640 /** 641 * For accounts that support report spam, this will indicate that this folder supports 642 * the mark not spam functionality. 643 */ 644 public static final int MARK_NOT_SPAM = 0x0080; 645 646 /** 647 * For accounts that support mute, this will indicate if a mute is performed from within 648 * this folder, the action is destructive. 649 */ 650 public static final int DESTRUCTIVE_MUTE = 0x0100; 651 652 /** 653 * Indicates that a folder supports settings (sync lookback, etc.) 654 */ 655 public static final int SUPPORTS_SETTINGS = 0x0200; 656 /** 657 * All the messages in this folder are important. 658 */ 659 public static final int ONLY_IMPORTANT = 0x0400; 660 /** 661 * Deletions in this folder can't be undone (could include archive if desirable) 662 */ 663 public static final int DELETE_ACTION_FINAL = 0x0800; 664 /** 665 * This folder is virtual, i.e. contains conversations potentially pulled from other 666 * folders, potentially even from different accounts. Examples might be a "starred" 667 * folder, or an "unread" folder (per account or provider-wide) 668 */ 669 public static final int IS_VIRTUAL = 0x1000; 670 671 /** 672 * For accounts that support report phishing, this will indicate that this folder supports 673 * the report phishing functionality. 674 */ 675 public static final int REPORT_PHISHING = 0x2000; 676 } 677 678 public static final class FolderColumns { 679 /** 680 * This string column contains the uri of the folder. 681 */ 682 public static final String URI = "folderUri"; 683 /** 684 * This string column contains the human visible name for the folder. 685 */ 686 public static final String NAME = "name"; 687 /** 688 * This int column represents the capabilities of the folder specified by 689 * FolderCapabilities flags. 690 */ 691 public static String CAPABILITIES = "capabilities"; 692 /** 693 * This int column represents whether or not this folder has any 694 * child folders. 695 */ 696 public static String HAS_CHILDREN = "hasChildren"; 697 /** 698 * This int column represents how large the sync window is. 699 */ 700 public static String SYNC_WINDOW = "syncWindow"; 701 /** 702 * This string column contains the content provider uri to return the 703 * list of conversations for this folder. 704 */ 705 public static final String CONVERSATION_LIST_URI = "conversationListUri"; 706 /** 707 * This string column contains the content provider uri to return the 708 * list of child folders of this folder. 709 */ 710 public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri"; 711 712 public static final String UNREAD_COUNT = "unreadCount"; 713 714 public static final String TOTAL_COUNT = "totalCount"; 715 /** 716 * This string column contains the content provider uri to force a 717 * refresh of this folder. 718 */ 719 public static final String REFRESH_URI = "refreshUri"; 720 /** 721 * This int column contains current sync status of the folder; some combination of the 722 * SyncStatus bits defined above 723 */ 724 public static final String SYNC_STATUS = "syncStatus"; 725 /** 726 * This int column contains the sync status of the last sync attempt; one of the 727 * LastSyncStatus values defined above 728 */ 729 public static final String LAST_SYNC_RESULT = "lastSyncResult"; 730 /** 731 * This long column contains the icon res id for this folder, or 0 if there is none. 732 */ 733 public static final String ICON_RES_ID = "iconResId"; 734 /** 735 * This int column contains the type of the folder. Zero is default. 736 */ 737 public static final String TYPE = "type"; 738 /** 739 * String representing the integer background color associated with this 740 * folder, or null. 741 */ 742 public static final String BG_COLOR = "bgColor"; 743 /** 744 * String representing the integer of the foreground color associated 745 * with this folder, or null. 746 */ 747 public static final String FG_COLOR = "fgColor"; 748 /** 749 * String with the content provider Uri used to request more items in the folder, or null. 750 */ 751 public static final String LOAD_MORE_URI = "loadMoreUri"; 752 753 /** 754 * Possibly empty string that describes the full hierarchy of a folder 755 * along with its name. 756 */ 757 public static final String HIERARCHICAL_DESC = "hierarchicalDesc"; 758 759 public FolderColumns() {} 760 } 761 762 // We define a "folder" as anything that contains a list of conversations. 763 public static final String CONVERSATION_LIST_TYPE = 764 "vnd.android.cursor.dir/vnd.com.android.mail.conversation"; 765 public static final String CONVERSATION_TYPE = 766 "vnd.android.cursor.item/vnd.com.android.mail.conversation"; 767 768 769 public static final String[] CONVERSATION_PROJECTION = { 770 BaseColumns._ID, 771 ConversationColumns.URI, 772 ConversationColumns.MESSAGE_LIST_URI, 773 ConversationColumns.SUBJECT, 774 ConversationColumns.SNIPPET, 775 ConversationColumns.CONVERSATION_INFO, 776 ConversationColumns.DATE_RECEIVED_MS, 777 ConversationColumns.HAS_ATTACHMENTS, 778 ConversationColumns.NUM_MESSAGES, 779 ConversationColumns.NUM_DRAFTS, 780 ConversationColumns.SENDING_STATE, 781 ConversationColumns.PRIORITY, 782 ConversationColumns.READ, 783 ConversationColumns.STARRED, 784 ConversationColumns.RAW_FOLDERS, 785 ConversationColumns.FLAGS, 786 ConversationColumns.PERSONAL_LEVEL, 787 ConversationColumns.SPAM, 788 ConversationColumns.PHISHING, 789 ConversationColumns.MUTED, 790 ConversationColumns.COLOR, 791 ConversationColumns.ACCOUNT_URI, 792 ConversationColumns.SENDER_INFO, 793 ConversationColumns.CONVERSATION_BASE_URI, 794 ConversationColumns.CONVERSATION_COOKIE, 795 ConversationColumns.REMOTE 796 }; 797 798 // These column indexes only work when the caller uses the 799 // default CONVERSATION_PROJECTION defined above. 800 public static final int CONVERSATION_ID_COLUMN = 0; 801 public static final int CONVERSATION_URI_COLUMN = 1; 802 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2; 803 public static final int CONVERSATION_SUBJECT_COLUMN = 3; 804 public static final int CONVERSATION_SNIPPET_COLUMN = 4; 805 public static final int CONVERSATION_INFO_COLUMN = 5; 806 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6; 807 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7; 808 public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8; 809 public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9; 810 public static final int CONVERSATION_SENDING_STATE_COLUMN = 10; 811 public static final int CONVERSATION_PRIORITY_COLUMN = 11; 812 public static final int CONVERSATION_READ_COLUMN = 12; 813 public static final int CONVERSATION_STARRED_COLUMN = 13; 814 public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 14; 815 public static final int CONVERSATION_FLAGS_COLUMN = 15; 816 public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 16; 817 public static final int CONVERSATION_IS_SPAM_COLUMN = 17; 818 public static final int CONVERSATION_IS_PHISHING_COLUMN = 18; 819 public static final int CONVERSATION_MUTED_COLUMN = 19; 820 public static final int CONVERSATION_COLOR_COLUMN = 20; 821 public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 21; 822 public static final int CONVERSATION_SENDER_INFO_COLUMN = 22; 823 public static final int CONVERSATION_BASE_URI_COLUMN = 23; 824 public static final int CONVERSATION_COOKIE_COLUMN = 24; 825 public static final int CONVERSATION_REMOTE_COLUMN = 25; 826 827 public static final class ConversationSendingState { 828 public static final int OTHER = 0; 829 public static final int QUEUED = 1; 830 public static final int SENDING = 2; 831 public static final int SENT = 3; 832 public static final int SEND_ERROR = -1; 833 } 834 835 public static final class ConversationPriority { 836 public static final int DEFAULT = 0; 837 public static final int IMPORTANT = 1; 838 public static final int LOW = 0; 839 public static final int HIGH = 1; 840 } 841 842 public static final class ConversationPersonalLevel { 843 public static final int NOT_TO_ME = 0; 844 public static final int TO_ME_AND_OTHERS = 1; 845 public static final int ONLY_TO_ME = 2; 846 } 847 848 public static final class ConversationFlags { 849 public static final int REPLIED = 1<<2; 850 public static final int FORWARDED = 1<<3; 851 public static final int CALENDAR_INVITE = 1<<4; 852 } 853 854 public static final class ConversationPhishing { 855 public static final int NOT_PHISHING = 0; 856 public static final int PHISHING = 1; 857 } 858 859 /** 860 * Names of columns representing fields in a Conversation. 861 */ 862 public static final class ConversationColumns { 863 public static final String URI = "conversationUri"; 864 /** 865 * This string column contains the content provider uri to return the 866 * list of messages for this conversation. 867 * The cursor returned by this query can return a {@link android.os.Bundle} 868 * from a call to {@link android.database.Cursor#getExtras()}. This Bundle may have 869 * values with keys listed in {@link CursorExtraKeys} 870 */ 871 public static final String MESSAGE_LIST_URI = "messageListUri"; 872 /** 873 * This string column contains the subject string for a conversation. 874 */ 875 public static final String SUBJECT = "subject"; 876 /** 877 * This string column contains the snippet string for a conversation. 878 */ 879 public static final String SNIPPET = "snippet"; 880 /** 881 * @deprecated 882 */ 883 public static final String SENDER_INFO = "senderInfo"; 884 /** 885 * This string column contains the string representation of the 886 * ConversationInfo JSON object for a conversation. 887 */ 888 public static final String CONVERSATION_INFO = "conversationInfo"; 889 /** 890 * This long column contains the time in ms of the latest update to a 891 * conversation. 892 */ 893 public static final String DATE_RECEIVED_MS = "dateReceivedMs"; 894 895 /** 896 * This boolean column contains whether any messages in this conversation 897 * have attachments. 898 */ 899 public static final String HAS_ATTACHMENTS = "hasAttachments"; 900 901 /** 902 * This int column contains the number of messages in this conversation. 903 * For unthreaded, this will always be 1. 904 */ 905 public static String NUM_MESSAGES = "numMessages"; 906 907 /** 908 * This int column contains the number of drafts associated with this 909 * conversation. 910 */ 911 public static String NUM_DRAFTS = "numDrafts"; 912 913 /** 914 * This int column contains the state of drafts and replies associated 915 * with this conversation. Use ConversationSendingState to interpret 916 * this field. 917 */ 918 public static String SENDING_STATE = "sendingState"; 919 920 /** 921 * This int column contains the priority of this conversation. Use 922 * ConversationPriority to interpret this field. 923 */ 924 public static String PRIORITY = "priority"; 925 926 /** 927 * This int column indicates whether the conversation has been read 928 */ 929 public static String READ = "read"; 930 /** 931 * This int column indicates whether the conversation has been starred 932 */ 933 public static String STARRED = "starred"; 934 935 /** 936 * This string column contains a serialized list of all folders 937 * separated by a Folder.FOLDER_SEPARATOR that are associated with this 938 * conversation. The folders should be only those that the provider 939 * wants to have displayed, so rawFolders will ALWAYS intentionally 940 * exclude the folder currently being viewed. Ideally, only ever use 941 * this for rendering the folder list for a conversation. 942 */ 943 public static final String RAW_FOLDERS = "rawFolders"; 944 public static final String FLAGS = "conversationFlags"; 945 /** 946 * This int column indicates the personal level of a conversation per 947 * {@link ConversationPersonalLevel}. 948 */ 949 public static final String PERSONAL_LEVEL = "personalLevel"; 950 951 /** 952 * This int column indicates whether the conversation is marked spam. 953 */ 954 public static final String SPAM = "spam"; 955 956 /** 957 * This int column indicates whether the conversation is marked phishing. 958 */ 959 public static final String PHISHING = "phishing"; 960 961 /** 962 * This int column indicates whether the conversation was muted. 963 */ 964 public static final String MUTED = "muted"; 965 966 /** 967 * This int column contains a color for the conversation (used in Email only) 968 */ 969 public static final String COLOR = "color"; 970 971 /** 972 * This String column contains the Uri for this conversation's account 973 */ 974 public static final String ACCOUNT_URI = "accountUri"; 975 /** 976 * This int column indicates whether a conversation is remote (non-local), and would require 977 * a network fetch to load. 978 */ 979 public static final String REMOTE = "remote"; 980 /** 981 * This int column indicates whether the conversation was displayed on the UI and the 982 * user got a chance to read it. The UI does not read this value, it is meant only to 983 * write the status back to the provider. As a result, it is not available in the 984 * {@link Conversation} object. 985 */ 986 public static final String VIEWED = "viewed"; 987 /** 988 * This String column contains the base uri for this conversation. This uri can be used 989 * when handling relative urls in the message content 990 */ 991 public static final String CONVERSATION_BASE_URI = "conversationBaseUri"; 992 /** 993 * This String column contains the cookie needed for accessing inline content. The cookie 994 * specified here will be set on the uri specified in the {@link CONVERSATION_BASE_URI} 995 * column. 996 */ 997 public static final String CONVERSATION_COOKIE = "conversationCookie"; 998 999 private ConversationColumns() { 1000 } 1001 } 1002 1003 public static final class ConversationCursorCommand { 1004 1005 public static final String COMMAND_RESPONSE_OK = "ok"; 1006 public static final String COMMAND_RESPONSE_FAILED = "failed"; 1007 1008 /** 1009 * This bundle key has a boolean value: true to allow cursor network access (whether this 1010 * is true by default is up to the provider), false to temporarily disable network access. 1011 * <p> 1012 * A provider that implements this command should include this key in its response with a 1013 * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}. 1014 */ 1015 public static final String COMMAND_KEY_ALLOW_NETWORK_ACCESS = "allowNetwork"; 1016 1017 /** 1018 * This bundle key has a boolean value: true to indicate that this cursor has been shown 1019 * to the user. 1020 */ 1021 public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility"; 1022 1023 private ConversationCursorCommand() {} 1024 } 1025 1026 /** 1027 * List of operations that can can be performed on a conversation. These operations are applied 1028 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} 1029 * where the conversation uri is specified, and the ContentValues specifies the operation to 1030 * be performed. 1031 * <p/> 1032 * The operation to be performed is specified in the ContentValues by 1033 * the {@link ConversationOperations#OPERATION_KEY} 1034 * <p/> 1035 * Note not all UI providers will support these operations. {@link AccountCapabilities} can 1036 * be used to determine which operations are supported. 1037 */ 1038 public static final class ConversationOperations { 1039 /** 1040 * ContentValues key used to specify the operation to be performed 1041 */ 1042 public static final String OPERATION_KEY = "operation"; 1043 1044 /** 1045 * Archive operation 1046 */ 1047 public static final String ARCHIVE = "archive"; 1048 1049 /** 1050 * Mute operation 1051 */ 1052 public static final String MUTE = "mute"; 1053 1054 /** 1055 * Report spam operation 1056 */ 1057 public static final String REPORT_SPAM = "report_spam"; 1058 1059 /** 1060 * Report not spam operation 1061 */ 1062 public static final String REPORT_NOT_SPAM = "report_not_spam"; 1063 1064 /** 1065 * Report phishing operation 1066 */ 1067 public static final String REPORT_PHISHING = "report_phishing"; 1068 1069 /** 1070 * Discard drafts operation 1071 */ 1072 public static final String DISCARD_DRAFTS = "discard_drafts"; 1073 1074 private ConversationOperations() { 1075 } 1076 } 1077 1078 public static final class DraftType { 1079 public static final int NOT_A_DRAFT = 0; 1080 public static final int COMPOSE = 1; 1081 public static final int REPLY = 2; 1082 public static final int REPLY_ALL = 3; 1083 public static final int FORWARD = 4; 1084 1085 private DraftType() {} 1086 } 1087 1088 /** 1089 * Class for the enum values to determine whether this 1090 * string should be displayed as a high priority warning 1091 * or a low priority warning. The current design has 1092 * high priority warnings in red while low priority warnings 1093 * are grey. 1094 */ 1095 public static final class SpamWarningLevel { 1096 public static final int NO_WARNING = 0; 1097 public static final int LOW_WARNING = 1; 1098 public static final int HIGH_WARNING = 2; 1099 1100 private SpamWarningLevel() {} 1101 } 1102 1103 /** 1104 * Class for the enum values to determine which type 1105 * of link to show in the spam warning. 1106 */ 1107 public static final class SpamWarningLinkType { 1108 public static final int NO_LINK = 0; 1109 public static final int IGNORE_WARNING = 1; 1110 public static final int REPORT_PHISHING = 2; 1111 1112 private SpamWarningLinkType() {} 1113 } 1114 1115 public static final String[] MESSAGE_PROJECTION = { 1116 BaseColumns._ID, 1117 MessageColumns.SERVER_ID, 1118 MessageColumns.URI, 1119 MessageColumns.CONVERSATION_ID, 1120 MessageColumns.SUBJECT, 1121 MessageColumns.SNIPPET, 1122 MessageColumns.FROM, 1123 MessageColumns.TO, 1124 MessageColumns.CC, 1125 MessageColumns.BCC, 1126 MessageColumns.REPLY_TO, 1127 MessageColumns.DATE_RECEIVED_MS, 1128 MessageColumns.BODY_HTML, 1129 MessageColumns.BODY_TEXT, 1130 MessageColumns.EMBEDS_EXTERNAL_RESOURCES, 1131 MessageColumns.REF_MESSAGE_ID, 1132 MessageColumns.DRAFT_TYPE, 1133 MessageColumns.APPEND_REF_MESSAGE_CONTENT, 1134 MessageColumns.HAS_ATTACHMENTS, 1135 MessageColumns.ATTACHMENT_LIST_URI, 1136 MessageColumns.MESSAGE_FLAGS, 1137 MessageColumns.JOINED_ATTACHMENT_INFOS, 1138 MessageColumns.SAVE_MESSAGE_URI, 1139 MessageColumns.SEND_MESSAGE_URI, 1140 MessageColumns.ALWAYS_SHOW_IMAGES, 1141 MessageColumns.READ, 1142 MessageColumns.STARRED, 1143 MessageColumns.QUOTE_START_POS, 1144 MessageColumns.ATTACHMENTS, 1145 MessageColumns.CUSTOM_FROM_ADDRESS, 1146 MessageColumns.MESSAGE_ACCOUNT_URI, 1147 MessageColumns.EVENT_INTENT_URI, 1148 MessageColumns.SPAM_WARNING_STRING, 1149 MessageColumns.SPAM_WARNING_LEVEL, 1150 MessageColumns.SPAM_WARNING_LINK_TYPE, 1151 MessageColumns.VIA_DOMAIN, 1152 MessageColumns.IS_SENDING 1153 }; 1154 1155 /** Separates attachment info parts in strings in a message. */ 1156 @Deprecated 1157 public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n"; 1158 public static final String MESSAGE_LIST_TYPE = 1159 "vnd.android.cursor.dir/vnd.com.android.mail.message"; 1160 public static final String MESSAGE_TYPE = 1161 "vnd.android.cursor.item/vnd.com.android.mail.message"; 1162 1163 public static final int MESSAGE_ID_COLUMN = 0; 1164 public static final int MESSAGE_SERVER_ID_COLUMN = 1; 1165 public static final int MESSAGE_URI_COLUMN = 2; 1166 public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3; 1167 public static final int MESSAGE_SUBJECT_COLUMN = 4; 1168 public static final int MESSAGE_SNIPPET_COLUMN = 5; 1169 public static final int MESSAGE_FROM_COLUMN = 6; 1170 public static final int MESSAGE_TO_COLUMN = 7; 1171 public static final int MESSAGE_CC_COLUMN = 8; 1172 public static final int MESSAGE_BCC_COLUMN = 9; 1173 public static final int MESSAGE_REPLY_TO_COLUMN = 10; 1174 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11; 1175 public static final int MESSAGE_BODY_HTML_COLUMN = 12; 1176 public static final int MESSAGE_BODY_TEXT_COLUMN = 13; 1177 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14; 1178 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15; 1179 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16; 1180 public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17; 1181 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18; 1182 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19; 1183 public static final int MESSAGE_FLAGS_COLUMN = 20; 1184 public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21; 1185 public static final int MESSAGE_SAVE_URI_COLUMN = 22; 1186 public static final int MESSAGE_SEND_URI_COLUMN = 23; 1187 public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 24; 1188 public static final int MESSAGE_READ_COLUMN = 25; 1189 public static final int MESSAGE_STARRED_COLUMN = 26; 1190 public static final int QUOTED_TEXT_OFFSET_COLUMN = 27; 1191 public static final int MESSAGE_ATTACHMENTS_COLUMN = 28; 1192 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 29; 1193 public static final int MESSAGE_ACCOUNT_URI_COLUMN = 30; 1194 public static final int MESSAGE_EVENT_INTENT_COLUMN = 31; 1195 public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 32; 1196 public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 33; 1197 public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 34; 1198 public static final int MESSAGE_VIA_DOMAIN_COLUMN = 35; 1199 public static final int MESSAGE_IS_SENDING_COLUMN = 36; 1200 1201 public static final class CursorStatus { 1202 // The cursor is actively loading more data 1203 public static final int LOADING = 1 << 0; 1204 1205 // The cursor is currently not loading more data, but more data may be available 1206 public static final int LOADED = 1 << 1; 1207 1208 // An error occured while loading data 1209 public static final int ERROR = 1 << 2; 1210 1211 // The cursor is loaded, and there will be no more data 1212 public static final int COMPLETE = 1 << 3; 1213 1214 public static boolean isWaitingForResults(int cursorStatus) { 1215 return 0 != (cursorStatus & LOADING); 1216 } 1217 } 1218 1219 1220 public static final class CursorExtraKeys { 1221 /** 1222 * This integer column contains the staus of the message cursor. The value will be 1223 * one defined in {@link CursorStatus}. 1224 */ 1225 public static final String EXTRA_STATUS = "cursor_status"; 1226 1227 /** 1228 * Used for finding the cause of an error. 1229 * TODO: define these values 1230 */ 1231 public static final String EXTRA_ERROR = "cursor_error"; 1232 1233 } 1234 1235 public static final class AccountCursorExtraKeys { 1236 /** 1237 * This integer column contains the staus of the account cursor. The value will be 1238 * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully 1239 * initialized 1240 */ 1241 public static final String ACCOUNTS_LOADED = "accounts_loaded"; 1242 } 1243 1244 1245 public static final class MessageFlags { 1246 public static final int REPLIED = 1 << 2; 1247 public static final int FORWARDED = 1 << 3; 1248 public static final int CALENDAR_INVITE = 1 << 4; 1249 } 1250 1251 public static final class MessageColumns { 1252 /** 1253 * This string column contains a content provider URI that points to this single message. 1254 */ 1255 public static final String URI = "messageUri"; 1256 /** 1257 * This string column contains a server-assigned ID for this message. 1258 */ 1259 public static final String SERVER_ID = "serverMessageId"; 1260 public static final String CONVERSATION_ID = "conversationId"; 1261 /** 1262 * This string column contains the subject of a message. 1263 */ 1264 public static final String SUBJECT = "subject"; 1265 /** 1266 * This string column contains a snippet of the message body. 1267 */ 1268 public static final String SNIPPET = "snippet"; 1269 /** 1270 * This string column contains the single email address (and optionally name) of the sender. 1271 */ 1272 public static final String FROM = "fromAddress"; 1273 /** 1274 * This string column contains a comma-delimited list of "To:" recipient email addresses. 1275 */ 1276 public static final String TO = "toAddresses"; 1277 /** 1278 * This string column contains a comma-delimited list of "CC:" recipient email addresses. 1279 */ 1280 public static final String CC = "ccAddresses"; 1281 /** 1282 * This string column contains a comma-delimited list of "BCC:" recipient email addresses. 1283 * This value will be null for incoming messages. 1284 */ 1285 public static final String BCC = "bccAddresses"; 1286 /** 1287 * This string column contains the single email address (and optionally name) of the 1288 * sender's reply-to address. 1289 */ 1290 public static final String REPLY_TO = "replyToAddress"; 1291 /** 1292 * This long column contains the timestamp (in millis) of receipt of the message. 1293 */ 1294 public static final String DATE_RECEIVED_MS = "dateReceivedMs"; 1295 /** 1296 * This string column contains the HTML form of the message body, if available. If not, 1297 * a provider must populate BODY_TEXT. 1298 */ 1299 public static final String BODY_HTML = "bodyHtml"; 1300 /** 1301 * This string column contains the plaintext form of the message body, if HTML is not 1302 * otherwise available. If HTML is available, this value should be left empty (null). 1303 */ 1304 public static final String BODY_TEXT = "bodyText"; 1305 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources"; 1306 /** 1307 * This string column contains an opaque string used by the sendMessage api. 1308 */ 1309 public static final String REF_MESSAGE_ID = "refMessageId"; 1310 /** 1311 * This integer column contains the type of this draft, or zero (0) if this message is not a 1312 * draft. See {@link DraftType} for possible values. 1313 */ 1314 public static final String DRAFT_TYPE = "draftType"; 1315 /** 1316 * This boolean column indicates whether an outgoing message should trigger special quoted 1317 * text processing upon send. The value should default to zero (0) for protocols that do 1318 * not support or require this flag, and for all incoming messages. 1319 */ 1320 public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent"; 1321 /** 1322 * This boolean column indicates whether a message has attachments. The list of attachments 1323 * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}. 1324 */ 1325 public static final String HAS_ATTACHMENTS = "hasAttachments"; 1326 /** 1327 * This string column contains the content provider URI for the list of 1328 * attachments associated with this message. 1329 */ 1330 public static final String ATTACHMENT_LIST_URI = "attachmentListUri"; 1331 /** 1332 * This long column is a bit field of flags defined in {@link MessageFlags}. 1333 */ 1334 public static final String MESSAGE_FLAGS = "messageFlags"; 1335 /** 1336 * This string column contains a specially formatted string representing all 1337 * attachments that we added to a message that is being sent or saved. 1338 * 1339 * TODO: remove this and use {@link #ATTACHMENTS} instead 1340 */ 1341 @Deprecated 1342 public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos"; 1343 /** 1344 * This string column contains the content provider URI for saving this 1345 * message. 1346 */ 1347 public static final String SAVE_MESSAGE_URI = "saveMessageUri"; 1348 /** 1349 * This string column contains content provider URI for sending this 1350 * message. 1351 */ 1352 public static final String SEND_MESSAGE_URI = "sendMessageUri"; 1353 1354 /** 1355 * This integer column represents whether the user has specified that images should always 1356 * be shown. The value of "1" indicates that the user has specified that images should be 1357 * shown, while the value of "0" indicates that the user should be prompted before loading 1358 * any external images. 1359 */ 1360 public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages"; 1361 1362 /** 1363 * This boolean column indicates whether the message has been read 1364 */ 1365 public static String READ = "read"; 1366 1367 /** 1368 * This boolean column indicates whether the message has been starred 1369 */ 1370 public static String STARRED = "starred"; 1371 1372 /** 1373 * This integer column represents the offset in the message of quoted 1374 * text. If include_quoted_text is zero, the value contained in this 1375 * column is invalid. 1376 */ 1377 public static final String QUOTE_START_POS = "quotedTextStartPos"; 1378 1379 /** 1380 * This string columns contains a JSON array of serialized {@link Attachment} objects. 1381 */ 1382 public static final String ATTACHMENTS = "attachments"; 1383 public static final String CUSTOM_FROM_ADDRESS = "customFrom"; 1384 /** 1385 * Uri of the account associated with this message. Except in the case 1386 * of showing a combined view, this column is almost always empty. 1387 */ 1388 public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri"; 1389 /** 1390 * Intent Uri to launch when the user wants to view an event in their calendar, or null. 1391 */ 1392 public static final String EVENT_INTENT_URI = "eventIntentUri"; 1393 /** 1394 * This string column contains the string for the spam 1395 * warning of this message, or null if there is no spam warning for the message. 1396 */ 1397 public static final String SPAM_WARNING_STRING = "spamWarningString"; 1398 /** 1399 * This integer column contains the level of spam warning of this message, 1400 * or zero (0) if this message does not have a warning level. 1401 * See {@link SpamWarningLevel} for possible values. 1402 */ 1403 public static final String SPAM_WARNING_LEVEL = "spamWarningLevel"; 1404 /** 1405 * This integer column contains the type of link for the spam warning 1406 * of this message, or zero (0) if this message does not have a link type. 1407 * See {@link SpamWarningLinkType} for possible values. 1408 */ 1409 public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType"; 1410 /** 1411 * This string column contains the string for the via domain 1412 * to be included if this message was sent via an alternate 1413 * domain. This column should be null if no via domain exists. 1414 */ 1415 public static final String VIA_DOMAIN = "viaDomain"; 1416 /** 1417 * This boolean column indicates whether the message is an outgoing message in the process 1418 * of being sent (will be zero for incoming messages and messages that are already sent). 1419 */ 1420 public static final String IS_SENDING = "isSending"; 1421 1422 private MessageColumns() {} 1423 } 1424 1425 /** 1426 * List of operations that can can be performed on a message. These operations are applied 1427 * with {@link ContentProvider#update(Uri, ContentValues, String, String[])} 1428 * where the message uri is specified, and the ContentValues specifies the operation to 1429 * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT) 1430 * <p/> 1431 * Note not all UI providers will support these operations. 1432 */ 1433 public static final class MessageOperations { 1434 /** 1435 * Respond to a calendar invitation 1436 */ 1437 public static final String RESPOND_COLUMN = "respond"; 1438 1439 public static final int RESPOND_ACCEPT = 1; 1440 public static final int RESPOND_TENTATIVE = 2; 1441 public static final int RESPOND_DECLINE = 3; 1442 1443 private MessageOperations() { 1444 } 1445 } 1446 1447 public static final String ATTACHMENT_LIST_TYPE = 1448 "vnd.android.cursor.dir/vnd.com.android.mail.attachment"; 1449 public static final String ATTACHMENT_TYPE = 1450 "vnd.android.cursor.item/vnd.com.android.mail.attachment"; 1451 1452 public static final String[] ATTACHMENT_PROJECTION = { 1453 AttachmentColumns.NAME, 1454 AttachmentColumns.SIZE, 1455 AttachmentColumns.URI, 1456 AttachmentColumns.CONTENT_TYPE, 1457 AttachmentColumns.STATE, 1458 AttachmentColumns.DESTINATION, 1459 AttachmentColumns.DOWNLOADED_SIZE, 1460 AttachmentColumns.CONTENT_URI, 1461 AttachmentColumns.THUMBNAIL_URI, 1462 AttachmentColumns.PREVIEW_INTENT_URI 1463 }; 1464 private static final String EMAIL_SEPARATOR_PATTERN = "\n"; 1465 public static final int ATTACHMENT_NAME_COLUMN = 0; 1466 public static final int ATTACHMENT_SIZE_COLUMN = 1; 1467 public static final int ATTACHMENT_URI_COLUMN = 2; 1468 public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3; 1469 public static final int ATTACHMENT_STATE_COLUMN = 4; 1470 public static final int ATTACHMENT_DESTINATION_COLUMN = 5; 1471 public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6; 1472 public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7; 1473 public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8; 1474 public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9; 1475 1476 /** 1477 * Valid states for the {@link AttachmentColumns#STATE} column. 1478 * 1479 */ 1480 public static final class AttachmentState { 1481 /** 1482 * The full attachment is not present on device. When used as a command, 1483 * setting this state will tell the provider to cancel a download in 1484 * progress. 1485 * <p> 1486 * Valid next states: {@link #DOWNLOADING} 1487 */ 1488 public static final int NOT_SAVED = 0; 1489 /** 1490 * The most recent attachment download attempt failed. The current UI 1491 * design does not require providers to persist this state, but 1492 * providers must return this state at least once after a download 1493 * failure occurs. This state may not be used as a command. 1494 * <p> 1495 * Valid next states: {@link #DOWNLOADING} 1496 */ 1497 public static final int FAILED = 1; 1498 /** 1499 * The attachment is currently being downloaded by the provider. 1500 * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current 1501 * download progress while in this state. When used as a command, 1502 * setting this state will tell the provider to initiate a download to 1503 * the accompanying destination in {@link AttachmentColumns#DESTINATION} 1504 * . 1505 * <p> 1506 * Valid next states: {@link #NOT_SAVED}, {@link #FAILED}, 1507 * {@link #SAVED} 1508 */ 1509 public static final int DOWNLOADING = 2; 1510 /** 1511 * The attachment was successfully downloaded to the destination in 1512 * {@link AttachmentColumns#DESTINATION}. If a provider later detects 1513 * that a download is missing, it should reset the state to 1514 * {@link #NOT_SAVED}. This state may not be used as a command on its 1515 * own. To move a file from cache to external, update 1516 * {@link AttachmentColumns#DESTINATION}. 1517 * <p> 1518 * Valid next states: {@link #NOT_SAVED} 1519 */ 1520 public static final int SAVED = 3; 1521 1522 private AttachmentState() {} 1523 } 1524 1525 public static final class AttachmentDestination { 1526 1527 /** 1528 * The attachment will be or is already saved to the app-private cache partition. 1529 */ 1530 public static final int CACHE = 0; 1531 /** 1532 * The attachment will be or is already saved to external shared device storage. 1533 */ 1534 public static final int EXTERNAL = 1; 1535 1536 private AttachmentDestination() {} 1537 } 1538 1539 public static final class AttachmentColumns { 1540 /** 1541 * This string column is the attachment's file name, intended for display in UI. It is not 1542 * the full path of the file. 1543 */ 1544 public static final String NAME = OpenableColumns.DISPLAY_NAME; 1545 /** 1546 * This integer column is the file size of the attachment, in bytes. 1547 */ 1548 public static final String SIZE = OpenableColumns.SIZE; 1549 /** 1550 * This column is a {@link Uri} that can be queried to monitor download state and progress 1551 * for this individual attachment (resulting cursor has one single row for this attachment). 1552 */ 1553 public static final String URI = "uri"; 1554 /** 1555 * This string column is the MIME type of the attachment. 1556 */ 1557 public static final String CONTENT_TYPE = "contentType"; 1558 /** 1559 * This integer column is the current downloading state of the 1560 * attachment as defined in {@link AttachmentState}. 1561 * <p> 1562 * Providers must accept updates to {@link #URI} with new values of 1563 * this column to initiate or cancel downloads. 1564 */ 1565 public static final String STATE = "state"; 1566 /** 1567 * This integer column is the file destination for the current download 1568 * in progress (when {@link #STATE} is 1569 * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file 1570 * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined 1571 * in {@link AttachmentDestination}. This value is undefined in any 1572 * other state. 1573 * <p> 1574 * Providers must accept updates to {@link #URI} with new values of 1575 * this column to move an existing downloaded file. 1576 */ 1577 public static final String DESTINATION = "destination"; 1578 /** 1579 * This integer column is the current number of bytes downloaded when 1580 * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is 1581 * undefined in any other state. 1582 */ 1583 public static final String DOWNLOADED_SIZE = "downloadedSize"; 1584 /** 1585 * This column is a {@link Uri} that points to the downloaded local file 1586 * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is 1587 * undefined in any other state. 1588 */ 1589 public static final String CONTENT_URI = "contentUri"; 1590 /** 1591 * This column is a {@link Uri} that points to a local thumbnail file 1592 * for the attachment. Providers that do not support downloading 1593 * attachment thumbnails may leave this null. 1594 */ 1595 public static final String THUMBNAIL_URI = "thumbnailUri"; 1596 /** 1597 * This column is an {@link Uri} used in an {@link Intent.ACTION_VIEW} Intent to launch a 1598 * preview activity that allows the user to efficiently view an attachment without having to 1599 * first download the entire file. Providers that do not support 1600 * previewing attachments may leave this null. 1601 */ 1602 public static final String PREVIEW_INTENT_URI = "previewIntentUri"; 1603 1604 private AttachmentColumns() {} 1605 } 1606 1607 public static String getAttachmentTypeSetting() { 1608 // TODO: query the account to see what kinds of attachments it supports? 1609 return "com.google.android.gm.allowAddAnyAttachment"; 1610 } 1611 1612 public static void incrementRecipientsTimesContacted(Context context, String addressString) { 1613 DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context); 1614 ArrayList<String> recipients = new ArrayList<String>(); 1615 String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN); 1616 for (String address : addresses) { 1617 recipients.add(address); 1618 } 1619 statsUpdater.updateWithAddress(recipients); 1620 } 1621 1622 public static final String[] UNDO_PROJECTION = { 1623 ConversationColumns.MESSAGE_LIST_URI 1624 }; 1625 public static final int UNDO_MESSAGE_LIST_COLUMN = 0; 1626 1627 // Parameter used to indicate the sequence number for an undoable operation 1628 public static final String SEQUENCE_QUERY_PARAMETER = "seq"; 1629 1630 /** 1631 * Settings for auto advancing when the current conversation has been destroyed. 1632 */ 1633 public static final class AutoAdvance { 1634 /** No setting specified. */ 1635 public static final int UNSET = 0; 1636 /** Go to the older message (if available) */ 1637 public static final int OLDER = 1; 1638 /** Go to the newer message (if available) */ 1639 public static final int NEWER = 2; 1640 /** Go back to conversation list*/ 1641 public static final int LIST = 3; 1642 } 1643 1644 /** 1645 * Settings for what swipe should do. 1646 */ 1647 public static final class Swipe { 1648 /** Archive or remove label, if available. */ 1649 public static final int ARCHIVE = 0; 1650 /** Delete */ 1651 public static final int DELETE = 1; 1652 /** No swipe */ 1653 public static final int DISABLED = 2; 1654 /** Default is delete */ 1655 public static final int DEFAULT = ARCHIVE; 1656 } 1657 1658 public static final class SnapHeaderValue { 1659 public static final int ALWAYS = 0; 1660 public static final int PORTRAIT_ONLY = 1; 1661 public static final int NEVER = 2; 1662 } 1663 1664 public static final class MessageTextSize { 1665 public static final int TINY = -2; 1666 public static final int SMALL = -1; 1667 public static final int NORMAL = 0; 1668 public static final int LARGE = 1; 1669 public static final int HUGE = 2; 1670 } 1671 1672 public static final class DefaultReplyBehavior { 1673 public static final int REPLY = 0; 1674 public static final int REPLY_ALL = 1; 1675 } 1676 1677 /** 1678 * Action for an intent used to update/create new notifications. The mime type of this 1679 * intent should be set to the mimeType of the account that is generating this notification. 1680 * An intent of this action is required to have the following extras: 1681 * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT} 1682 */ 1683 public static final String ACTION_UPDATE_NOTIFICATION = 1684 "com.android.mail.action.update_notification"; 1685 1686 public static final class UpdateNotificationExtras { 1687 /** 1688 * Parcelable extra containing a {@link Uri} to a {@link Folder} 1689 */ 1690 public static final String EXTRA_FOLDER = "notification_extra_folder"; 1691 1692 /** 1693 * Parcelable extra containing a {@link Uri} to an {@link Account} 1694 */ 1695 public static final String EXTRA_ACCOUNT = "notification_extra_account"; 1696 1697 /** 1698 * Integer extra containing the update unread count for the account/folder. 1699 * If this value is 0, the UI will not block the intent to allow code to clear notifications 1700 * to run. 1701 */ 1702 public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count"; 1703 } 1704 1705 public static final class EditSettingsExtras { 1706 /** 1707 * Parcelable extra containing account for which the user wants to 1708 * modify settings 1709 */ 1710 public static final String EXTRA_ACCOUNT = "extra_account"; 1711 1712 /** 1713 * Parcelable extra containing folder for which the user wants to 1714 * modify settings 1715 */ 1716 public static final String EXTRA_FOLDER = "extra_folder"; 1717 1718 /** 1719 * Boolean extra which is set true if the user wants to "manage folders" 1720 */ 1721 public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders"; 1722 } 1723 1724 public static final class SendFeedbackExtras { 1725 /** 1726 * Optional boolean extras which indicates that the user is reporting a problem. 1727 */ 1728 public static final String EXTRA_REPORTING_PROBLEM = "reporting_problem"; 1729 } 1730} 1731