summaryrefslogtreecommitdiff
path: root/src/com/android/mail/ui/ConversationListCallbacks.java
blob: 1b6ca1082a4475648a706d0293ccd3ac4ecd3a87 (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
/*
 * 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.LoaderManager.LoaderCallbacks;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.Parcelable;

import com.android.mail.browse.ConversationCursor;
import com.android.mail.providers.Conversation;
import com.android.mail.providers.Folder;

/**
 * A controller interface that is to receive user initiated events and handle them.
 */
public interface ConversationListCallbacks {
    /**
     * Show the conversation provided here. If the conversation is null, this is a request to pop
     * <em>out</em> of conversation view mode and head back to conversation list mode, or whatever
     * should best show in its place.
     * @param conversation conversation to display, possibly null.
     * @param inLoaderCallbacks whether we are in the scope of a {@link LoaderCallbacks} method
     * (when fragment transactions are disallowed)
     */
    void onConversationSelected(Conversation conversation, boolean inLoaderCallbacks);

    /**
     * Possibly show the conversation provided here depending on implementation.
     * Used mainly by two-pane landscape mode when we are navigating with the keyboard.
     */
    void onConversationFocused(Conversation conversation);

    /**
     * Called whenever CAB mode has been entered via long press or selecting a sender image.
     */
    void onCabModeEntered();

    /**
     * Called whenever CAB mode has been exited.
     */
    void onCabModeExited();

    ConversationCursor getConversationListCursor();

    Conversation getCurrentConversation();
    void setCurrentConversation(Conversation c);
    void onConversationViewSwitched(Conversation c);

    /**
     * Returns whether the initial conversation has begun but not finished loading. If this returns
     * true, you can register to be told when the load in progress finishes
     * ({@link #registerConversationLoadedObserver(DataSetObserver)}).
     * <p>
     * This flag only applies to the first conversation in a set (e.g. when using ViewPager).
     *
     * @return true if the initial conversation has begun but not finished loading
     */
    boolean isInitialConversationLoading();
    void registerConversationLoadedObserver(DataSetObserver observer);
    void unregisterConversationLoadedObserver(DataSetObserver observer);
    /**
     * Coordinates actions that might occur in response to a conversation that has finished loading
     * and is now user-visible.
     */
    void onConversationSeen();

    void registerConversationListObserver(DataSetObserver observer);
    void unregisterConversationListObserver(DataSetObserver observer);

    /**
     * Commit any destructive action leave behind items so that it is no longer
     * possible to undo them.
     */
    void commitDestructiveActions(boolean animate);

    /**
     * Detect if there are any animations occurring in the conversation list.
     */
    boolean isAnimating();

    /**
     * Tell the controller that the conversation view has entered detached mode.
     */
    void setDetachedMode();

    /**
     * @return true if the List fragment should start up with list swipes disabled entirely
     * (with no UI reaction)
     */
    boolean shouldPreventListSwipesEntirely();

    String CONVERSATION_LIST_SCROLL_POSITION_INDEX = "index";
    String CONVERSATION_LIST_SCROLL_POSITION_OFFSET = "offset";

    /**
     * Gets the last save scroll position of the conversation list for the specified Folder.
     *
     * @return A {@link Bundle} containing two ints,
     *         {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and
     *         {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET}, or <code>null</code>
     */
    Parcelable getConversationListScrollPosition(String folderUri);

    /**
     * Sets the last save scroll position of the conversation list for the specified Folder for
     * restoration on returning to this list.
     *
     * @param savedPosition A {@link Bundle} containing two ints,
     *            {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and
     *            {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET}
     */
    void setConversationListScrollPosition(String folderUri, Parcelable savedPosition);

    /**
     * Is the user peeking the current conversation or actually viewing it.
     */
    boolean isCurrentConversationJustPeeking();

    /**
     * Set up the empty icon depending on the current empty folder.
     * @param isEmpty if false, then instead of showing the default empty icon, shows the no
     *   selected message icon.
     * @return true if the icon is setup, false otherwise.
     */
    boolean setupEmptyIconView(Folder folder, boolean isEmpty);
}