ConversationUpdater.java revision 3b6abe57473e9565e502c6a2013fdbaad803bad0
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.MessageCursor.ConversationMessage; 25import com.android.mail.providers.Conversation; 26import com.android.mail.providers.ConversationInfo; 27import com.android.mail.providers.UIProvider; 28import com.android.mail.providers.UIProvider.AutoAdvance; 29 30import java.util.Collection; 31import java.util.Set; 32 33/** 34 * Classes that can update conversations implement this interface. 35 */ 36public interface ConversationUpdater extends ConversationListCallbacks { 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 /** 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 /** 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 /** 85 * Mark a number of conversations as read or unread. 86 * 87 */ 88 void markConversationsRead(Collection<Conversation> targets, boolean read); 89 90 /** 91 * Mark a single conversation unread, either entirely or for just a subset of the messages in a 92 * conversation. 93 * 94 * @param conv conversation to mark unread 95 * @param unreadMessageUris URIs for the subset of the conversation's messages to mark unread, 96 * or null/empty set to mark the entire conversation unread. 97 * @param originalConversationInfo the original unread state of the {@link ConversationInfo} 98 * that {@link ConversationCursor} will temporarily use until the commit is complete. 99 * @param forceAutoAdvance set to true if the auto advance behavior is specified in the next 100 * variable. 101 * @param autoadvance the {@link AutoAdvance} value: one of {@link AutoAdvance#LIST}, 102 * {@link AutoAdvance#NEWER}, or {@link AutoAdvance#OLDER}. 103 */ 104 void markConversationMessagesUnread(Conversation conv, Set<Uri> unreadMessageUris, 105 String originalConversationInfo, boolean forceAutoAdvance, int autoadvance); 106 107 /** 108 * Star a single message within a conversation. This method requires a 109 * {@link ConversationMessage} to propagate the change to the owning {@link Conversation}. 110 * 111 */ 112 void starMessage(ConversationMessage msg, boolean starred); 113 114 /** 115 * Get a destructive action for selected conversations. The action corresponds to Menu item 116 * identifiers, for example R.id.unread, or R.id.delete. 117 * @param action 118 * @return 119 */ 120 public DestructiveAction getBatchAction(int action); 121 122 /** 123 * Get a destructive action for selected conversations. The action 124 * corresponds to Menu item identifiers, for example R.id.unread, or 125 * R.id.delete. but is not automatically added to the pending actions list. 126 * The caller must explicitly call performAction. 127 * @param action 128 * @return 129 */ 130 public DestructiveAction getDeferredBatchAction(int action); 131 132 /** 133 * Assign the target conversations to the given folders, and remove them from all other 134 * folders that they might be assigned to. 135 * @param folders the folders to assign the conversations to. 136 * @param target the conversations to act upon. 137 * @param batch whether this is a batch operation 138 * @param showUndo whether to show the undo bar 139 */ 140 public void assignFolder(Collection<FolderOperation> folders, Collection<Conversation> target, 141 boolean batch, boolean showUndo); 142 143 /** 144 * Refreshes the conversation list, if one exists. 145 */ 146 void refreshConversationList(); 147} 148