ConversationUpdater.java revision 84f7d32bdc79263004ed5241480988e02f8e618c
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 18package com.android.mail.ui; 19 20import android.content.ContentValues; 21import android.net.Uri; 22 23import com.android.mail.browse.ConversationCursor; 24import com.android.mail.browse.ConversationItemView; 25import com.android.mail.browse.MessageCursor.ConversationMessage; 26import com.android.mail.providers.Conversation; 27import com.android.mail.providers.ConversationInfo; 28import com.android.mail.providers.Folder; 29import com.android.mail.providers.UIProvider; 30 31import java.util.Collection; 32import java.util.Set; 33 34/** 35 * Classes that can update conversations implement this interface. 36 */ 37public interface ConversationUpdater extends ConversationListCallbacks { 38 /** 39 * Modify the given conversation by changing the column provided here to contain the value 40 * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example 41 * {@link UIProvider.ConversationColumns#FOLDER_LIST} 42 * @param target 43 * @param columnName 44 * @param value 45 */ 46 void updateConversation(Collection <Conversation> target, String columnName, String value); 47 48 /** 49 * Modify the given conversation by changing the column provided here to contain the value 50 * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example 51 * {@link UIProvider.ConversationColumns#READ} 52 * @param target 53 * @param columnName 54 * @param value 55 */ 56 void updateConversation(Collection <Conversation> target, String columnName, int value); 57 58 /** 59 * Modify the given conversation by changing the column provided here to contain the value 60 * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example 61 * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS} 62 * @param target 63 * @param columnName 64 * @param value 65 */ 66 void updateConversation(Collection <Conversation> target, String columnName, boolean value); 67 68 /** 69 * Modify the given conversation by changing the columns provided here to 70 * contain the values provided. Column names are listed in 71 * {@link UIProvider.ConversationColumns}, for example 72 * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS} 73 * @param target 74 * @param values 75 */ 76 void updateConversation(Collection <Conversation> target, ContentValues values); 77 78 /** 79 * Requests the removal of the current conversation with the specified destructive action. 80 * @param actionId TODO(viki): 81 * @param target the conversations to act upon. 82 * @param action to perform after the UI has been updated to remove the conversations 83 */ 84 void delete( 85 int actionId, final Collection<Conversation> target, final DestructiveAction action); 86 87 /** 88 * Requests the removal of the current conversation with the specified 89 * destructive action. 90 * @param actionId TODO(viki): 91 * @param target the conversations to act upon. 92 *@param target the conversation views to act upon. 93 * @param action to perform after the UI has been updated to remove the 94 * conversations 95 */ 96 void delete(int actionId, final Collection<Conversation> target, 97 final Collection<ConversationItemView> targetViews, final DestructiveAction action); 98 99 /** 100 * Mark a number of conversations as read or unread. 101 * @param targets the conversations to act upon 102 * @param read true if the conversations are marked read, false if they are marked unread. 103 * @param viewed whether the conversations are marked viewed as well. This indicates that the 104 * conversations are shown on the UI. 105 */ 106 void markConversationsRead(Collection<Conversation> targets, boolean read, boolean viewed); 107 108 /** 109 * Mark a single conversation unread, either entirely or for just a subset of the messages in a 110 * conversation and the view <b>returns to Conversation List</b> mode. 111 * 112 * @param conv conversation to mark unread 113 * @param unreadMessageUris URIs for the subset of the conversation's messages to mark unread, 114 * or null/empty set to mark the entire conversation unread. 115 * @param originalConversationInfo the original unread state of the {@link ConversationInfo} 116 * that {@link ConversationCursor} will temporarily use until the commit is complete. 117 */ 118 void markConversationMessagesUnread(Conversation conv, Set<Uri> unreadMessageUris, 119 String originalConversationInfo); 120 121 /** 122 * Star a single message within a conversation. This method requires a 123 * {@link ConversationMessage} to propagate the change to the owning {@link Conversation}. 124 * 125 */ 126 void starMessage(ConversationMessage msg, boolean starred); 127 128 /** 129 * Get a destructive action for selected conversations. The action corresponds to Menu item 130 * identifiers, for example R.id.unread, or R.id.delete. 131 * @param action 132 * @return 133 */ 134 public DestructiveAction getBatchAction(int action); 135 136 /** 137 * Get a destructive action for selected conversations. The action corresponds to Menu item 138 * identifiers, for example R.id.unread, or R.id.delete. 139 * @param action 140 * @return 141 */ 142 public DestructiveAction getDeferredBatchAction(int action); 143 144 /** 145 * Get a destructive action for selected conversations. The action 146 * corresponds to Menu item identifiers, for example R.id.unread, or 147 * R.id.delete. but is not automatically added to the pending actions list. 148 * The caller must explicitly call performAction. 149 * @param action 150 * @param batch 151 * @return 152 */ 153 public DestructiveAction getDeferredAction(int action, Collection<Conversation> target, 154 boolean batch); 155 156 /** 157 * Get destructive folder change for selected conversations. 158 * The caller must explicitly call performAction. 159 * @param action 160 * @return 161 */ 162 public DestructiveAction getDeferredRemoveFolder(Collection<Conversation> target, 163 Folder toRemove, boolean isDestructive, boolean isBatch, 164 boolean showUndo); 165 166 /** 167 * Assign the target conversations to the given folders, and remove them from all other 168 * folders that they might be assigned to. 169 * @param folders the folders to assign the conversations to. 170 * @param target the conversations to act upon. 171 * @param batch whether this is a batch operation 172 * @param showUndo whether to show the undo bar 173 */ 174 public void assignFolder(Collection<FolderOperation> folders, Collection<Conversation> target, 175 boolean batch, boolean showUndo); 176 177 /** 178 * Refreshes the conversation list, if one exists. 179 */ 180 void refreshConversationList(); 181 182 /** 183 * Show the next conversation after a destructive action. The next 184 * conversation is determined by list state and user preferences. 185 * @param conversations Conversations that were removed as part of the 186 * destructive action. 187 */ 188 void showNextConversation(Collection<Conversation> conversations); 189} 190