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