blob: 8188c488b765b09642a4280a9a120126a2331d7f [file] [log] [blame]
Vikram Aggarwal531488e2012-05-29 16:36:52 -07001/*
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
Mindy Pereira6c2663d2012-07-20 15:37:29 -070020import android.content.ContentValues;
Andy Huang839ada22012-07-20 15:48:40 -070021import android.net.Uri;
Mindy Pereira6c2663d2012-07-20 15:37:29 -070022
Andy Huang839ada22012-07-20 15:48:40 -070023import com.android.mail.browse.ConversationCursor;
24import com.android.mail.browse.MessageCursor.ConversationMessage;
Vikram Aggarwal531488e2012-05-29 16:36:52 -070025import com.android.mail.providers.Conversation;
Andy Huang839ada22012-07-20 15:48:40 -070026import com.android.mail.providers.ConversationInfo;
Mindy Pereira01f30502012-08-14 10:30:51 -070027import com.android.mail.providers.Folder;
Vikram Aggarwal531488e2012-05-29 16:36:52 -070028import com.android.mail.providers.UIProvider;
29
30import java.util.Collection;
Andy Huang839ada22012-07-20 15:48:40 -070031import java.util.Set;
Vikram Aggarwal531488e2012-05-29 16:36:52 -070032
33/**
34 * Classes that can update conversations implement this interface.
35 */
Andy Huang839ada22012-07-20 15:48:40 -070036public interface ConversationUpdater extends ConversationListCallbacks {
Vikram Aggarwal531488e2012-05-29 16:36:52 -070037 /**
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 Pereira6c2663d2012-07-20 15:37:29 -070068 * 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 Aggarwal4f4782b2012-05-30 08:39:09 -070078 * 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 Huang839ada22012-07-20 15:48:40 -070085 * Mark a number of conversations as read or unread.
Vikram Aggarwal66bc2aa2012-08-02 10:47:03 -070086 * @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 Huang839ada22012-07-20 15:48:40 -070090 */
Vikram Aggarwal66bc2aa2012-08-02 10:47:03 -070091 void markConversationsRead(Collection<Conversation> targets, boolean read, boolean viewed);
Andy Huang839ada22012-07-20 15:48:40 -070092
93 /**
94 * Mark a single conversation unread, either entirely or for just a subset of the messages in a
Vikram Aggarwal4a878b62012-07-31 15:09:25 -070095 * conversation and the view <b>returns to Conversation List</b> mode.
Andy Huang839ada22012-07-20 15:48:40 -070096 *
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 Aggarwal4a878b62012-07-31 15:09:25 -0700104 String originalConversationInfo);
Andy Huang839ada22012-07-20 15:48:40 -0700105
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 Aggarwal531488e2012-05-29 16:36:52 -0700114 * 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 Pereirade3e74a2012-07-24 09:43:10 -0700122 * 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 Pereira01f30502012-08-14 10:30:51 -0700132 * 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 Aggarwal531488e2012-05-29 16:36:52 -0700142 * 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 Pereira06642fa2012-07-12 16:23:27 -0700147 * @param showUndo whether to show the undo bar
Vikram Aggarwal531488e2012-05-29 16:36:52 -0700148 */
Mindy Pereira8db7e402012-07-13 10:32:47 -0700149 public void assignFolder(Collection<FolderOperation> folders, Collection<Conversation> target,
Mindy Pereira06642fa2012-07-12 16:23:27 -0700150 boolean batch, boolean showUndo);
Vikram Aggarwal4f4782b2012-05-30 08:39:09 -0700151
152 /**
153 * Refreshes the conversation list, if one exists.
154 */
155 void refreshConversationList();
Vikram Aggarwal531488e2012-05-29 16:36:52 -0700156}