Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
| 18 | package com.android.mail.ui; |
| 19 | |
Mindy Pereira | 6c2663d | 2012-07-20 15:37:29 -0700 | [diff] [blame] | 20 | import android.content.ContentValues; |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 21 | import android.net.Uri; |
Mindy Pereira | 6c2663d | 2012-07-20 15:37:29 -0700 | [diff] [blame] | 22 | |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 23 | import com.android.mail.browse.ConversationCursor; |
| 24 | import com.android.mail.browse.MessageCursor.ConversationMessage; |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 25 | import com.android.mail.providers.Conversation; |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 26 | import com.android.mail.providers.ConversationInfo; |
Mindy Pereira | 01f3050 | 2012-08-14 10:30:51 -0700 | [diff] [blame] | 27 | import com.android.mail.providers.Folder; |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 28 | import com.android.mail.providers.UIProvider; |
| 29 | |
| 30 | import java.util.Collection; |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 31 | import java.util.Set; |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Classes that can update conversations implement this interface. |
| 35 | */ |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 36 | public interface ConversationUpdater extends ConversationListCallbacks { |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Modify the given conversation by changing the column provided here to contain the value |
| 39 | * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example |
| 40 | * {@link UIProvider.ConversationColumns#FOLDER_LIST} |
| 41 | * @param target |
| 42 | * @param columnName |
| 43 | * @param value |
| 44 | */ |
| 45 | void updateConversation(Collection <Conversation> target, String columnName, String value); |
| 46 | |
| 47 | /** |
| 48 | * Modify the given conversation by changing the column provided here to contain the value |
| 49 | * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example |
| 50 | * {@link UIProvider.ConversationColumns#READ} |
| 51 | * @param target |
| 52 | * @param columnName |
| 53 | * @param value |
| 54 | */ |
| 55 | void updateConversation(Collection <Conversation> target, String columnName, int value); |
| 56 | |
| 57 | /** |
| 58 | * Modify the given conversation by changing the column provided here to contain the value |
| 59 | * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example |
| 60 | * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS} |
| 61 | * @param target |
| 62 | * @param columnName |
| 63 | * @param value |
| 64 | */ |
| 65 | void updateConversation(Collection <Conversation> target, String columnName, boolean value); |
| 66 | |
| 67 | /** |
Mindy Pereira | 6c2663d | 2012-07-20 15:37:29 -0700 | [diff] [blame] | 68 | * Modify the given conversation by changing the columns provided here to |
| 69 | * contain the values provided. Column names are listed in |
| 70 | * {@link UIProvider.ConversationColumns}, for example |
| 71 | * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS} |
| 72 | * @param target |
| 73 | * @param values |
| 74 | */ |
| 75 | void updateConversation(Collection <Conversation> target, ContentValues values); |
| 76 | |
| 77 | /** |
Vikram Aggarwal | 4f4782b | 2012-05-30 08:39:09 -0700 | [diff] [blame] | 78 | * Requests the removal of the current conversation with the specified destructive action. |
| 79 | * @param target the conversations to act upon. |
| 80 | * @param action to perform after the UI has been updated to remove the conversations |
| 81 | */ |
| 82 | void delete(final Collection<Conversation> target, final DestructiveAction action); |
| 83 | |
| 84 | /** |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 85 | * Mark a number of conversations as read or unread. |
Vikram Aggarwal | 66bc2aa | 2012-08-02 10:47:03 -0700 | [diff] [blame] | 86 | * @param targets the conversations to act upon |
| 87 | * @param read true if the conversations are marked read, false if they are marked unread. |
| 88 | * @param viewed whether the conversations are marked viewed as well. This indicates that the |
| 89 | * conversations are shown on the UI. |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 90 | */ |
Vikram Aggarwal | 66bc2aa | 2012-08-02 10:47:03 -0700 | [diff] [blame] | 91 | void markConversationsRead(Collection<Conversation> targets, boolean read, boolean viewed); |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Mark a single conversation unread, either entirely or for just a subset of the messages in a |
Vikram Aggarwal | 4a878b6 | 2012-07-31 15:09:25 -0700 | [diff] [blame] | 95 | * conversation and the view <b>returns to Conversation List</b> mode. |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 96 | * |
| 97 | * @param conv conversation to mark unread |
| 98 | * @param unreadMessageUris URIs for the subset of the conversation's messages to mark unread, |
| 99 | * or null/empty set to mark the entire conversation unread. |
| 100 | * @param originalConversationInfo the original unread state of the {@link ConversationInfo} |
| 101 | * that {@link ConversationCursor} will temporarily use until the commit is complete. |
| 102 | */ |
| 103 | void markConversationMessagesUnread(Conversation conv, Set<Uri> unreadMessageUris, |
Vikram Aggarwal | 4a878b6 | 2012-07-31 15:09:25 -0700 | [diff] [blame] | 104 | String originalConversationInfo); |
Andy Huang | 839ada2 | 2012-07-20 15:48:40 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Star a single message within a conversation. This method requires a |
| 108 | * {@link ConversationMessage} to propagate the change to the owning {@link Conversation}. |
| 109 | * |
| 110 | */ |
| 111 | void starMessage(ConversationMessage msg, boolean starred); |
| 112 | |
| 113 | /** |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 114 | * Get a destructive action for selected conversations. The action corresponds to Menu item |
| 115 | * identifiers, for example R.id.unread, or R.id.delete. |
| 116 | * @param action |
| 117 | * @return |
| 118 | */ |
| 119 | public DestructiveAction getBatchAction(int action); |
| 120 | |
| 121 | /** |
Mindy Pereira | de3e74a | 2012-07-24 09:43:10 -0700 | [diff] [blame] | 122 | * Get a destructive action for selected conversations. The action |
| 123 | * corresponds to Menu item identifiers, for example R.id.unread, or |
| 124 | * R.id.delete. but is not automatically added to the pending actions list. |
| 125 | * The caller must explicitly call performAction. |
| 126 | * @param action |
| 127 | * @return |
| 128 | */ |
| 129 | public DestructiveAction getDeferredBatchAction(int action); |
| 130 | |
| 131 | /** |
Mindy Pereira | 01f3050 | 2012-08-14 10:30:51 -0700 | [diff] [blame] | 132 | * Get destructive folder change for selected conversations. |
| 133 | * The caller must explicitly call performAction. |
| 134 | * @param action |
| 135 | * @return |
| 136 | */ |
| 137 | public DestructiveAction getDeferredRemoveFolder(Collection<Conversation> target, |
| 138 | Folder toRemove, boolean isDestructive, boolean isBatch, |
| 139 | boolean showUndo); |
| 140 | |
| 141 | /** |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 142 | * Assign the target conversations to the given folders, and remove them from all other |
| 143 | * folders that they might be assigned to. |
| 144 | * @param folders the folders to assign the conversations to. |
| 145 | * @param target the conversations to act upon. |
| 146 | * @param batch whether this is a batch operation |
Mindy Pereira | 06642fa | 2012-07-12 16:23:27 -0700 | [diff] [blame] | 147 | * @param showUndo whether to show the undo bar |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 148 | */ |
Mindy Pereira | 8db7e40 | 2012-07-13 10:32:47 -0700 | [diff] [blame] | 149 | public void assignFolder(Collection<FolderOperation> folders, Collection<Conversation> target, |
Mindy Pereira | 06642fa | 2012-07-12 16:23:27 -0700 | [diff] [blame] | 150 | boolean batch, boolean showUndo); |
Vikram Aggarwal | 4f4782b | 2012-05-30 08:39:09 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * Refreshes the conversation list, if one exists. |
| 154 | */ |
| 155 | void refreshConversationList(); |
Vikram Aggarwal | 531488e | 2012-05-29 16:36:52 -0700 | [diff] [blame] | 156 | } |