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