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