From 921b022fb53a7989743edd7cb761f1ade206e930 Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Sun, 20 Dec 2009 00:02:46 +0000 Subject: [PATCH] Enhanced header in Accounts, MessageList and Folder to show the unread count, scoped for the Activity, the in-progress operation, the account on which the operation is in progress, the folder for the operation, when appropriate, and the progress of the operation, when it applies to multiple items. For the MessageList, also use the determinate progress bar to show progress for synchronization of the folder being displayed. Fixes Issue 924. Also, a minor change that might help with Issue 913, by putting the insertion of the pending command into a background thread. --- res/values/strings.xml | 31 +- src/com/fsck/k9/MessagingController.java | 277 +++++++++++++----- src/com/fsck/k9/MessagingListener.java | 15 + src/com/fsck/k9/activity/Accounts.java | 120 ++++++-- .../fsck/k9/activity/ActivityListener.java | 145 +++++++++ src/com/fsck/k9/activity/FolderList.java | 195 ++++++------ src/com/fsck/k9/activity/MessageList.java | 203 ++++++++----- src/com/fsck/k9/service/MailService.java | 4 - src/com/fsck/k9/service/PollService.java | 4 +- 9 files changed, 720 insertions(+), 274 deletions(-) create mode 100644 src/com/fsck/k9/activity/ActivityListener.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 0f434b928..000cfaa16 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12,10 +12,22 @@ Allows this application to read your Email attachments. About %s - Accounts + Accounts + %s + + %s:%s + Compose Debug Choose Folder + + %s%s%s + + \u0020[%d] + \u0020(Poll %s:%s%s) + \u0020(Sending %s%s) + \u0020(Proc %s:%s%s) + \u0020%s/%s Next @@ -86,12 +98,14 @@ (No subject) - Loading\u2026 + Poll%s + (Poll %s%s) Loading messages\u2026 Connection error Message not found Error - Sending\u2026 + Sending + Retry loading more messages Load up @@ -190,8 +204,15 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Recent messages from all accounts All Mail Inbox - %s (%d) - Load more messages + %s:%s + %s + %s + %s + %s + + + +Load more messages To Cc diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java index f526920cc..d05f9ab3e 100644 --- a/src/com/fsck/k9/MessagingController.java +++ b/src/com/fsck/k9/MessagingController.java @@ -238,47 +238,6 @@ public class MessagingController implements Runnable } } - public void log(String logmess) - { - if (K9.DEBUG) - { - Log.d(K9.LOG_TAG, logmess); - } - if (K9.logFile != null) - { - FileOutputStream fos = null; - try - { - File logFile = new File(K9.logFile); - fos = new FileOutputStream(logFile, true); - PrintStream ps = new PrintStream(fos); - ps.println(new Date() + ":" + K9.LOG_TAG + ":" + logmess); - ps.flush(); - ps.close(); - fos.flush(); - fos.close(); - } - catch (Exception e) - { - Log.e(K9.LOG_TAG, "Unable to log message '" + logmess + "'", e); - } - finally - { - if (fos != null) - { - try - { - fos.close(); - } - catch (Exception e) - { - - } - } - } - } - } - /** * Gets or creates the singleton instance of MessagingController. Application is used to * provide a Context to classes that need it. @@ -764,7 +723,6 @@ public class MessagingController implements Runnable } String debugLine = "Synchronizing folder " + account.getDescription() + ":" + folder; Log.i(K9.LOG_TAG, debugLine); - log(debugLine); for (MessagingListener l : getListeners()) { @@ -780,8 +738,8 @@ public class MessagingController implements Runnable { if (K9.DEBUG) { - Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for folder " + - account.getDescription() + ":" + folder); + Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " + + account.getDescription() ); } try { @@ -974,7 +932,7 @@ public class MessagingController implements Runnable localFolder.close(false); if (K9.DEBUG) { - log("Done synchronizing folder " + + Log.d(K9.LOG_TAG, "Done synchronizing folder " + account.getDescription() + ":" + folder + " @ " + new Date() + " with " + newMessages + " new messages"); } @@ -1043,19 +1001,24 @@ public class MessagingController implements Runnable rootMessage); } addErrorMessage(account, e); - log("Failed synchronizing folder " + + Log.e(K9.LOG_TAG, "Failed synchronizing folder " + account.getDescription() + ":" + folder + " @ " + new Date()); } } - private void setLocalUnreadCountToRemote(LocalFolder localFolder, Folder remoteFolder, int newMessageCount) throws MessagingException + private int setLocalUnreadCountToRemote(LocalFolder localFolder, Folder remoteFolder, int newMessageCount) throws MessagingException { int remoteUnreadMessageCount = remoteFolder.getUnreadMessageCount(); if (remoteUnreadMessageCount != -1) { localFolder.setUnreadMessageCount(remoteUnreadMessageCount); + return remoteUnreadMessageCount; + } + else + { + return localFolder.getMessageCount(); } } @@ -1141,6 +1104,13 @@ public class MessagingController implements Runnable } } } + + final AtomicInteger progress = new AtomicInteger(0); + final int todo = unsyncedMessages.size() + syncFlagMessages.size(); + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxProgress(account, folder, progress.get(), todo); + } Log.i(K9.LOG_TAG, "SYNC: Have " + unsyncedMessages.size() + " unsynced messages"); @@ -1304,10 +1274,12 @@ public class MessagingController implements Runnable Log.v(K9.LOG_TAG, "About to notify listeners that we got a new small message " + account + ":" + folder + ":" + message.getUid()); } + progress.incrementAndGet(); // Update the listener with what we've found for (MessagingListener l : getListeners()) { l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); + l.synchronizeMailboxProgress(account, folder, progress.get(), todo); if (!localMessage.isSet(Flag.SEEN)) { l.synchronizeMailboxNewMessage(account, folder, localMessage); @@ -1422,10 +1394,12 @@ public class MessagingController implements Runnable + account + ":" + folder + ":" + message.getUid()); } // Update the listener with what we've found + progress.incrementAndGet(); for (MessagingListener l : getListeners()) { Message localMessage = localFolder.getMessage(message.getUid()); l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); + l.synchronizeMailboxProgress(account, folder, progress.get(), todo); if (!localMessage.isSet(Flag.SEEN)) { l.synchronizeMailboxNewMessage(account, folder, localMessage); @@ -1472,6 +1446,11 @@ public class MessagingController implements Runnable } } } + progress.incrementAndGet(); + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxProgress(account, folder, progress.get(), todo); + } } } Log.i(K9.LOG_TAG, "SYNC: Synced remote messages for folder " + folder + ", " + newMessages.get() + " new messages"); @@ -1571,13 +1550,27 @@ public class MessagingController implements Runnable } }); } - + private void processPendingCommandsSynchronous(Account account) throws MessagingException { LocalStore localStore = (LocalStore) Store.getInstance( account.getLocalStoreUri(), mApplication); ArrayList commands = localStore.getPendingCommands(); + + int progress = 0; + int todo = commands.size(); + if (todo == 0) + { + return; + } + + for (MessagingListener l : getListeners()) + { + l.pendingCommandsProcessing(account); + l.synchronizeMailboxProgress(account, null, progress, todo); + } + PendingCommand processingCommand = null; try { @@ -1588,6 +1581,12 @@ public class MessagingController implements Runnable { Log.d(K9.LOG_TAG, "Processing pending command '" + command + "'"); } + String[] components = command.command.split("\\."); + String commandTitle = components[components.length - 1]; + for (MessagingListener l : getListeners()) + { + l.pendingCommandStarted(account, commandTitle); + } /* * We specifically do not catch any exceptions here. If a command fails it is * most likely due to a server or IO error and it must be retried before any @@ -1642,6 +1641,15 @@ public class MessagingController implements Runnable throw me; } } + finally + { + progress++; + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxProgress(account, null, progress, todo); + l.pendingCommandCompleted(account, commandTitle); + } + } } } catch (MessagingException me) @@ -1650,6 +1658,13 @@ public class MessagingController implements Runnable Log.e(K9.LOG_TAG, "Could not process command '" + processingCommand + "'", me); throw me; } + finally + { + for (MessagingListener l : getListeners()) + { + l.pendingCommandsFinished(account); + } + } } /** @@ -1923,21 +1938,27 @@ public class MessagingController implements Runnable } - private void queueSetFlag(Account account, String folderName, String newState, String flag, String[] uids) + private void queueSetFlag(final Account account, final String folderName, final String newState, final String flag, final String[] uids) { - PendingCommand command = new PendingCommand(); - command.command = PENDING_COMMAND_SET_FLAG_BULK; - int length = 3 + uids.length; - command.arguments = new String[length]; - command.arguments[0] = folderName; - command.arguments[1] = newState; - command.arguments[2] = flag; - for (int i = 0; i < uids.length; i++) + put("queueSetFlag " + account.getDescription() + ":" + folderName, null, new Runnable() { - command.arguments[3 + i] = uids[i]; - } - queuePendingCommand(account, command); - processPendingCommands(account); + public void run() + { + PendingCommand command = new PendingCommand(); + command.command = PENDING_COMMAND_SET_FLAG_BULK; + int length = 3 + uids.length; + command.arguments = new String[length]; + command.arguments[0] = folderName; + command.arguments[1] = newState; + command.arguments[2] = flag; + for (int i = 0; i < uids.length; i++) + { + command.arguments[3 + i] = uids[i]; + } + queuePendingCommand(account, command); + processPendingCommands(account); + } + }); } /** * Processes a pending mark read or unread command. @@ -2143,7 +2164,7 @@ public class MessagingController implements Runnable localFolder.setUnreadMessageCount(0); for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, folder); + l.folderStatusChanged(account, folder, 0); } try { @@ -2225,7 +2246,7 @@ public class MessagingController implements Runnable for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, localFolder.getName()); + l.folderStatusChanged(account, localFolder.getName(), localFolder.getUnreadMessageCount()); } } @@ -2352,7 +2373,7 @@ public class MessagingController implements Runnable for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, folderName); + l.folderStatusChanged(account, folderName, localFolder.getUnreadMessageCount()); } if (account.getErrorFolderName().equals(folderName)) @@ -2922,6 +2943,12 @@ public class MessagingController implements Runnable Message[] localMessages = localFolder.getMessages(null); boolean anyFlagged = false; + int progress = 0; + int todo = localMessages.length; + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxProgress(account, account.getSentFolderName(), progress, todo); + } /* * The profile we will use to pull all of the content * for a given local message into memory for sending. @@ -2972,7 +2999,11 @@ public class MessagingController implements Runnable transport.sendMessage(message); message.setFlag(Flag.X_SEND_IN_PROGRESS, false); message.setFlag(Flag.SEEN, true); - + progress++; + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxProgress(account, account.getSentFolderName(), progress, todo); + } Log.i(K9.LOG_TAG, "Moving sent message to folder '" + account.getSentFolderName() + "' (" + localSentFolder.getId() + ") "); localFolder.moveMessages( new Message[] { message }, @@ -3117,8 +3148,35 @@ public class MessagingController implements Runnable }; - putBackground("getAccountUnread:" + account.getDescription(), l, unreadRunnable); + put("getAccountUnread:" + account.getDescription(), l, unreadRunnable); } + + public void getFolderUnreadMessageCount(final Account account, final String folderName, + final MessagingListener l) + { + Runnable unreadRunnable = new Runnable() + { + public void run() + { + + int unreadMessageCount = 0; + try + { + Folder localFolder = (Folder) Store.getInstance(account.getLocalStoreUri(), mApplication).getFolder(folderName); + unreadMessageCount = localFolder.getUnreadMessageCount(); + } + catch (MessagingException me) + { + Log.e(K9.LOG_TAG, "Count not get unread count for account " + account.getDescription(), me); + } + l.folderStatusChanged(account, folderName, unreadMessageCount); + } + }; + + + put("getFolderUnread:" + account.getDescription() + ":" + folderName, l, unreadRunnable); + } + public int moveMessages(final Account account, final String srcFolder, final Message[] messages, final String destFolder, final MessagingListener listener) @@ -3359,7 +3417,7 @@ public class MessagingController implements Runnable for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, account.getTrashFolderName()); + l.folderStatusChanged(account, account.getTrashFolderName(), localFolder.getUnreadMessageCount()); } if (K9.DEBUG) @@ -3958,7 +4016,7 @@ public class MessagingController implements Runnable } } - private boolean modeMismatch(Account.FolderMode aMode, Folder.FolderClass fMode) + public boolean modeMismatch(Account.FolderMode aMode, Folder.FolderClass fMode) { if (aMode == Account.FolderMode.NONE || (aMode == Account.FolderMode.FIRST_CLASS && @@ -4191,7 +4249,7 @@ public class MessagingController implements Runnable localFolder.open(OpenMode.READ_WRITE); int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly); - setLocalUnreadCountToRemote(localFolder, remoteFolder, messages.size()); + int unreadMessageCount = setLocalUnreadCountToRemote(localFolder, remoteFolder, messages.size()); localFolder.setLastPush(System.currentTimeMillis()); localFolder.setStatus(null); @@ -4201,7 +4259,7 @@ public class MessagingController implements Runnable for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, remoteFolder.getName()); + l.folderStatusChanged(account, remoteFolder.getName(), unreadMessageCount); } } @@ -4260,10 +4318,15 @@ public class MessagingController implements Runnable MemorizingState syncingState = null; MemorizingState sendingState = null; MemorizingState pushingState = null; + MemorizingState processingState = null; String failureMessage = null; int syncingTotalMessagesInMailbox; int syncingNumNewMessages; + + int folderCompleted = 0; + int folderTotal = 0; + String processingCommandTitle = null; Memory(Account nAccount, String nFolderName) { @@ -4301,6 +4364,8 @@ public class MessagingController implements Runnable { Memory memory = getMemory(account, folder); memory.syncingState = MemorizingState.STARTED; + memory.folderCompleted = 0; + memory.folderTotal = 0; } public synchronized void synchronizeMailboxFinished(Account account, String folder, @@ -4327,6 +4392,7 @@ public class MessagingController implements Runnable Memory syncStarted = null; Memory sendStarted = null; + Memory processingStarted = null; for (Memory memory : memories.values()) { @@ -4376,15 +4442,48 @@ public class MessagingController implements Runnable break; } } + if (memory.processingState != null) + { + switch (memory.processingState) + { + case STARTED: + processingStarted = memory; + break; + case FINISHED: + case FAILED: + other.pendingCommandsFinished(memory.account); + break; + } + } } - + Memory somethingStarted = null; if (syncStarted != null) { other.synchronizeMailboxStarted(syncStarted.account, syncStarted.folderName); + somethingStarted = syncStarted; } if (sendStarted != null) { other.sendPendingMessagesStarted(sendStarted.account); + somethingStarted = sendStarted; + } + if (processingStarted != null) + { + other.pendingCommandsProcessing(processingStarted.account); + if (processingStarted.processingCommandTitle != null) + { + other.pendingCommandStarted(processingStarted.account, processingStarted.processingCommandTitle); + + } + else + { + other.pendingCommandCompleted(processingStarted.account, processingStarted.processingCommandTitle); + } + somethingStarted = processingStarted; + } + if (somethingStarted != null && somethingStarted.folderTotal > 0) + { + other.synchronizeMailboxProgress(somethingStarted.account, somethingStarted.folderName, somethingStarted.folderCompleted, somethingStarted.folderTotal); } } @@ -4400,6 +4499,8 @@ public class MessagingController implements Runnable { Memory memory = getMemory(account, null); memory.sendingState = MemorizingState.STARTED; + memory.folderCompleted = 0; + memory.folderTotal = 0; } public synchronized void sendPendingMessagesCompleted(Account account) @@ -4413,6 +4514,40 @@ public class MessagingController implements Runnable Memory memory = getMemory(account, null); memory.sendingState = MemorizingState.FAILED; } + + + public void synchronizeMailboxProgress(Account account, String folderName, int completed, int total) + { + Memory memory = getMemory(account, folderName); + memory.folderCompleted = completed; + memory.folderTotal = total; + } + + + public void pendingCommandsProcessing(Account account) + { + Memory memory = getMemory(account, null); + memory.processingState = MemorizingState.STARTED; + memory.folderCompleted = 0; + memory.folderTotal = 0; + } + public void pendingCommandsFinished(Account account) + { + Memory memory = getMemory(account, null); + memory.processingState = MemorizingState.FINISHED; + } + public void pendingCommandStarted(Account account, String commandTitle) + { + Memory memory = getMemory(account, null); + memory.processingCommandTitle = commandTitle; + } + + public void pendingCommandCompleted(Account account, String commandTitle) + { + Memory memory = getMemory(account, null); + memory.processingCommandTitle = null; + } + } diff --git a/src/com/fsck/k9/MessagingListener.java b/src/com/fsck/k9/MessagingListener.java index 98f726cf2..afda0f371 100644 --- a/src/com/fsck/k9/MessagingListener.java +++ b/src/com/fsck/k9/MessagingListener.java @@ -73,6 +73,9 @@ public class MessagingListener public void synchronizeMailboxStarted(Account account, String folder) { } + + public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) + {} public void synchronizeMailboxNewMessage(Account account, String folder, Message message) { @@ -151,6 +154,10 @@ public class MessagingListener { } + public void folderStatusChanged(Account account, String folderName, int unreadMessageCount) + { + } + public void folderStatusChanged(Account account, String folderName) { } @@ -190,6 +197,14 @@ public class MessagingListener String reason) { } + + public void pendingCommandsProcessing(Account account) {} + public void pendingCommandsFinished(Account account) {} + public void pendingCommandStarted(Account account, String commandTitle) + {} + + public void pendingCommandCompleted(Account account, String commandTitle) + {} /** * General notification messages subclasses can override to be notified that the controller diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 47ef6b37e..25b5e4812 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -35,7 +35,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC private ConcurrentHashMap pendingWork = new ConcurrentHashMap(); private Account mSelectedContextAccount; - + private int mUnreadMessageCount = 0; + private AccountsHandler mHandler = new AccountsHandler(); private AccountsAdapter mAdapter; @@ -52,13 +53,19 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC private static final int MSG_ACCOUNT_SIZE_CHANGED = 2; private static final int MSG_WORKING_ACCOUNT = 3; private static final int MSG_PROGRESS = 4; - private static final int MSG_FOLDER_SYNCING = 5; private static final int MSG_DEFINITE_PROGRESS = 6; + private static final int MSG_SET_TITLE = 7; public void handleMessage(android.os.Message msg) { switch (msg.what) { + case MSG_SET_TITLE: + { + this.setViewTitle(); + break; + } + case DATA_CHANGED: if (mAdapter != null) { @@ -88,19 +95,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC toast.show(); break; } - case MSG_FOLDER_SYNCING: - { - String folderName = (String)((Object[]) msg.obj)[0]; - String dispString; - dispString = getString(R.string.accounts_title); - if (folderName != null) - { - dispString += " (" + getString(R.string.status_loading) - + folderName + ")"; - } - setTitle(dispString); - break; - } case MSG_PROGRESS: setProgressBarIndeterminateVisibility(msg.arg1 != 0); //setProgressBarVisibility(msg.arg1 != 0); @@ -112,6 +106,18 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC super.handleMessage(msg); } } + private void setViewTitle() + { + String dispString = mListener.formatHeader(Accounts.this, getString(R.string.accounts_title), mUnreadMessageCount); + + setTitle(dispString); + } + public void refreshTitle() + { + android.os.Message msg = new android.os.Message(); + msg.what = MSG_SET_TITLE; + sendMessage(msg); + } public void dataChanged() { @@ -154,22 +160,22 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC msg.arg1 = progress ; sendMessage(msg); } - public void folderSyncing(String folder) - { - android.os.Message msg = new android.os.Message(); - msg.what = MSG_FOLDER_SYNCING; - msg.obj = new String[] { folder }; - sendMessage(msg); - } - } - MessagingListener mListener = new MessagingListener() + ActivityListener mListener = new ActivityListener() { @Override public void accountStatusChanged(Account account, int unreadMessageCount) { + Integer oldUnreadMessageCountInteger = unreadMessageCounts.get(account.getUuid()); + int oldUnreadMessageCount = 0; + if (oldUnreadMessageCountInteger != null) + { + oldUnreadMessageCount = oldUnreadMessageCountInteger; + } + unreadMessageCounts.put(account.getUuid(), unreadMessageCount); + mUnreadMessageCount += unreadMessageCount - oldUnreadMessageCount; mHandler.dataChanged(); pendingWork.remove(account); @@ -177,6 +183,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC if (pendingWork.isEmpty()) { mHandler.progress(Window.PROGRESS_END); + mHandler.refreshTitle(); } else { @@ -200,28 +207,82 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC int totalMessagesInMailbox, int numNewMessages) { + super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener); mHandler.progress(false); - mHandler.folderSyncing(null); + + mHandler.refreshTitle(); } @Override public void synchronizeMailboxStarted(Account account, String folder) { + super.synchronizeMailboxStarted(account, folder); mHandler.progress(true); - mHandler.folderSyncing(account.getDescription() - + getString(R.string.notification_bg_title_separator) + folder); + mHandler.refreshTitle(); + } + + public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) + { + super.synchronizeMailboxProgress(account, folder, completed, total); + mHandler.refreshTitle(); } @Override public void synchronizeMailboxFailed(Account account, String folder, String message) { + super.synchronizeMailboxFailed(account, folder, message); mHandler.progress(false); - mHandler.folderSyncing(null); + mHandler.refreshTitle(); + + } + + @Override + public void sendPendingMessagesStarted(Account account) + { + super.sendPendingMessagesStarted(account); + mHandler.refreshTitle(); + } + + @Override + public void sendPendingMessagesCompleted(Account account) + { + super.sendPendingMessagesCompleted(account); + mHandler.refreshTitle(); } + + @Override + public void sendPendingMessagesFailed(Account account) + { + super.sendPendingMessagesFailed(account); + mHandler.refreshTitle(); + } + + public void pendingCommandsProcessing(Account account) + { + super.pendingCommandsProcessing(account); + mHandler.refreshTitle(); + } + public void pendingCommandsFinished(Account account) + { + super.pendingCommandsFinished(account); + mHandler.refreshTitle(); + } + public void pendingCommandStarted(Account account, String commandTitle) + { + super.pendingCommandStarted(account, commandTitle); + mHandler.refreshTitle(); + } + public void pendingCommandCompleted(Account account, String commandTitle) + { + super.pendingCommandCompleted(account, commandTitle); + mHandler.refreshTitle(); + } + + }; private static String UNREAD_MESSAGE_COUNTS = "unreadMessageCounts"; @@ -324,6 +385,9 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC mHandler.progress(Window.PROGRESS_START); } pendingWork.clear(); + mUnreadMessageCount = 0; + unreadMessageCounts.clear(); + for (Account account : accounts) { pendingWork.put(account, "true"); diff --git a/src/com/fsck/k9/activity/ActivityListener.java b/src/com/fsck/k9/activity/ActivityListener.java new file mode 100644 index 000000000..345b7cae1 --- /dev/null +++ b/src/com/fsck/k9/activity/ActivityListener.java @@ -0,0 +1,145 @@ +package com.fsck.k9.activity; + +import android.content.Context; + +import com.fsck.k9.Account; +import com.fsck.k9.K9; +import com.fsck.k9.MessagingListener; +import com.fsck.k9.R; + +public class ActivityListener extends MessagingListener +{ + private String mLoadingFolderName = null; + private String mLoadingAccountDescription = null; + private String mSendingAccountDescription = null; + private int mFolderCompleted = 0; + private int mFolderTotal = 0; + private String mProcessingAccountDescription = null; + private String mProcessingCommandTitle = null; + + public String formatHeader(Context context, String activityPrefix, int unreadMessageCount) + { + String operation = null; + String progress = null; + if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != null) + { + progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "" ); + + if (mLoadingFolderName != 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); + } + + else if (mSendingAccountDescription != null) + { + operation = context.getString(R.string.status_sending_account, mSendingAccountDescription, progress); + } + else if (mProcessingAccountDescription != null) + { + operation = context.getString(R.string.status_processing_account, mProcessingAccountDescription, + mProcessingCommandTitle != null ? mProcessingCommandTitle : "", + progress); + } + } + else + { + operation = ""; + } + + return context.getString(R.string.activity_header_format, activityPrefix, + (unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""), + operation); + + + } + + @Override + public void synchronizeMailboxFinished( + Account account, + String folder, + int totalMessagesInMailbox, + int numNewMessages) + { + mLoadingAccountDescription = null; + mLoadingFolderName = null; + } + + @Override + public void synchronizeMailboxStarted(Account account, String folder) + { + mLoadingAccountDescription = account.getDescription(); + mLoadingFolderName = folder; + mFolderCompleted = 0; + mFolderTotal = 0; + } + + public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) + { + mFolderCompleted = completed; + mFolderTotal = total; + } + + @Override + public void synchronizeMailboxFailed(Account account, String folder, + String message) + { + mLoadingAccountDescription = null; + mLoadingFolderName = null; + + } + + @Override + public void sendPendingMessagesStarted(Account account) + { + mSendingAccountDescription = account.getDescription(); + } + + @Override + public void sendPendingMessagesCompleted(Account account) + { + mSendingAccountDescription = null; + } + + + @Override + public void sendPendingMessagesFailed(Account account) + { + mSendingAccountDescription = null; + } + public void pendingCommandsProcessing(Account account) + { + mProcessingAccountDescription = account.getDescription(); + mFolderCompleted = 0; + mFolderTotal = 0; + } + public void pendingCommandsFinished(Account account) + { + mProcessingAccountDescription = null; + } + public void pendingCommandStarted(Account account, String commandTitle) + { + mProcessingCommandTitle = commandTitle; + } + + public void pendingCommandCompleted(Account account, String commandTitle) + { + mProcessingCommandTitle = null; + } + + public int getFolderCompleted() + { + return mFolderCompleted; + } + + public int getFolderTotal() + { + return mFolderTotal; + } + + +} diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 04264fac9..602ba085d 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -63,6 +63,9 @@ public class FolderList extends K9ListActivity private FolderListHandler mHandler = new FolderListHandler(); private boolean mStartup = false; + + private int mUnreadMessageCount = 0; + class FolderListHandler extends Handler { @@ -70,17 +73,22 @@ public class FolderList extends K9ListActivity private static final int MSG_PROGRESS = 2; private static final int MSG_DATA_CHANGED = 3; private static final int MSG_FOLDER_LOADING = 7; - private static final int MSG_FOLDER_SYNCING = 18; - private static final int MSG_SENDING_OUTBOX = 19; private static final int MSG_ACCOUNT_SIZE_CHANGED = 20; private static final int MSG_WORKING_ACCOUNT = 21; private static final int MSG_NEW_FOLDERS = 22; + private static final int MSG_SET_TITLE = 23; + @Override public void handleMessage(android.os.Message msg) { switch (msg.what) { + case MSG_SET_TITLE: + { + this.setViewTitle(); + break; + } case MSG_NEW_FOLDERS: ArrayList newFolders = (ArrayList)msg.obj; mAdapter.mFolders.clear(); @@ -126,44 +134,27 @@ public class FolderList extends K9ListActivity toast.show(); break; } - - - case MSG_FOLDER_SYNCING: - { - String folderName = (String)((Object[]) msg.obj)[0]; - String dispString; - dispString = mAccount.getDescription(); - - if (folderName != null) - { - dispString += " (" + getString(R.string.status_loading) + folderName + ")"; - } - - setTitle(dispString); - - break; - } - - case MSG_SENDING_OUTBOX: - { - boolean sending = (msg.arg1 != 0); - String dispString; - dispString = mAccount.getDescription(); - - if (sending) - { - dispString += " (" + getString(R.string.status_sending) + ")"; - } - - setTitle(dispString); - - break; - } - default: super.handleMessage(msg); } } + private void setViewTitle() + { + String dispString = mAdapter.mListener.formatHeader(FolderList.this, getString(R.string.folder_list_title, mAccount.getDescription()), mUnreadMessageCount); + + setTitle(dispString); + + + setTitle(dispString); + } + + public void refreshTitle() + { + android.os.Message msg = new android.os.Message(); + msg.what = MSG_SET_TITLE; + sendMessage(msg); + } + public void newFolders(ArrayList newFolders) { @@ -210,22 +201,6 @@ public class FolderList extends K9ListActivity { sendEmptyMessage(MSG_DATA_CHANGED); } - - public void folderSyncing(String folder) - { - android.os.Message msg = new android.os.Message(); - msg.what = MSG_FOLDER_SYNCING; - msg.obj = new String[] { folder }; - sendMessage(msg); - } - - public void sendingOutbox(boolean sending) - { - android.os.Message msg = new android.os.Message(); - msg.what = MSG_SENDING_OUTBOX; - msg.arg1 = sending ? 1 : 0; - sendMessage(msg); - } } /** @@ -421,7 +396,8 @@ public class FolderList extends K9ListActivity MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener); mAccount.refresh(Preferences.getPreferences(this)); - + MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener); + onRefresh(!REFRESH_REMOTE); NotificationManager notifMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); @@ -502,16 +478,7 @@ public class FolderList extends K9ListActivity { mHandler.dataChanged(); - MessagingListener listener = new MessagingListener() - { - @Override - public void controllerCommandCompleted(boolean moreToDo) - { - Log.v(K9.LOG_TAG, "Empty Trash background task completed"); - } - }; - - MessagingController.getInstance(getApplication()).emptyTrash(account, listener); + MessagingController.getInstance(getApplication()).emptyTrash(account, null); } private void checkMail(final Account account) @@ -789,8 +756,14 @@ public class FolderList extends K9ListActivity return true; } - private MessagingListener mListener = new MessagingListener() + private ActivityListener mListener = new ActivityListener() { + @Override + public void accountStatusChanged(Account account, int unreadMessageCount) + { + mUnreadMessageCount = unreadMessageCount; + mHandler.refreshTitle(); + } @Override public void listFoldersStarted(Account account) @@ -874,14 +847,24 @@ public class FolderList extends K9ListActivity { holder = (FolderInfoHolder) getItem(folderIndex); } + int unreadMessageCount = 0; + try + { + unreadMessageCount = folder.getUnreadMessageCount(); + } + catch (Exception e) + { + Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":" + + folder.getName()); + } if (holder == null) { - holder = new FolderInfoHolder(folder); + holder = new FolderInfoHolder(folder, unreadMessageCount); } else { - holder.populate(folder); + holder.populate(folder, unreadMessageCount); } @@ -889,11 +872,14 @@ public class FolderList extends K9ListActivity } Collections.sort(newFolders); mHandler.newFolders(newFolders); + mHandler.refreshTitle(); } public void synchronizeMailboxStarted(Account account, String folder) { + super.synchronizeMailboxStarted(account, folder); + mHandler.refreshTitle(); if (!account.equals(mAccount)) { return; @@ -901,23 +887,37 @@ public class FolderList extends K9ListActivity mHandler.progress(true); mHandler.folderLoading(folder, true); - mHandler.folderSyncing(folder); + mHandler.dataChanged(); + + } + + @Override + public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) + { + super.synchronizeMailboxProgress(account, folder, completed, total); + mHandler.refreshTitle(); + if (true) return; + if (!account.equals(mAccount)) + { + return; + } mHandler.dataChanged(); } - + @Override public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) { + super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); + mHandler.refreshTitle(); if (!account.equals(mAccount)) { return; } mHandler.progress(false); mHandler.folderLoading(folder, false); - // mHandler.folderStatus(folder, null); - mHandler.folderSyncing(null); refreshFolder(account, folder); + } @@ -929,12 +929,13 @@ public class FolderList extends K9ListActivity if (account != null && folderName != null) { Folder localFolder = (Folder) Store.getInstance(account.getLocalStoreUri(), getApplication()).getFolder(folderName); + int unreadMessageCount = localFolder.getUnreadMessageCount(); if (localFolder != null) { FolderInfoHolder folderHolder = getFolder(folderName); if (folderHolder != null) { - folderHolder.populate(localFolder); + folderHolder.populate(localFolder, unreadMessageCount); mHandler.dataChanged(); } } @@ -951,6 +952,8 @@ public class FolderList extends K9ListActivity public void synchronizeMailboxFailed(Account account, String folder, String message) { + super.synchronizeMailboxFailed(account, folder, message); + mHandler.refreshTitle(); if (!account.equals(mAccount)) { return; @@ -971,9 +974,8 @@ public class FolderList extends K9ListActivity holder.lastChecked = 0; } - mHandler.folderSyncing(null); - mHandler.dataChanged(); + } @Override @@ -1013,7 +1015,7 @@ public class FolderList extends K9ListActivity } @Override - public void folderStatusChanged(Account account, String folderName) + public void folderStatusChanged(Account account, String folderName, int unreadMessageCount) { if (!account.equals(mAccount)) { @@ -1025,38 +1027,45 @@ public class FolderList extends K9ListActivity @Override public void sendPendingMessagesCompleted(Account account) { + super.sendPendingMessagesCompleted(account); + mHandler.refreshTitle(); if (!account.equals(mAccount)) { return; } - mHandler.sendingOutbox(false); refreshFolder(account, mAccount.getOutboxFolderName()); + + } @Override public void sendPendingMessagesStarted(Account account) { + super.sendPendingMessagesStarted(account); + mHandler.refreshTitle(); + if (!account.equals(mAccount)) { return; } - mHandler.sendingOutbox(true); - mHandler.dataChanged(); + } @Override public void sendPendingMessagesFailed(Account account) { + super.sendPendingMessagesFailed(account); + mHandler.refreshTitle(); if (!account.equals(mAccount)) { return; } - mHandler.sendingOutbox(false); refreshFolder(account, mAccount.getOutboxFolderName()); + } public void accountSizeChanged(Account account, long oldSize, long newSize) @@ -1069,6 +1078,26 @@ public class FolderList extends K9ListActivity mHandler.accountSizeChanged(oldSize, newSize); } + public void pendingCommandsProcessing(Account account) + { + super.pendingCommandsProcessing(account); + mHandler.refreshTitle(); + } + public void pendingCommandsFinished(Account account) + { + super.pendingCommandsFinished(account); + mHandler.refreshTitle(); + } + public void pendingCommandStarted(Account account, String commandTitle) + { + super.pendingCommandStarted(account, commandTitle); + mHandler.refreshTitle(); + } + public void pendingCommandCompleted(Account account, String commandTitle) + { + super.pendingCommandCompleted(account, commandTitle); + mHandler.refreshTitle(); + } }; @@ -1147,7 +1176,8 @@ public class FolderList extends K9ListActivity if (folder.loading) { - statusText = getString(R.string.status_loading); + String progress = false && mAdapter.mListener.getFolderTotal() > 0 ? getString(R.string.folder_progress, mAdapter.mListener.getFolderCompleted(), mAdapter.mListener.getFolderTotal()) : ""; + statusText = getString(R.string.status_loading, progress); } else if (folder.status != null) { @@ -1276,13 +1306,12 @@ public class FolderList extends K9ListActivity { } - public FolderInfoHolder(Folder folder) + public FolderInfoHolder(Folder folder, int unreadCount) { - populate(folder); + populate(folder, unreadCount); } - public void populate(Folder folder) + public void populate(Folder folder, int unreadCount) { - int unreadCount = 0; try { diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 23cb5650e..0d6bd7220 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -106,6 +106,8 @@ public class MessageList private LayoutInflater mInflater; private Account mAccount; + private int mUnreadMessageCount = 0; + /** * Stores the name of the folder that we want to open as soon as possible @@ -121,7 +123,6 @@ public class MessageList private boolean sortDateAscending = false; - private boolean mStartup = false; private boolean mLeftHanded = false; private int mSelectedCount = 0; @@ -211,14 +212,41 @@ public class MessageList public void folderLoading(String folder, boolean loading) { - if (mCurrentFolder.name == folder) + if (mCurrentFolder.name.equals(folder)) { mCurrentFolder.loading = loading; } } - + private void refreshTitle() + { + runOnUiThread(new Runnable() + { + public void run() + { + String displayName = mFolderName; + if (K9.INBOX.equalsIgnoreCase(displayName)) + { + displayName = getString(R.string.special_mailbox_name_inbox); + } + String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount); + + setTitle(dispString); + int level = Window.PROGRESS_END; + if (mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0) + { + level = (Window.PROGRESS_END / mAdapter.mListener.getFolderTotal()) * (mAdapter.mListener.getFolderCompleted()) ; + if (level > Window.PROGRESS_END) + { + level = Window.PROGRESS_END; + } + } + + getWindow().setFeatureInt(Window.FEATURE_PROGRESS, level); + } + }); + } public void progress(final boolean progress) { runOnUiThread(new Runnable() @@ -230,45 +258,7 @@ public class MessageList }); } - public void folderSyncing(final String folder) - { - runOnUiThread(new Runnable() - { - public void run() - { - String dispString = mAccount.getDescription(); - - if (folder != null) - { - dispString += " (" + getString(R.string.status_loading) - + folder + ")"; - } - - setTitle(dispString); - } - }); - } - - public void sendingOutbox(final boolean sending) - { - - - runOnUiThread(new Runnable() - { - public void run() - { - String dispString = mAccount.getDescription(); - - if (sending) - { - dispString += " (" + getString(R.string.status_sending) + ")"; - } - - setTitle(dispString); - } - }); - - } + } /** @@ -321,7 +311,7 @@ public class MessageList super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - + requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.message_list); mListView = (ListView) findViewById(R.id.message_list); @@ -331,8 +321,6 @@ public class MessageList mListView.setScrollingCacheEnabled(true); mListView.setOnItemClickListener(this); - - registerForContextMenu(mListView); /* @@ -353,7 +341,6 @@ public class MessageList Intent intent = getIntent(); mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT); - mStartup = (boolean)intent.getBooleanExtra(EXTRA_STARTUP, false); // Take the initial folder into account only if we are *not* restoring the // activity already @@ -400,7 +387,6 @@ public class MessageList onRestoreListState(savedInstanceState); } - setTitle(); } private void onRestoreListState(Bundle savedInstanceState) @@ -454,17 +440,10 @@ public class MessageList notifMgr.cancel(mAccount.getAccountNumber()); notifMgr.cancel(-1000 - mAccount.getAccountNumber()); - setTitle(); - } - - private void setTitle() - { - setTitle( - mAccount.getDescription() - + " - " + - mCurrentFolder.displayName - - ); + controller.getFolderUnreadMessageCount(mAccount, mFolderName, mAdapter.mListener); + + mHandler.refreshTitle(); + } @Override @@ -1449,20 +1428,20 @@ public class MessageList { private List messages = java.util.Collections.synchronizedList(new ArrayList()); - private MessagingListener mListener = new MessagingListener() + private ActivityListener mListener = new ActivityListener() { @Override public void synchronizeMailboxStarted(Account account, String folder) { - if (!account.equals(mAccount) || !folder.equals(mFolderName)) + super.synchronizeMailboxStarted(account, folder); + + if (account.equals(mAccount) && folder.equals(mFolderName)) { - return; + mHandler.progress(true); + mHandler.folderLoading(folder, true); } - - mHandler.progress(true); - mHandler.folderLoading(folder, true); - mHandler.folderSyncing(folder); + mHandler.refreshTitle(); } @@ -1471,32 +1450,61 @@ public class MessageList public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) { - if (!account.equals(mAccount) || !folder.equals(mFolderName)) + super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); + + if (account.equals(mAccount) && folder.equals(mFolderName)) { - return; + mHandler.progress(false); + mHandler.folderLoading(folder, false); + mHandler.sortMessages(); } - - mHandler.progress(false); - mHandler.folderLoading(folder, false); - mHandler.folderSyncing(null); - mHandler.sortMessages(); + mHandler.refreshTitle(); } @Override public void synchronizeMailboxFailed(Account account, String folder, String message) { - if (!account.equals(mAccount) || !folder.equals(mFolderName)) + super.synchronizeMailboxFailed(account, folder, message); + + if (account.equals(mAccount) && folder.equals(mFolderName)) { - return; + // Perhaps this can be restored, if done in the mHandler thread + // Toast.makeText(MessageList.this, message, Toast.LENGTH_LONG).show(); + mHandler.progress(false); + mHandler.folderLoading(folder, false); + mHandler.sortMessages(); } - - // Perhaps this can be restored, if done in the mHandler thread - // Toast.makeText(MessageList.this, message, Toast.LENGTH_LONG).show(); - mHandler.progress(false); - mHandler.folderLoading(folder, false); - mHandler.folderSyncing(null); - mHandler.sortMessages(); + mHandler.refreshTitle(); } + + @Override + public void sendPendingMessagesCompleted(Account account) + { + super.sendPendingMessagesCompleted(account); + mHandler.refreshTitle(); + } + + @Override + public void sendPendingMessagesStarted(Account account) + { + super.sendPendingMessagesStarted(account); + mHandler.refreshTitle(); + } + + @Override + public void sendPendingMessagesFailed(Account account) + { + super.sendPendingMessagesFailed(account); + mHandler.refreshTitle(); + } + + @Override + public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) + { + super.synchronizeMailboxProgress(account, folder, completed, total); + mHandler.refreshTitle(); + } + @Override public void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message) @@ -1605,6 +1613,36 @@ public class MessageList addOrUpdateMessage(folder, message); } + @Override + public void folderStatusChanged(Account account, String folderName, int unreadMessageCount) + { + if (!account.equals(mAccount) || !folderName.equals(mFolderName)) + { + return; + } + mUnreadMessageCount = unreadMessageCount; + mHandler.refreshTitle(); + } + public void pendingCommandsProcessing(Account account) + { + super.pendingCommandsProcessing(account); + mHandler.refreshTitle(); + } + public void pendingCommandsFinished(Account account) + { + super.pendingCommandsFinished(account); + mHandler.refreshTitle(); + } + public void pendingCommandStarted(Account account, String commandTitle) + { + super.pendingCommandStarted(account, commandTitle); + mHandler.refreshTitle(); + } + public void pendingCommandCompleted(Account account, String commandTitle) + { + super.pendingCommandCompleted(account, commandTitle); + mHandler.refreshTitle(); + } }; @@ -2274,6 +2312,8 @@ public class MessageList public boolean loading; public boolean lastCheckFailed; + + public Folder folder; /** * Outbox is handled differently from any other folder. @@ -2286,6 +2326,7 @@ public class MessageList } public void populate(Folder folder) { + this.folder = folder; this.name = folder.getName(); if (this.name.equalsIgnoreCase(K9.INBOX)) diff --git a/src/com/fsck/k9/service/MailService.java b/src/com/fsck/k9/service/MailService.java index 76fda66de..5f766a1fc 100644 --- a/src/com/fsck/k9/service/MailService.java +++ b/src/com/fsck/k9/service/MailService.java @@ -143,7 +143,6 @@ public class MailService extends CoreService { Log.v(K9.LOG_TAG, "***** MailService *****: cancel"); } - MessagingController.getInstance(getApplication()).log("***** MailService *****: cancel"); cancel(); } @@ -155,7 +154,6 @@ public class MailService extends CoreService } rescheduleAll(hasConnectivity, doBackground, startIdObj); startIdObj = null; - MessagingController.getInstance(getApplication()).log("***** MailService *****: reschedule"); } else if (ACTION_RESCHEDULE_CHECK.equals(intent.getAction())) @@ -166,7 +164,6 @@ public class MailService extends CoreService } reschedule(startIdObj); startIdObj = null; - MessagingController.getInstance(getApplication()).log("***** MailService *****: reschedule"); } else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) @@ -293,7 +290,6 @@ public class MailService extends CoreService { String checkString = "Next check for package " + getApplication().getPackageName() + " scheduled for " + new Date(nextTime); Log.i(K9.LOG_TAG, checkString); - MessagingController.getInstance(getApplication()).log(checkString); } catch (Exception e) { diff --git a/src/com/fsck/k9/service/PollService.java b/src/com/fsck/k9/service/PollService.java index c18e281f8..b94a6cf81 100644 --- a/src/com/fsck/k9/service/PollService.java +++ b/src/com/fsck/k9/service/PollService.java @@ -44,7 +44,7 @@ public class PollService extends CoreService Listener listener = (Listener)controller.getCheckMailListener(); if (listener == null) { - MessagingController.getInstance(getApplication()).log("***** PollService *****: starting new check"); + Log.i(K9.LOG_TAG, "***** PollService *****: starting new check"); mListener.setStartId(startId); mListener.wakeLockAcquire(); controller.setCheckMailListener(mListener); @@ -52,7 +52,7 @@ public class PollService extends CoreService } else { - MessagingController.getInstance(getApplication()).log("***** PollService *****: renewing WakeLock"); + Log.i(K9.LOG_TAG,"***** PollService *****: renewing WakeLock"); listener.setStartId(startId); listener.wakeLockAcquire(); }