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.LoaderManager.LoaderCallbacks; 21 import android.database.DataSetObserver; 22 import android.os.Bundle; 23 import android.os.Parcelable; 24 25 import com.android.mail.browse.ConversationCursor; 26 import com.android.mail.providers.Conversation; 27 import com.android.mail.providers.Folder; 28 29 /** 30 * A controller interface that is to receive user initiated events and handle them. 31 */ 32 public interface ConversationListCallbacks { 33 /** 34 * Show the conversation provided here. If the conversation is null, this is a request to pop 35 * <em>out</em> of conversation view mode and head back to conversation list mode, or whatever 36 * should best show in its place. 37 * @param conversation conversation to display, possibly null. 38 * @param inLoaderCallbacks whether we are in the scope of a {@link LoaderCallbacks} method 39 * (when fragment transactions are disallowed) 40 */ onConversationSelected(Conversation conversation, boolean inLoaderCallbacks)41 void onConversationSelected(Conversation conversation, boolean inLoaderCallbacks); 42 43 /** 44 * Possibly show the conversation provided here depending on implementation. 45 * Used mainly by two-pane landscape mode when we are navigating with the keyboard. 46 */ onConversationFocused(Conversation conversation)47 void onConversationFocused(Conversation conversation); 48 49 /** 50 * Called whenever CAB mode has been entered via long press or selecting a sender image. 51 */ onCabModeEntered()52 void onCabModeEntered(); 53 54 /** 55 * Called whenever CAB mode has been exited. 56 */ onCabModeExited()57 void onCabModeExited(); 58 getConversationListCursor()59 ConversationCursor getConversationListCursor(); 60 getCurrentConversation()61 Conversation getCurrentConversation(); setCurrentConversation(Conversation c)62 void setCurrentConversation(Conversation c); onConversationViewSwitched(Conversation c)63 void onConversationViewSwitched(Conversation c); 64 65 /** 66 * Returns whether the initial conversation has begun but not finished loading. If this returns 67 * true, you can register to be told when the load in progress finishes 68 * ({@link #registerConversationLoadedObserver(DataSetObserver)}). 69 * <p> 70 * This flag only applies to the first conversation in a set (e.g. when using ViewPager). 71 * 72 * @return true if the initial conversation has begun but not finished loading 73 */ isInitialConversationLoading()74 boolean isInitialConversationLoading(); registerConversationLoadedObserver(DataSetObserver observer)75 void registerConversationLoadedObserver(DataSetObserver observer); unregisterConversationLoadedObserver(DataSetObserver observer)76 void unregisterConversationLoadedObserver(DataSetObserver observer); 77 /** 78 * Coordinates actions that might occur in response to a conversation that has finished loading 79 * and is now user-visible. 80 */ onConversationSeen()81 void onConversationSeen(); 82 registerConversationListObserver(DataSetObserver observer)83 void registerConversationListObserver(DataSetObserver observer); unregisterConversationListObserver(DataSetObserver observer)84 void unregisterConversationListObserver(DataSetObserver observer); 85 86 /** 87 * Commit any destructive action leave behind items so that it is no longer 88 * possible to undo them. 89 */ commitDestructiveActions(boolean animate)90 void commitDestructiveActions(boolean animate); 91 92 /** 93 * Detect if there are any animations occurring in the conversation list. 94 */ isAnimating()95 boolean isAnimating(); 96 97 /** 98 * Tell the controller that the conversation view has entered detached mode. 99 */ setDetachedMode()100 void setDetachedMode(); 101 102 /** 103 * @return true if the List fragment should start up with list swipes disabled entirely 104 * (with no UI reaction) 105 */ shouldPreventListSwipesEntirely()106 boolean shouldPreventListSwipesEntirely(); 107 108 String CONVERSATION_LIST_SCROLL_POSITION_INDEX = "index"; 109 String CONVERSATION_LIST_SCROLL_POSITION_OFFSET = "offset"; 110 111 /** 112 * Gets the last save scroll position of the conversation list for the specified Folder. 113 * 114 * @return A {@link Bundle} containing two ints, 115 * {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and 116 * {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET}, or <code>null</code> 117 */ getConversationListScrollPosition(String folderUri)118 Parcelable getConversationListScrollPosition(String folderUri); 119 120 /** 121 * Sets the last save scroll position of the conversation list for the specified Folder for 122 * restoration on returning to this list. 123 * 124 * @param savedPosition A {@link Bundle} containing two ints, 125 * {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and 126 * {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET} 127 */ setConversationListScrollPosition(String folderUri, Parcelable savedPosition)128 void setConversationListScrollPosition(String folderUri, Parcelable savedPosition); 129 130 /** 131 * Is the user peeking the current conversation or actually viewing it. 132 */ isCurrentConversationJustPeeking()133 boolean isCurrentConversationJustPeeking(); 134 135 /** 136 * Set up the empty icon depending on the current empty folder. 137 * @param isEmpty if false, then instead of showing the default empty icon, shows the no 138 * selected message icon. 139 * @return true if the icon is setup, false otherwise. 140 */ setupEmptyIconView(Folder folder, boolean isEmpty)141 boolean setupEmptyIconView(Folder folder, boolean isEmpty); 142 } 143