Fix auto-refresh of mailboxes.
Removed the ugly doAutoRefresh() and byExplicitUserAction. The intention for these was to supress auto-refresh when the message list opens without any explicit user action, e.g. due to screen rotation. However, now that we have the RefreshManager.isMailboxStale check with 5 minutes duration, this check is not really necessary. Let's just always refresh mailbox if it's stale. Bug 3493134 Change-Id: I6d0365ed7f8092304117d5f619d570b828edf76f
This commit is contained in:
parent
844e5eb80d
commit
4d4bb9a849
@ -136,8 +136,6 @@ public class MessageListFragment extends ListFragment
|
||||
private int mCountTotalAccounts;
|
||||
|
||||
// Misc members
|
||||
private boolean mDoAutoRefresh;
|
||||
|
||||
private boolean mOpenRequested;
|
||||
|
||||
/** Whether "Send all messages" should be shown. */
|
||||
@ -377,7 +375,6 @@ public class MessageListFragment extends ListFragment
|
||||
mIsEasAccount = false;
|
||||
mIsRefreshable = false;
|
||||
mCountTotalAccounts = 0;
|
||||
mDoAutoRefresh = false;
|
||||
mOpenRequested = false;
|
||||
mShowSendCommand = false;
|
||||
|
||||
@ -934,33 +931,18 @@ public class MessageListFragment extends ListFragment
|
||||
return testMultiple(mListAdapter.getSelectedSet(), MessagesAdapter.COLUMN_READ, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by activity to indicate that the user explicitly opened the
|
||||
* mailbox and it needs auto-refresh when it's first shown. TODO:
|
||||
* {@link MessageList} needs to call this as well.
|
||||
*
|
||||
* TODO It's a bit ugly. We can remove this if this fragment "remembers" the current mailbox ID
|
||||
* through configuration changes.
|
||||
*/
|
||||
public void doAutoRefresh() {
|
||||
mDoAutoRefresh = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements a timed refresh of "stale" mailboxes. This should only happen when
|
||||
* multiple conditions are true, including:
|
||||
* Only refreshable mailboxes.
|
||||
* Only when the user explicitly opens the mailbox (not onResume, for example)
|
||||
* Only when the mailbox is "stale" (currently set to 5 minutes since last refresh)
|
||||
* Note we do this even if it's a push account; even on Exchange only inbox can be pushed.
|
||||
*/
|
||||
private void autoRefreshStaleMailbox() {
|
||||
if (!mDoAutoRefresh // Not explicitly open
|
||||
|| !mIsRefreshable // Not refreshable (special box such as drafts, or magic boxes)
|
||||
) {
|
||||
if (!mIsRefreshable) {
|
||||
// Not refreshable (special box such as drafts, or magic boxes)
|
||||
return;
|
||||
}
|
||||
mDoAutoRefresh = false;
|
||||
if (!mRefreshManager.isMailboxStale(mMailboxId)) {
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class MessageListXL extends Activity implements
|
||||
}
|
||||
|
||||
if (accountId != -1) {
|
||||
mFragmentManager.selectAccount(accountId, mailboxId, messageId, true);
|
||||
mFragmentManager.selectAccount(accountId, mailboxId, messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,12 +418,12 @@ public class MessageListXL extends Activity implements
|
||||
private class MailboxListFragmentCallback implements MailboxListFragment.Callback {
|
||||
@Override
|
||||
public void onMailboxSelected(long accountId, long mailboxId) {
|
||||
mFragmentManager.selectMailbox(mailboxId, -1, true);
|
||||
mFragmentManager.selectMailbox(mailboxId, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountSelected(long accountId) {
|
||||
mFragmentManager.selectAccount(accountId, -1, -1, true);
|
||||
mFragmentManager.selectAccount(accountId, -1, -1);
|
||||
loadAccounts(); // This will update the account spinner, and select the account.
|
||||
}
|
||||
|
||||
@ -681,7 +681,7 @@ public class MessageListXL extends Activity implements
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "Account selected: accountId=" + accountId);
|
||||
}
|
||||
mFragmentManager.selectAccount(accountId, -1, -1, true);
|
||||
mFragmentManager.selectAccount(accountId, -1, -1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ class MessageListXLFragmentManager {
|
||||
return;
|
||||
}
|
||||
// selectAccount() calls selectMailbox/Message() if necessary.
|
||||
selectAccount(accountId, mailboxId, messageId, false);
|
||||
selectAccount(accountId, mailboxId, messageId);
|
||||
}
|
||||
|
||||
private void saveMessageListFragmentState() {
|
||||
@ -343,11 +343,8 @@ class MessageListXLFragmentManager {
|
||||
* @param accountId account ID. Must not be -1.
|
||||
* @param mailboxId mailbox ID. Pass -1 to open account's inbox.
|
||||
* @param messageId message ID. Pass -1 to not open a message.
|
||||
* @param byExplicitUserAction set true if the user is explicitly opening the mailbox,
|
||||
* in which case we perform "auto-refresh".
|
||||
*/
|
||||
public void selectAccount(long accountId, long mailboxId, long messageId,
|
||||
boolean byExplicitUserAction) {
|
||||
public void selectAccount(long accountId, long mailboxId, long messageId) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "selectAccount mAccountId=" + accountId);
|
||||
}
|
||||
@ -373,11 +370,11 @@ class MessageListXLFragmentManager {
|
||||
|
||||
if ((accountId == Account.ACCOUNT_ID_COMBINED_VIEW) && (mailboxId == -1)) {
|
||||
// When opening the Combined view, the right pane will be "combined inbox".
|
||||
selectMailbox(Mailbox.QUERY_ALL_INBOXES, -1, false);
|
||||
selectMailbox(Mailbox.QUERY_ALL_INBOXES, -1);
|
||||
} else if (mailboxId == -1) {
|
||||
startInboxLookup();
|
||||
} else {
|
||||
selectMailbox(mailboxId, messageId, byExplicitUserAction);
|
||||
selectMailbox(mailboxId, messageId);
|
||||
}
|
||||
mTargetActivity.onAccountChanged(mAccountId);
|
||||
}
|
||||
@ -409,10 +406,8 @@ class MessageListXLFragmentManager {
|
||||
*
|
||||
* @param mailboxId ID of mailbox
|
||||
* @param messageId message ID. Pass -1 to not open a message.
|
||||
* @param byExplicitUserAction set true if the user is explicitly opening the mailbox,
|
||||
* in which case we perform "auto-refresh".
|
||||
*/
|
||||
public void selectMailbox(long mailboxId, long messageId, boolean byExplicitUserAction) {
|
||||
public void selectMailbox(long mailboxId, long messageId) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "selectMailbox mMailboxId=" + mailboxId);
|
||||
}
|
||||
@ -429,9 +424,6 @@ class MessageListXLFragmentManager {
|
||||
mMessageId = -1;
|
||||
|
||||
// Open mailbox
|
||||
if (byExplicitUserAction) {
|
||||
mMessageListFragment.doAutoRefresh();
|
||||
}
|
||||
mMessageListFragment.openMailbox(mMailboxId);
|
||||
restoreMesasgeListState();
|
||||
|
||||
@ -523,7 +515,7 @@ class MessageListXLFragmentManager {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, " Found inbox");
|
||||
}
|
||||
selectMailbox(mailboxId, -1, true);
|
||||
selectMailbox(mailboxId, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user