First pass at better end-user visibility into what K-9 is doing when we

appear to "sit" while syncing headers.
This commit is contained in:
Jesse Vincent 2010-07-13 23:59:14 +00:00
parent 49c0601390
commit ed86fc8371
6 changed files with 121 additions and 4 deletions

View File

@ -28,6 +28,7 @@
<string name="activity_unread_count">\u0020[<xliff:g id="unread_count">%d</xliff:g>]</string>
<string name="status_loading_account_folder">\u0020(Poll <xliff:g id="account">%s</xliff:g>:<xliff:g id="folder">%s</xliff:g><xliff:g id="progress">%s</xliff:g>)</string>
<string name="status_loading_account_folder_headers">\u0020(Fetching headers <xliff:g id="account">%s</xliff:g>:<xliff:g id="folder">%s</xliff:g><xliff:g id="progress">%s</xliff:g>)</string>
<string name="status_sending_account">\u0020(Sending <xliff:g id="account">%s</xliff:g><xliff:g id="progress">%s</xliff:g>)</string>
<string name="status_processing_account">\u0020(Proc <xliff:g id="account">%s</xliff:g>:<xliff:g id="command">%s</xliff:g><xliff:g id="progress">%s</xliff:g>)</string>
<string name="folder_progress">\u0020<xliff:g id="completed">%s</xliff:g>/<xliff:g id="total">%s</xliff:g></string>

View File

@ -13,6 +13,7 @@ import com.fsck.k9.service.MailService;
public class ActivityListener extends MessagingListener
{
private String mLoadingFolderName = null;
private String mLoadingHeaderFolderName = null;
private String mLoadingAccountDescription = null;
private String mSendingAccountDescription = null;
private int mFolderCompleted = 0;
@ -20,22 +21,36 @@ public class ActivityListener extends MessagingListener
private String mProcessingAccountDescription = null;
private String mProcessingCommandTitle = null;
public String formatHeader(Context context, String activityPrefix, int unreadMessageCount, DateFormat timeFormat)
{
String operation = null;
String progress = null;
if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != null)
if (mLoadingAccountDescription != null
|| mSendingAccountDescription != null
|| mLoadingHeaderFolderName != null
|| mProcessingAccountDescription != null)
{
progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "");
progress = (mFolderTotal > 0 ?
context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "");
if (mLoadingFolderName != null)
if (mLoadingFolderName != null || mLoadingHeaderFolderName != null)
{
String displayName = mLoadingFolderName;
if (K9.INBOX.equalsIgnoreCase(displayName))
{
displayName = context.getString(R.string.special_mailbox_name_inbox);
}
operation = context.getString(R.string.status_loading_account_folder, mLoadingAccountDescription, displayName, progress);
if (mLoadingHeaderFolderName != null)
{
operation = context.getString(R.string.status_loading_account_folder_headers, mLoadingAccountDescription, displayName, progress);
}
else
{
operation = context.getString(R.string.status_loading_account_folder, mLoadingAccountDescription, displayName, progress);
}
}
else if (mSendingAccountDescription != null)
@ -89,6 +104,29 @@ public class ActivityListener extends MessagingListener
mFolderTotal = 0;
}
@Override
public void synchronizeMailboxHeadersStarted(Account account, String folder)
{
mLoadingHeaderFolderName = folder;
}
@Override
public void synchronizeMailboxHeadersProgress(Account account, String folder, int completed, int total)
{
mFolderCompleted = completed;
mFolderTotal = total;
}
@Override
public void synchronizeMailboxHeadersFinished(Account account, String folder,
int total, int completed)
{
mLoadingHeaderFolderName = null;
}
@Override
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{

View File

@ -961,6 +961,34 @@ public class FolderList extends K9ListActivity
}
@Override
public void synchronizeMailboxHeadersStarted(Account account, String folder)
{
super.synchronizeMailboxHeadersStarted(account, folder);
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxHeadersProgress(Account account, String folder, int completed, int total)
{
super.synchronizeMailboxHeadersProgress(account,folder,completed, total);
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxHeadersFinished(Account account, String folder,
int total, int completed)
{
super.synchronizeMailboxHeadersFinished(account,folder, total, completed);
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{

View File

@ -1716,6 +1716,23 @@ public class MessageList
}
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxHeadersProgress(Account account, String folder, int completed, int total)
{
super.synchronizeMailboxHeadersProgress(account,folder,completed, total);
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxHeadersFinished(Account account, String folder,
int total, int completed)
{
super.synchronizeMailboxHeadersFinished(account,folder, total, completed);
mHandler.refreshTitle();
}
@Override
public void synchronizeMailboxFinished(Account account, String folder,

View File

@ -1092,9 +1092,24 @@ public class MessagingController implements Runnable
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "SYNC: About to get messages " + remoteStart + " through " + remoteEnd + " for folder " + folder);
final AtomicInteger headerProgress = new AtomicInteger(0);
for (MessagingListener l : getListeners(listener))
{
l.synchronizeMailboxHeadersStarted(account, folder);
}
remoteMessageArray = remoteFolder.getMessages(remoteStart, remoteEnd, earliestDate, null);
int messageCount = remoteMessageArray.length;
for (Message thisMess : remoteMessageArray)
{
headerProgress.incrementAndGet();
for (MessagingListener l : getListeners(listener))
{
l.synchronizeMailboxHeadersProgress(account, folder, headerProgress.get(), messageCount);
}
Message localMessage = localUidMap.get(thisMess.getUid());
if (localMessage == null || localMessage.olderThan(earliestDate) == false)
{
@ -1106,6 +1121,10 @@ public class MessagingController implements Runnable
Log.v(K9.LOG_TAG, "SYNC: Got " + remoteUidMap.size() + " messages for folder " + folder);
remoteMessageArray = null;
for (MessagingListener l : getListeners(listener))
{
l.synchronizeMailboxHeadersFinished(account, folder, headerProgress.get(), remoteUidMap.size());
}
}
else if (remoteMessageCount < 0)

View File

@ -78,6 +78,20 @@ public class MessagingListener
{
}
public void synchronizeMailboxHeadersStarted(Account account, String folder)
{
}
public void synchronizeMailboxHeadersProgress(Account account, String folder, int completed, int total)
{
}
public void synchronizeMailboxHeadersFinished(Account account, String folder,
int totalMessagesInMailbox, int numNewMessages)
{
}
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{}