• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.database.DataSetObservable;
21 import android.database.DataSetObserver;
22 import android.widget.ListView;
23 
24 import com.android.mail.providers.Account;
25 import com.android.mail.providers.AccountObserver;
26 import com.android.mail.providers.Folder;
27 import com.android.mail.providers.FolderWatcher;
28 import com.android.mail.utils.VeiledAddressMatcher;
29 
30 /**
31  * This class consolidates account-specific actions taken by a mail activity.
32  */
33 public interface AccountController {
34     /**
35      * Registers to receive changes to the current account, and obtain the current account.
36      */
registerAccountObserver(DataSetObserver observer)37     void registerAccountObserver(DataSetObserver observer);
38 
39     /**
40      * Removes a listener from receiving current account changes.
41      */
unregisterAccountObserver(DataSetObserver observer)42     void unregisterAccountObserver(DataSetObserver observer);
43 
44     /**
45      * Returns the current account in use by the controller. Instead of calling this method,
46      * consider registering for account changes using
47      * {@link AccountObserver#initialize(AccountController)}, which not only provides the current
48      * account, but also updates to the account, in case of settings changes.
49      */
getAccount()50     Account getAccount();
51 
52 
53     /**
54      * Registers to receive changes to the list of accounts, and obtain the current list.
55      */
registerAllAccountObserver(DataSetObserver observer)56     void registerAllAccountObserver(DataSetObserver observer);
57 
58     /**
59      * Removes a listener from receiving account list changes.
60      */
unregisterAllAccountObserver(DataSetObserver observer)61     void unregisterAllAccountObserver(DataSetObserver observer);
62 
63     /** Returns a list of all accounts currently known. */
getAllAccounts()64     Account[] getAllAccounts();
65 
66     /**
67      * Returns an object that can check veiled addresses.
68      * @return
69      */
getVeiledAddressMatcher()70     VeiledAddressMatcher getVeiledAddressMatcher();
71 
72     /**
73      * Handles selecting an account from within the {@link FolderListFragment}.
74      *
75      * @param account the account to change to.
76      */
changeAccount(Account account)77     void changeAccount(Account account);
78 
79     /**
80      * Handles selecting the currently active account from within
81      * the {@link FolderListFragment}.
82      */
switchToDefaultInboxOrChangeAccount(Account account)83     void switchToDefaultInboxOrChangeAccount(Account account);
84 
85     /**
86      * Registers to receive changes upon drawer closing when a changeAccount is called.
87      */
registerDrawerClosedObserver(final DataSetObserver observer)88     void registerDrawerClosedObserver(final DataSetObserver observer);
89 
90     /**
91      * Removes a listener from receiving current account changes.
92      */
unregisterDrawerClosedObserver(final DataSetObserver observer)93     void unregisterDrawerClosedObserver(final DataSetObserver observer);
94 
95     /**
96      * When the {@link FolderListFragment} has a new account ready for changing to,
97      * close the drawer and then wait for {@link DataSetObservable#notifyChanged()}.
98      * @param hasNewFolderOrAccount true if we need to load conversations for a different folder
99      *            or account, false otherwise.
100      */
closeDrawer(boolean hasNewFolderOrAccount, Account nextAccount, Folder nextFolder)101     void closeDrawer(boolean hasNewFolderOrAccount, Account nextAccount, Folder nextFolder);
102 
103     /**
104      * Set the folderWatcher
105      */
setFolderWatcher(FolderWatcher watcher)106     void setFolderWatcher(FolderWatcher watcher);
107 
108     /**
109      * @return <code>true</code> if the drawer pull action is enabled, <code>false</code> otherwise
110      */
isDrawerPullEnabled()111     boolean isDrawerPullEnabled();
112 
113     /**
114      * @return the choice mode to use in the {@link ListView} in the default folder list (subclasses
115      * of {@link FolderListFragment} may override this
116      */
getFolderListViewChoiceMode()117     int getFolderListViewChoiceMode();
118 }
119