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