summaryrefslogtreecommitdiffstats
path: root/src/com/android/mail/ui/ConversationUpdater.java
blob: 745d7d2a2c1b699c1ce493b1997d2268bf545603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * Copyright (C) 2012 Google Inc.
 * Licensed to The Android Open Source Project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.mail.ui;

import android.app.AlertDialog;
import android.content.ContentValues;
import android.net.Uri;

import com.android.mail.browse.ConfirmDialogFragment;
import com.android.mail.browse.ConversationCursor;
import com.android.mail.browse.ConversationMessage;
import com.android.mail.browse.UndoCallback;
import com.android.mail.providers.Conversation;
import com.android.mail.providers.ConversationInfo;
import com.android.mail.providers.Folder;
import com.android.mail.providers.UIProvider;

import java.util.Collection;
import java.util.Set;

/**
 * Classes that can update conversations implement this interface.
 */
public interface ConversationUpdater extends ConversationListCallbacks {
    /**
     * Modify the given conversation by changing the column provided here to contain the value
     * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example
     * {@link UIProvider.ConversationColumns#FOLDER_LIST}
     * @param target
     * @param columnName
     * @param value
     */
    void updateConversation(Collection <Conversation> target, String columnName, String value);

    /**
     * Modify the given conversation by changing the column provided here to contain the value
     * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example
     * {@link UIProvider.ConversationColumns#READ}
     * @param target
     * @param columnName
     * @param value
     */
    void updateConversation(Collection <Conversation> target, String columnName, int value);

    /**
     * Modify the given conversation by changing the column provided here to contain the value
     * provided. Column names are listed in {@link UIProvider.ConversationColumns}, for example
     * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS}
     * @param target
     * @param columnName
     * @param value
     */
    void updateConversation(Collection <Conversation> target, String columnName, boolean value);

    /**
     * Modify the given conversation by changing the columns provided here to
     * contain the values provided. Column names are listed in
     * {@link UIProvider.ConversationColumns}, for example
     * {@link UIProvider.ConversationColumns#HAS_ATTACHMENTS}
     * @param target
     * @param values
     */
    void updateConversation(Collection <Conversation> target, ContentValues values);

    /**
     * Requests the removal of the current conversation with the specified destructive action.
     * @param actionId the unique id for the action responsible for this delete: R.id.archive, ...
     * @param target the conversations to act upon.
     * @param action to perform after the UI has been updated to remove the conversations
     * @param isBatch true if this is a batch action, false otherwise.
     */
    void delete(
            int actionId, final Collection<Conversation> target, final DestructiveAction action,
            boolean isBatch);

    /**
     * Mark a number of conversations as read or unread.
     * @param targets the conversations to act upon
     * @param read true if the conversations are marked read, false if they are marked unread.
     * @param viewed whether the conversations are marked viewed as well. This indicates that the
     * conversations are shown on the UI.
     */
    void markConversationsRead(Collection<Conversation> targets, boolean read, boolean viewed);

    /**
     * Mark a single conversation unread, either entirely or for just a subset of the messages in a
     * conversation and the view <b>returns to Conversation List</b> mode.
     *
     * @param conv conversation to mark unread
     * @param unreadMessageUris URIs for the subset of the conversation's messages to mark unread,
     * or null/empty set to mark the entire conversation unread.
     * @param originalConversationInfo the original unread state of the {@link ConversationInfo}
     * that {@link ConversationCursor} will temporarily use until the commit is complete.
     */
    void markConversationMessagesUnread(Conversation conv, Set<Uri> unreadMessageUris,
            byte[] originalConversationInfo);

    /**
     * Mark a single conversation 'seen', which is a combination of 'viewed' and 'read'. In some
     * configurations (peek mode), this operation may be prevented and the method will return false.
     *
     * @param conv the conversation to mark seen
     * @return true if the operation was a success
     */
    boolean markConversationSeen(Conversation conv);

    /**
     * Star a single message within a conversation. This method requires a
     * {@link ConversationMessage} to propagate the change to the owning {@link Conversation}.
     *
     */
    void starMessage(ConversationMessage msg, boolean starred);

    /**
     * Get a destructive action for selected conversations. The action corresponds to Menu item
     * identifiers, for example R.id.unread, or R.id.delete.
     * @param action
     * @return
     */
    public DestructiveAction getBatchAction(int action, UndoCallback undoCallback);

    /**
     * Get a destructive action for selected conversations. The action corresponds to Menu item
     * identifiers, for example R.id.unread, or R.id.delete.
     * @param action
     * @return
     */
    public DestructiveAction getDeferredBatchAction(int action, UndoCallback undoCallback);

    /**
     * Get destructive folder change for selected conversations.
     * The caller must explicitly call performAction.
     * @param target
     * @param toRemove
     * @param isDestructive
     * @param isBatch
     * @param showUndo
     * @param undoCallback
     * @return
     */
    public DestructiveAction getDeferredRemoveFolder(Collection<Conversation> target,
            Folder toRemove, boolean isDestructive, boolean isBatch,
            boolean showUndo, UndoCallback undoCallback);

    /**
     * Assign the target conversations to the given folders, and remove them from all other folders
     * that they might be assigned to.
     * @param folders the folders to assign the conversations to.
     * @param target the conversations to act upon.
     * @param batch whether this is a batch operation
     * @param showUndo whether to show the undo bar
     * @param isMoveTo <code>true</code> if this is a move operation, <code>false</code> if it is
     *        some other type of folder change operation
     */
    public void assignFolder(Collection<FolderOperation> folders, Collection<Conversation> target,
            boolean batch, boolean showUndo, boolean isMoveTo);

    /**
     * Refreshes the conversation list, if one exists.
     */
    void refreshConversationList();

    /**
     * Show the next conversation after a destructive action. The next
     * conversation is determined by list state and user preferences.
     * @param conversations Conversations that were removed as part of the
     *            destructive action.
     */
    void showNextConversation(Collection<Conversation> conversations);

    /**
     * Make an action listener for a confirmation dialog, and the currently selected set of
     * conversations. The action is specified as an integer which marks the menu resource:
     * R.id.delete, R.id.discard_drafts, etc.
     * @param action the resource ID of the menu action: R.id.delete, for example
     * @param fromSelectedSet true if the listener acts on the selected set, false if the listener
     *        acts on the current conversation.
     * @param undoCallback the appropriate callback (if any) that needs to be run when this
     *        specific action is undone
     */
    public void makeDialogListener(final int action, boolean fromSelectedSet,
            UndoCallback undoCallback);

    /**
     * If set, get the listener associated with the existing {@link ConfirmDialogFragment}.  This
     * listener needs to be set centrally, because the dialog fragment can get torn down, along with
     * the current activity, and the listener has to be created afresh.
     * @return the current listener for the positive action in the current confirmation dialog, if
     * any. Returns null if no confirmation dialog is currently shown.
     */
    public AlertDialog.OnClickListener getListener();
}