Hide sync options and search icon when appropriate
- hide sync options for mailboxes that aren't actually syncable - hide search icon for any mailboxes that don't have any server counterparts Bug: 5086134 Change-Id: I60d5e5d1225a946464c5ea273c7d4b9299f433e5
This commit is contained in:
parent
330b1273af
commit
37a7469716
|
@ -470,6 +470,31 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
return false; // TYPE_DRAFTS, TYPE_OUTBOX, TYPE_SENT, etc
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether or not this mailbox retrieves its data from the server (as opposed to just
|
||||
* a local mailbox that is never synced).
|
||||
*/
|
||||
public boolean loadsFromServer(String protocol) {
|
||||
if (HostAuth.SCHEME_EAS.equals(protocol)) {
|
||||
return mType != Mailbox.TYPE_DRAFTS
|
||||
&& mType != Mailbox.TYPE_OUTBOX
|
||||
&& mType != Mailbox.TYPE_SEARCH
|
||||
&& mType < Mailbox.TYPE_NOT_SYNCABLE;
|
||||
|
||||
} else if (HostAuth.SCHEME_IMAP.equals(protocol)) {
|
||||
// TODO: actually use a sync flag when creating the mailboxes. Right now we use an
|
||||
// approximation for IMAP.
|
||||
return mType != Mailbox.TYPE_DRAFTS
|
||||
&& mType != Mailbox.TYPE_OUTBOX
|
||||
&& mType != Mailbox.TYPE_SEARCH;
|
||||
|
||||
} else if (HostAuth.SCHEME_POP3.equals(protocol)) {
|
||||
return TYPE_INBOX == mType;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if messages in a mailbox of a type can be replied/forwarded.
|
||||
*/
|
||||
|
|
|
@ -1155,6 +1155,9 @@ public class MessageListFragment extends ListFragment
|
|||
// There's no good way to tell that right now, though.
|
||||
mShowMoveCommand = (mAccount == null || mAccount.supportsMoveMessages(getActivity()))
|
||||
&& (mMailbox == null || mMailbox.canHaveMessagesMoved());
|
||||
|
||||
// Enable mailbox specific actions on the UIController level if needed.
|
||||
mActivity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,7 +97,7 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
|
|||
* The NfcHandler implements Near Field Communication sharing features
|
||||
* whenever the activity is in the foreground.
|
||||
*/
|
||||
private NfcHandler mNfcHandler;
|
||||
private final NfcHandler mNfcHandler;
|
||||
|
||||
/**
|
||||
* The active context for the current MessageList.
|
||||
|
@ -772,26 +772,26 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
|
|||
}
|
||||
|
||||
// Deal with protocol-specific menu options.
|
||||
boolean isEas = false;
|
||||
boolean mailboxHasServerCounterpart = false;
|
||||
boolean accountSearchable = false;
|
||||
long accountId = getActualAccountId();
|
||||
if (accountId > 0) {
|
||||
Account account = Account.restoreAccountWithId(mActivity, accountId);
|
||||
if (account != null) {
|
||||
String protocol = account.getProtocol(mActivity);
|
||||
if (HostAuth.SCHEME_EAS.equals(protocol)) {
|
||||
isEas = true;
|
||||
boolean isEas = false;
|
||||
|
||||
if (isMessageListReady()) {
|
||||
long accountId = getActualAccountId();
|
||||
if (accountId > 0) {
|
||||
Account account = Account.restoreAccountWithId(mActivity, accountId);
|
||||
if (account != null) {
|
||||
String protocol = account.getProtocol(mActivity);
|
||||
isEas = HostAuth.SCHEME_EAS.equals(protocol);
|
||||
Mailbox mailbox = getMessageListFragment().getMailbox();
|
||||
mailboxHasServerCounterpart = mailbox.loadsFromServer(protocol);
|
||||
accountSearchable = (account.mFlags & Account.FLAGS_SUPPORTS_SEARCH) != 0;
|
||||
}
|
||||
accountSearchable = (account.mFlags & Account.FLAGS_SUPPORTS_SEARCH) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Should use an isSyncable call to prevent drafts/outbox from allowing this
|
||||
menu.findItem(R.id.search).setVisible(accountSearchable);
|
||||
// TODO Show only for syncable mailbox as well.
|
||||
menu.findItem(R.id.mailbox_settings).setVisible(isEas
|
||||
&& (getMailboxSettingsMailboxId() != Mailbox.NO_MAILBOX));
|
||||
|
||||
menu.findItem(R.id.search).setVisible(accountSearchable && mailboxHasServerCounterpart);
|
||||
menu.findItem(R.id.mailbox_settings).setVisible(isEas && mailboxHasServerCounterpart);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue