AccountController.java revision 8bcb7c5c37ffd5a1a0c5f4efbcab084830d5e033
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 18package com.android.mail.ui; 19 20import android.database.DataSetObservable; 21import android.database.DataSetObserver; 22 23import com.android.mail.providers.Account; 24import com.android.mail.providers.AccountObserver; 25import com.android.mail.utils.VeiledAddressMatcher; 26 27/** 28 * This class consolidates account-specific actions taken by a mail activity. 29 */ 30public interface AccountController { 31 /** 32 * Registers to receive changes to the current account, and obtain the current account. 33 */ 34 void registerAccountObserver(DataSetObserver observer); 35 36 /** 37 * Removes a listener from receiving current account changes. 38 */ 39 void unregisterAccountObserver(DataSetObserver observer); 40 41 /** 42 * Returns the current account in use by the controller. Instead of calling this method, 43 * consider registering for account changes using 44 * {@link AccountObserver#initialize(AccountController)}, which not only provides the current 45 * account, but also updates to the account, in case of settings changes. 46 */ 47 Account getAccount(); 48 49 50 /** 51 * Registers to receive changes to the list of accounts, and obtain the current list. 52 */ 53 void registerAllAccountObserver(DataSetObserver observer); 54 55 /** 56 * Removes a listener from receiving account list changes. 57 */ 58 void unregisterAllAccountObserver(DataSetObserver observer); 59 60 /** Returns a list of all accounts currently known. */ 61 Account[] getAllAccounts(); 62 63 /** 64 * Returns an object that can check veiled addresses. 65 * @return 66 */ 67 VeiledAddressMatcher getVeiledAddressMatcher(); 68 69 /** 70 * Handles selecting an account from within the {@link FolderListFragment}. 71 * 72 * @param account the account to change to. 73 */ 74 void changeAccount(Account account); 75 76 /** 77 * Handles selecting the currently active account from within 78 * the {@link FolderListFragment}. 79 */ 80 void switchToDefaultInboxOrChangeAccount(Account account); 81 82 /** 83 * Registers to receive changes upon drawer closing when a changeAccount is called. 84 */ 85 void registerDrawerClosedObserver(final DataSetObserver observer); 86 87 /** 88 * Removes a listener from receiving current account changes. 89 */ 90 void unregisterDrawerClosedObserver(final DataSetObserver observer); 91 92 /** 93 * When the {@link FolderListFragment} has a new account ready for changing to, 94 * close the drawer and then wait for {@link DataSetObservable#notifyChanged()}. 95 * @param hasNewFolderOrAccount true if we need to load conversations for a different folder 96 * or account, false otherwise. 97 */ 98 void closeDrawer(boolean hasNewFolderOrAccount); 99} 100