mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
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:
parent
49c0601390
commit
ed86fc8371
@ -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>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user