diff --git a/res/layout/accounts_item.xml b/res/layout/accounts_item.xml
index bfb6b36ec..fe74eeeea 100644
--- a/res/layout/accounts_item.xml
+++ b/res/layout/accounts_item.xml
@@ -37,6 +37,7 @@
android:layout_width="0dip"
android:layout_weight="1" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5d4887ed3..885334035 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -690,17 +690,13 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
Count search results
Turn off for faster display
- All unread messages
- Unread messages in searchable accounts
+ All messages
+ All messages in searchable folders
- All starred messages
- Starred messages in searchable accounts
-
- Integrated Inbox (unread)
- All unread messages in integrated folders
+ Integrated Inbox
+ All messages in integrated folders
- Integrated Inbox (starred)
- All starred messages in integrated folders
+ Tap envelope or star for unread or starred messages
Integrate
Unread messages are shown in Integrated Inbox
diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java
index 9ad264d80..cc7e70c39 100644
--- a/src/com/fsck/k9/Account.java
+++ b/src/com/fsck/k9/Account.java
@@ -426,6 +426,7 @@ public class Account implements BaseAccount
// Why should everything be in MessagingController? This is an Account-specific operation. --danapple0
public AccountStats getStats(Context context) throws MessagingException
{
+ long startTime = System.currentTimeMillis();
AccountStats stats = new AccountStats();
int unreadMessageCount = 0;
int flaggedMessageCount = 0;
@@ -436,10 +437,15 @@ public class Account implements BaseAccount
}
Account.FolderMode aMode = getFolderDisplayMode();
Preferences prefs = Preferences.getPreferences(context);
- for (LocalFolder folder : localStore.getPersonalNamespaces())
+ long folderLoadStart = System.currentTimeMillis();
+ List extends Folder> folders = localStore.getPersonalNamespaces();
+ long folderLoadEnd = System.currentTimeMillis();
+ long folderEvalStart = folderLoadEnd;
+ for (Folder folder : folders)
{
- folder.refresh(prefs);
- Folder.FolderClass fMode = folder.getDisplayClass();
+ LocalFolder localFolder = (LocalFolder)folder;
+ //folder.refresh(prefs);
+ Folder.FolderClass fMode = localFolder.getDisplayClass(prefs);
if (folder.getName().equals(getTrashFolderName()) == false &&
folder.getName().equals(getDraftsFolderName()) == false &&
@@ -472,9 +478,14 @@ public class Account implements BaseAccount
}
}
+ long folderEvalEnd = System.currentTimeMillis();
stats.unreadMessageCount = unreadMessageCount;
stats.flaggedMessageCount = flaggedMessageCount;
- Log.i(K9.LOG_TAG, "flaggedMessageCount for " + getDescription() + " = " + flaggedMessageCount);
+ long endTime = System.currentTimeMillis();
+ if (K9.DEBUG)
+ Log.d(K9.LOG_TAG, "Account.getStats() on " + getDescription() + " took " + (endTime - startTime) + " ms;"
+ + " loading " + folders.size() + " took " + (folderLoadEnd - folderLoadStart) + " ms;"
+ + " evaluating took " + (folderEvalEnd - folderEvalStart) + " ms");
return stats;
}
diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java
index eea907fb3..0e0354a75 100644
--- a/src/com/fsck/k9/MessagingController.java
+++ b/src/com/fsck/k9/MessagingController.java
@@ -410,24 +410,26 @@ public class MessagingController implements Runnable
{
listener.listFoldersStarted(account);
}
- Folder[] localFolders = null;
+ List extends Folder> localFolders = null;
try
{
Store localStore = account.getLocalStore();
localFolders = localStore.getPersonalNamespaces();
- if (refreshRemote || localFolders == null || localFolders.length == 0)
+ Folder[] folderArray = localFolders.toArray(new Folder[0]);
+
+ if (refreshRemote || localFolders == null || localFolders.size() == 0)
{
doRefreshRemote(account, listener);
return;
}
for (MessagingListener l : getListeners())
{
- l.listFolders(account, localFolders);
+ l.listFolders(account, folderArray);
}
if (listener != null)
{
- listener.listFolders(account, localFolders);
+ listener.listFolders(account, folderArray);
}
}
catch (Exception e)
@@ -475,23 +477,23 @@ public class MessagingController implements Runnable
{
public void run()
{
- Folder[] localFolders = null;
+ List extends Folder> localFolders = null;
try
{
Store store = account.getRemoteStore();
- Folder[] remoteFolders = store.getPersonalNamespaces();
+ List extends Folder> remoteFolders = store.getPersonalNamespaces();
LocalStore localStore = account.getLocalStore();
HashSet remoteFolderNames = new HashSet();
- for (int i = 0, count = remoteFolders.length; i < count; i++)
+ for (int i = 0, count = remoteFolders.size(); i < count; i++)
{
- LocalFolder localFolder = localStore.getFolder(remoteFolders[i].getName());
+ LocalFolder localFolder = localStore.getFolder(remoteFolders.get(i).getName());
if (!localFolder.exists())
{
localFolder.create(FolderType.HOLDS_MESSAGES, account.getDisplayCount());
}
- remoteFolderNames.add(remoteFolders[i].getName());
+ remoteFolderNames.add(remoteFolders.get(i).getName());
}
localFolders = localStore.getPersonalNamespaces();
@@ -518,10 +520,11 @@ public class MessagingController implements Runnable
}
localFolders = localStore.getPersonalNamespaces();
+ Folder[] folderArray = localFolders.toArray(new Folder[0]);
for (MessagingListener l : getListeners())
{
- l.listFolders(account, localFolders);
+ l.listFolders(account, folderArray);
}
for (MessagingListener l : getListeners())
{
@@ -696,27 +699,34 @@ public class MessagingController implements Runnable
}
}
- public void searchLocalMessages(SearchAccount searchAccount, final Message[] messages, final MessagingListener listener)
+ public void searchLocalMessages(SearchSpecification searchSpecification, final Message[] messages, final MessagingListener listener)
{
- searchLocalMessages(searchAccount, searchAccount.getQuery(), messages, searchAccount.isIntegrate(),
- searchAccount.getRequiredFlags(), searchAccount.getForbiddenFlags(), listener);
+ searchLocalMessages(searchSpecification.getAccountUuids(), searchSpecification.getQuery(), messages,
+ searchSpecification.isIntegrate(), searchSpecification.getRequiredFlags(), searchSpecification.getForbiddenFlags(), listener);
}
/**
* Find all messages in any local account which match the query 'query'
- * @param account TODO
+ * @param searchAccounts TODO
* @param query
* @param listener
+ * @param account TODO
* @param account
- *
* @throws MessagingException
*/
- public void searchLocalMessages(final BaseAccount baseAccount, final String query, final Message[] messages, final boolean integrate, final Flag[] requiredFlags,
+ public void searchLocalMessages(final String[] accountUuids, final String query, final Message[] messages, final boolean integrate, final Flag[] requiredFlags,
final Flag[] forbiddenFlags, final MessagingListener listener)
{
final AccountStats stats = new AccountStats();
-
+ final Set accountUuidsSet = new HashSet();
+ if (accountUuids != null)
+ {
+ for (String accountUuid : accountUuids)
+ {
+ accountUuidsSet.add(accountUuid);
+ }
+ }
threadPool.execute(new Runnable()
{
public void run()
@@ -728,6 +738,10 @@ public class MessagingController implements Runnable
boolean displayableOnly = false;
for (final Account account : accounts)
{
+ if (accountUuids != null && accountUuidsSet.contains(account.getUuid()) == false)
+ {
+ continue;
+ }
Account.Searchable searchableFolders = account.getSearchableFolders();
switch (searchableFolders)
{
@@ -749,23 +763,24 @@ public class MessagingController implements Runnable
try
{
LocalStore store = account.getLocalStore();
- LocalFolder[] folders = store.getPersonalNamespaces();
- for (LocalFolder folder : folders)
+ List extends Folder> folders = store.getPersonalNamespaces();
+ for (Folder folder : folders)
{
+ LocalFolder localFolder = (LocalFolder)folder;
boolean include = true;
folder.refresh(prefs);
if (displayableOnly && modeMismatch(account.getFolderDisplayMode(), folder.getDisplayClass()))
{
include = false;
}
- if (integrate && folder.isIntegrate() == false)
+ if (integrate && localFolder.isIntegrate() == false)
{
include = false;
}
if (include)
{
- tmpFoldersToSearch.add(folder);
+ tmpFoldersToSearch.add(localFolder);
}
}
foldersToSearch = tmpFoldersToSearch;
@@ -801,10 +816,7 @@ public class MessagingController implements Runnable
}
public void messagesFinished(int number)
{
- if (baseAccount != null)
- {
- listener.accountStatusChanged(baseAccount, stats);
- }
+ listener.searchStats(stats);
}
};
@@ -4337,15 +4349,15 @@ public class MessagingController implements Runnable
}
int unreadMessageCount = 0;
- try
- {
- AccountStats stats = account.getStats(context);
- unreadMessageCount = stats.unreadMessageCount;
- }
- catch (MessagingException e)
- {
- Log.e(K9.LOG_TAG, "Unable to getUnreadMessageCount for account: " + account, e);
- }
+// try
+// {
+// AccountStats stats = account.getStats(context);
+// unreadMessageCount = stats.unreadMessageCount;
+// }
+// catch (MessagingException e)
+// {
+// Log.e(K9.LOG_TAG, "Unable to getUnreadMessageCount for account: " + account, e);
+// }
NotificationManager notifMgr =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -4355,7 +4367,6 @@ public class MessagingController implements Runnable
Intent i = FolderList.actionHandleAccountIntent(context, account, account.getAutoExpandFolderName());
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
- // 279 Unread (someone@gmail.com)
String accountNotice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, account.getDescription());
notif.setLatestEventInfo(context, accountNotice, messageNotice, pi);
diff --git a/src/com/fsck/k9/MessagingListener.java b/src/com/fsck/k9/MessagingListener.java
index c824a9211..25a83d953 100644
--- a/src/com/fsck/k9/MessagingListener.java
+++ b/src/com/fsck/k9/MessagingListener.java
@@ -17,7 +17,8 @@ import java.util.List;
*/
public class MessagingListener
{
-
+ public void searchStats(AccountStats stats) {}
+
public void accountStatusChanged(BaseAccount account, AccountStats stats)
{
}
diff --git a/src/com/fsck/k9/SearchAccount.java b/src/com/fsck/k9/SearchAccount.java
index 31f064f5c..df804d37c 100644
--- a/src/com/fsck/k9/SearchAccount.java
+++ b/src/com/fsck/k9/SearchAccount.java
@@ -3,6 +3,7 @@
*/
package com.fsck.k9;
+import java.io.Serializable;
import java.util.UUID;
import android.content.Context;
@@ -10,7 +11,7 @@ import android.content.Context;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Message;
-public class SearchAccount implements BaseAccount
+public class SearchAccount implements BaseAccount, SearchSpecification, Serializable
{
private Flag[] mRequiredFlags = null;
private Flag[] mForbiddenFlags = null;
@@ -19,6 +20,23 @@ public class SearchAccount implements BaseAccount
private String query = "";
private boolean integrate = false;
private String mUuid = UUID.randomUUID().toString();
+ private boolean builtin = false;
+ private String[] accountUuids = null;
+
+ public SearchAccount(Preferences preferences)
+ {
+
+ }
+ protected synchronized void delete(Preferences preferences)
+ {
+
+ }
+
+ public synchronized void save(Preferences preferences)
+ {
+
+ }
+
public SearchAccount(Context context, boolean nintegrate, Flag[] requiredFlags, Flag[] forbiddenFlags)
{
@@ -86,4 +104,22 @@ public class SearchAccount implements BaseAccount
{
this.integrate = integrate;
}
+
+ public boolean isBuiltin()
+ {
+ return builtin;
+ }
+
+ public void setBuiltin(boolean builtin)
+ {
+ this.builtin = builtin;
+ }
+ public String[] getAccountUuids()
+ {
+ return accountUuids;
+ }
+ public void setAccountUuids(String[] accountUuids)
+ {
+ this.accountUuids = accountUuids;
+ }
}
\ No newline at end of file
diff --git a/src/com/fsck/k9/SearchSpecification.java b/src/com/fsck/k9/SearchSpecification.java
new file mode 100644
index 000000000..dc9791397
--- /dev/null
+++ b/src/com/fsck/k9/SearchSpecification.java
@@ -0,0 +1,18 @@
+
+package com.fsck.k9;
+
+import com.fsck.k9.mail.Flag;
+
+public interface SearchSpecification
+{
+
+ public Flag[] getRequiredFlags();
+
+ public Flag[] getForbiddenFlags();
+
+ public boolean isIntegrate();
+
+ public String getQuery();
+
+ public String[] getAccountUuids();
+}
\ No newline at end of file
diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java
index f36a68b01..fb2559139 100644
--- a/src/com/fsck/k9/activity/Accounts.java
+++ b/src/com/fsck/k9/activity/Accounts.java
@@ -37,15 +37,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private ConcurrentHashMap pendingWork = new ConcurrentHashMap();
- private Account mSelectedContextAccount;
+ private BaseAccount mSelectedContextAccount;
private int mUnreadMessageCount = 0;
private AccountsHandler mHandler = new AccountsHandler();
private AccountsAdapter mAdapter;
private SearchAccount unreadAccount = null;
- private SearchAccount flaggedAccount = null;
private SearchAccount integratedInboxAccount = null;
- private SearchAccount integratedInboxStarredAccount = null;
private FontSizes mFontSizes = K9.getFontSizes();
class AccountsHandler extends Handler
@@ -308,22 +306,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override
public void onCreate(Bundle icicle)
{
- unreadAccount = new SearchAccount(this, false, null, new Flag[] { Flag.SEEN } );
- unreadAccount.setDescription(getString(R.string.search_unread_messages_title));
- unreadAccount.setEmail(getString(R.string.search_unread_messages_detail));
+ unreadAccount = new SearchAccount(this, false, null, null );
+ unreadAccount.setDescription(getString(R.string.search_all_messages_title));
+ unreadAccount.setEmail(getString(R.string.search_all_messages_detail));
- flaggedAccount = new SearchAccount(this, false, new Flag[] { Flag.FLAGGED }, null);
- flaggedAccount.setDescription(getString(R.string.search_starred_messages_title));
- flaggedAccount.setEmail(getString(R.string.search_starred_messages_detail));
-
- integratedInboxAccount = new SearchAccount(this, true, null, new Flag[] { Flag.SEEN });
+ integratedInboxAccount = new SearchAccount(this, true, null, null);
integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title));
integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail));
- integratedInboxStarredAccount = new SearchAccount(this, true, new Flag[] { Flag.FLAGGED }, null);
- integratedInboxStarredAccount.setDescription(getString(R.string.integrated_inbox_starred_title));
- integratedInboxStarredAccount.setEmail(getString(R.string.integrated_inbox_starred_detail));
-
super.onCreate(icicle);
Account[] accounts = Preferences.getPreferences(this).getAccounts();
@@ -397,15 +387,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
List newAccounts = new ArrayList(accounts.length + 4);
newAccounts.add(integratedInboxAccount);
- if (K9.messageListStars())
- {
- newAccounts.add(integratedInboxStarredAccount);
- }
newAccounts.add(unreadAccount);
- if (K9.messageListStars())
- {
- newAccounts.add(flaggedAccount);
- }
+
for (BaseAccount account : accounts)
{
newAccounts.add(account);
@@ -431,9 +414,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
else if (K9.countSearchMessages() && account instanceof SearchAccount)
{
pendingWork.put(account, "true");
- SearchAccount searchAccount = (SearchAccount)account;
+ final SearchAccount searchAccount = (SearchAccount)account;
- MessagingController.getInstance(getApplication()).searchLocalMessages(searchAccount, null, mListener);
+ MessagingController.getInstance(getApplication()).searchLocalMessages(searchAccount, null, new MessagingListener()
+ {
+ @Override
+ public void searchStats(AccountStats stats)
+ {
+ mListener.accountStatusChanged(searchAccount, stats);
+ }
+ });
}
}
@@ -561,18 +551,23 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public void onClick(DialogInterface dialog, int whichButton)
{
dismissDialog(DIALOG_REMOVE_ACCOUNT);
- try
+
+ if (mSelectedContextAccount instanceof Account)
{
- mSelectedContextAccount.getLocalStore().delete();
+ Account realAccount = (Account)mSelectedContextAccount;
+ try
+ {
+ realAccount.getLocalStore().delete();
+ }
+ catch (Exception e)
+ {
+ // Ignore
+ }
+ MessagingController.getInstance(getApplication()).notifyAccountCancel(Accounts.this, realAccount);
+ Preferences.getPreferences(Accounts.this).deleteAccount(realAccount);
+ K9.setServicesEnabled(Accounts.this);
+ refresh();
}
- catch (Exception e)
- {
- // Ignore
- }
- MessagingController.getInstance(getApplication()).notifyAccountCancel(Accounts.this, mSelectedContextAccount);
- Preferences.getPreferences(Accounts.this).deleteAccount(mSelectedContextAccount);
- K9.setServicesEnabled(Accounts.this);
- refresh();
}
})
.setNegativeButton(R.string.cancel_action, new DialogInterface.OnClickListener()
@@ -593,33 +588,38 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
// submenu wouldn't work.
if (menuInfo != null)
{
- mSelectedContextAccount = (Account)getListView().getItemAtPosition(menuInfo.position);
+ mSelectedContextAccount = (BaseAccount)getListView().getItemAtPosition(menuInfo.position);
+ }
+ Account realAccount = null;
+ if (mSelectedContextAccount instanceof Account)
+ {
+ realAccount = (Account)mSelectedContextAccount;
}
switch (item.getItemId())
{
case R.id.delete_account:
- onDeleteAccount(mSelectedContextAccount);
+ onDeleteAccount(realAccount);
break;
case R.id.edit_account:
- onEditAccount(mSelectedContextAccount);
+ onEditAccount(realAccount);
break;
case R.id.open:
onOpenAccount(mSelectedContextAccount);
break;
case R.id.check_mail:
- onCheckMail(mSelectedContextAccount);
+ onCheckMail(realAccount);
break;
case R.id.clear_pending:
- onClearCommands(mSelectedContextAccount);
+ onClearCommands(realAccount);
break;
case R.id.empty_trash:
- onEmptyTrash(mSelectedContextAccount);
+ onEmptyTrash(realAccount);
break;
case R.id.compact:
- onCompact(mSelectedContextAccount);
+ onCompact(realAccount);
break;
case R.id.clear:
- onClear(mSelectedContextAccount);
+ onClear(realAccount);
break;
}
return true;
@@ -769,7 +769,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
- BaseAccount account = getItem(position);
+ final BaseAccount account = getItem(position);
View view;
if (convertView != null)
{
@@ -787,6 +787,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
holder.email = (TextView) view.findViewById(R.id.email);
holder.newMessageCount = (TextView) view.findViewById(R.id.new_message_count);
holder.flaggedMessageCount = (TextView) view.findViewById(R.id.flagged_message_count);
+ holder.activeIcons = (RelativeLayout) view.findViewById(R.id.active_icons);
holder.chip = view.findViewById(R.id.chip);
@@ -825,6 +826,127 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
holder.flaggedMessageCount.setText(Integer.toString(stats.flaggedMessageCount));
holder.flaggedMessageCount.setVisibility(K9.messageListStars() && stats.flaggedMessageCount > 0 ? View.VISIBLE : View.GONE);
+
+ holder.flaggedMessageCount.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ Log.i(K9.LOG_TAG, "Star on " + account.getDescription());
+ // TODO: Better String formatting using resources
+ String description = account.getDescription() + " (Stars)";
+ if (account instanceof SearchAccount)
+ {
+ SearchAccount searchAccount = (SearchAccount)account;
+ MessageList.actionHandle(Accounts.this,
+ description, "", searchAccount.isIntegrate(), new Flag[] { Flag.FLAGGED }, null);
+ }
+ else
+ {
+ SearchSpecification searchSpec = new SearchSpecification()
+ {
+ @Override
+ public String[] getAccountUuids()
+ {
+ return new String[] { account.getUuid() };
+ }
+
+ @Override
+ public Flag[] getForbiddenFlags()
+ {
+ return null;
+ }
+
+ @Override
+ public String getQuery()
+ {
+ return null;
+ }
+
+ @Override
+ public Flag[] getRequiredFlags()
+ {
+ return new Flag[] { Flag.FLAGGED };
+ }
+
+ @Override
+ public boolean isIntegrate()
+ {
+ return false;
+ }
+
+ };
+ // TODO: Need a way to pass a SearchSpecification to the MessageList
+ // MessageList.actionHandle(Accounts.this,
+ // description, searchSpec);
+ }
+ }
+ });
+
+ holder.newMessageCount.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ // TODO: Better String formatting using resources
+ String description = account.getDescription() + " (Unread)";
+ Log.i(K9.LOG_TAG, "Envelope on " + account.getDescription());
+ if (account instanceof SearchAccount)
+ {
+ SearchAccount searchAccount = (SearchAccount)account;
+ MessageList.actionHandle(Accounts.this,
+ description, "", searchAccount.isIntegrate(), null, new Flag[] { Flag.SEEN });
+ }
+ else
+ {
+ SearchSpecification searchSpec = new SearchSpecification()
+ {
+ @Override
+ public String[] getAccountUuids()
+ {
+ return new String[] { account.getUuid() };
+ }
+
+ @Override
+ public Flag[] getForbiddenFlags()
+ {
+ return new Flag[] { Flag.SEEN };
+ }
+
+ @Override
+ public String getQuery()
+ {
+ return null;
+ }
+
+ @Override
+ public Flag[] getRequiredFlags()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isIntegrate()
+ {
+ return false;
+ }
+
+ };
+
+ // TODO: Need a way to pass a SearchSpecification to the MessageList
+ // MessageList.actionHandle(Accounts.this,
+ // description, searchSpec);
+ }
+ }
+ });
+ holder.activeIcons.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ Toast toast = Toast.makeText(getApplication(), getString(R.string.tap_hint), Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ }
+ );
+
}
else
{
@@ -866,6 +988,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public TextView email;
public TextView newMessageCount;
public TextView flaggedMessageCount;
+ public RelativeLayout activeIcons;
public View chip;
}
}
diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java
index d9ed1c4e9..76992889f 100644
--- a/src/com/fsck/k9/activity/MessageList.java
+++ b/src/com/fsck/k9/activity/MessageList.java
@@ -68,7 +68,7 @@ public class MessageList
private static final String EXTRA_FORBIDDEN_FLAGS = "forbiddenFlags";
private static final String EXTRA_INTEGRATE = "integrate";
private static final String EXTRA_TITLE = "title";
-
+ private static final String EXTRA_SEARCH_SPECIFICATION = "searchSpecification";
private ListView mListView;
@@ -264,7 +264,8 @@ public class MessageList
{
if (mTitle != null)
{
- setTitle(mTitle);
+ String dispString = mAdapter.mListener.formatHeader(MessageList.this, mTitle, mUnreadMessageCount, getTimeFormat());
+ setTitle(dispString);
}
else
{
@@ -1621,6 +1622,14 @@ public class MessageList
{
addOrUpdateMessage(account, folder, message);
}
+
+ @Override
+ public void searchStats(AccountStats stats)
+ {
+ mUnreadMessageCount = stats.unreadMessageCount;
+ mHandler.refreshTitle();
+ }
+
@Override
public void folderStatusChanged(Account account, String folder, int unreadMessageCount)
{
diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java
index 7a43a4da6..f00b12d3f 100644
--- a/src/com/fsck/k9/mail/Store.java
+++ b/src/com/fsck/k9/mail/Store.java
@@ -10,6 +10,7 @@ import com.fsck.k9.mail.store.Pop3Store;
import com.fsck.k9.mail.store.WebDavStore;
import java.util.HashMap;
+import java.util.List;
/**
* Store is the access point for an email message store. It's location can be
@@ -115,7 +116,7 @@ public abstract class Store
public abstract Folder getFolder(String name) throws MessagingException;
- public abstract Folder[] getPersonalNamespaces() throws MessagingException;
+ public abstract List extends Folder> getPersonalNamespaces() throws MessagingException;
public abstract void checkSettings() throws MessagingException;
diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java
index 9fc6e1a23..e20d530a9 100644
--- a/src/com/fsck/k9/mail/store/ImapStore.java
+++ b/src/com/fsck/k9/mail/store/ImapStore.java
@@ -248,12 +248,12 @@ public class ImapStore extends Store
}
@Override
- public Folder[] getPersonalNamespaces() throws MessagingException
+ public List extends Folder> getPersonalNamespaces() throws MessagingException
{
ImapConnection connection = getConnection();
try
{
- ArrayList folders = new ArrayList();
+ LinkedList folders = new LinkedList();
List responses =
connection.executeSimpleCommand(String.format("LIST \"\" \"%s*\"",
@@ -308,7 +308,7 @@ public class ImapStore extends Store
}
}
folders.add(getFolder("INBOX"));
- return folders.toArray(new Folder[] {});
+ return folders;
}
catch (IOException ioe)
{
diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java
index 2914d7698..90fad1b5a 100644
--- a/src/com/fsck/k9/mail/store/LocalStore.java
+++ b/src/com/fsck/k9/mail/store/LocalStore.java
@@ -266,37 +266,46 @@ public class LocalStore extends Store implements Serializable
public void compact() throws MessagingException
{
- Log.i(K9.LOG_TAG, "Before prune size = " + getSize());
+ if (K9.DEBUG)
+ Log.i(K9.LOG_TAG, "Before prune size = " + getSize());
pruneCachedAttachments();
- Log.i(K9.LOG_TAG, "After prune / before compaction size = " + getSize());
+ if (K9.DEBUG)
+ Log.i(K9.LOG_TAG, "After prune / before compaction size = " + getSize());
mDb.execSQL("VACUUM");
- Log.i(K9.LOG_TAG, "After compaction size = " + getSize());
+ if (K9.DEBUG)
+ Log.i(K9.LOG_TAG, "After compaction size = " + getSize());
}
public void clear() throws MessagingException
{
- Log.i(K9.LOG_TAG, "Before prune size = " + getSize());
+ if (K9.DEBUG)
+ Log.i(K9.LOG_TAG, "Before prune size = " + getSize());
pruneCachedAttachments(true);
+ if (K9.DEBUG)
+ {
+ Log.i(K9.LOG_TAG, "After prune / before compaction size = " + getSize());
- Log.i(K9.LOG_TAG, "After prune / before compaction size = " + getSize());
+ Log.i(K9.LOG_TAG, "Before clear folder count = " + getFolderCount());
+ Log.i(K9.LOG_TAG, "Before clear message count = " + getMessageCount());
- Log.i(K9.LOG_TAG, "Before clear folder count = " + getFolderCount());
- Log.i(K9.LOG_TAG, "Before clear message count = " + getMessageCount());
-
- Log.i(K9.LOG_TAG, "After prune / before clear size = " + getSize());
+ Log.i(K9.LOG_TAG, "After prune / before clear size = " + getSize());
+ }
// don't delete messages that are Local, since there is no copy on the server.
// Don't delete deleted messages. They are essentially placeholders for UIDs of messages that have
// been deleted locally. They take up insignificant space
mDb.execSQL("DELETE FROM messages WHERE deleted = 0 and uid not like 'Local%'");
compact();
- Log.i(K9.LOG_TAG, "After clear message count = " + getMessageCount());
+ if (K9.DEBUG)
+ {
+ Log.i(K9.LOG_TAG, "After clear message count = " + getMessageCount());
- Log.i(K9.LOG_TAG, "After clear size = " + getSize());
+ Log.i(K9.LOG_TAG, "After clear size = " + getSize());
+ }
}
public int getMessageCount() throws MessagingException
@@ -345,12 +354,11 @@ public class LocalStore extends Store implements Serializable
// TODO this takes about 260-300ms, seems slow.
@Override
- public LocalFolder[] getPersonalNamespaces() throws MessagingException
+ public List extends Folder> getPersonalNamespaces() throws MessagingException
{
- ArrayList folders = new ArrayList();
+ LinkedList folders = new LinkedList();
Cursor cursor = null;
-
try
{
cursor = mDb.rawQuery("SELECT id, name, unread_count, visible_limit, last_updated, status, push_state, last_pushed, flagged_count FROM folders", null);
@@ -369,7 +377,7 @@ public class LocalStore extends Store implements Serializable
cursor.close();
}
}
- return folders.toArray(new LocalFolder[] {});
+ return folders;
}
@Override
@@ -457,7 +465,8 @@ public class LocalStore extends Store implements Serializable
{
if (cursor.getString(0) == null)
{
- Log.d(K9.LOG_TAG, "Attachment " + file.getAbsolutePath() + " has no store data, not deleting");
+ if (K9.DEBUG)
+ Log.d(K9.LOG_TAG, "Attachment " + file.getAbsolutePath() + " has no store data, not deleting");
/*
* If the attachment has no store data it is not recoverable, so
* we won't delete it.
@@ -692,8 +701,11 @@ public class LocalStore extends Store implements Serializable
whereClause.append(" )");
}
- Log.i(K9.LOG_TAG, "whereClause = " + whereClause.toString());
- Log.i(K9.LOG_TAG, "args = " + args);
+ if (K9.DEBUG)
+ {
+ Log.v(K9.LOG_TAG, "whereClause = " + whereClause.toString());
+ Log.v(K9.LOG_TAG, "args = " + args);
+ }
return getMessages(
listener,
null,
@@ -1193,6 +1205,15 @@ public class LocalStore extends Store implements Serializable
editor.commit();
}
+
+
+ public FolderClass getDisplayClass(Preferences preferences) throws MessagingException
+ {
+ String id = getPrefId();
+ return FolderClass.valueOf(preferences.getPreferences().getString(id + ".displayMode",
+ FolderClass.NO_CLASS.name()));
+ }
+
@Override
public void refresh(Preferences preferences) throws MessagingException
{
diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java
index 990247504..cb5156104 100644
--- a/src/com/fsck/k9/mail/store/Pop3Store.java
+++ b/src/com/fsck/k9/mail/store/Pop3Store.java
@@ -19,8 +19,10 @@ import java.net.*;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
public class Pop3Store extends Store
{
@@ -156,12 +158,11 @@ public class Pop3Store extends Store
}
@Override
- public Folder[] getPersonalNamespaces() throws MessagingException
+ public List extends Folder> getPersonalNamespaces() throws MessagingException
{
- return new Folder[]
- {
- getFolder("INBOX"),
- };
+ List folders = new LinkedList();
+ folders.add(getFolder("INBOX"));
+ return folders;
}
@Override
diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java
index 3875b0a44..b083b4331 100644
--- a/src/com/fsck/k9/mail/store/WebDavStore.java
+++ b/src/com/fsck/k9/mail/store/WebDavStore.java
@@ -49,6 +49,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Stack;
import java.util.zip.GZIPInputStream;
@@ -260,9 +262,9 @@ public class WebDavStore extends Store
}
@Override
- public Folder[] getPersonalNamespaces() throws MessagingException
+ public List extends Folder> getPersonalNamespaces() throws MessagingException
{
- ArrayList folderList = new ArrayList();
+ LinkedList folderList = new LinkedList();
HashMap headers = new HashMap();
DataSet dataset = new DataSet();
String messageBody;
@@ -323,7 +325,7 @@ public class WebDavStore extends Store
this.mFolderList.put(folderName, wdFolder);
}
- return folderList.toArray(new WebDavFolder[] {});
+ return folderList;
}
@Override