mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 16:48:50 -05:00
Star and envelope are now active for regular accounts.
This commit is contained in:
parent
41c5dc5986
commit
8e0ee1a6e1
@ -690,6 +690,10 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="count_search_title">Count search results</string>
|
||||
<string name="count_search_summary">Turn off for faster display</string>
|
||||
|
||||
<string name="search_title"><xliff:g id="search_name">%s</xliff:g> <xliff:g id="modifier">%s</xliff:g></string>
|
||||
<string name="flagged_modifier"> - Starred</string>
|
||||
<string name="unread_modifier"> - Unread</string>
|
||||
|
||||
<string name="search_all_messages_title">All messages</string>
|
||||
<string name="search_all_messages_detail">All messages in searchable folders</string>
|
||||
|
||||
|
@ -736,21 +736,31 @@ public class MessagingController implements Runnable
|
||||
Account[] accounts = prefs.getAccounts();
|
||||
List<LocalFolder> foldersToSearch = null;
|
||||
boolean displayableOnly = false;
|
||||
boolean noSpecialFolders = true;
|
||||
for (final Account account : accounts)
|
||||
{
|
||||
if (accountUuids != null && accountUuidsSet.contains(account.getUuid()) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Account.Searchable searchableFolders = account.getSearchableFolders();
|
||||
switch (searchableFolders)
|
||||
|
||||
if (accountUuids != null && accountUuidsSet.contains(account.getUuid()) == true)
|
||||
{
|
||||
case NONE:
|
||||
continue;
|
||||
case DISPLAYABLE:
|
||||
displayableOnly = true;
|
||||
break;
|
||||
|
||||
displayableOnly = true;
|
||||
noSpecialFolders = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Account.Searchable searchableFolders = account.getSearchableFolders();
|
||||
switch (searchableFolders)
|
||||
{
|
||||
case NONE:
|
||||
continue;
|
||||
case DISPLAYABLE:
|
||||
displayableOnly = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (listener != null)
|
||||
{
|
||||
@ -769,11 +779,21 @@ public class MessagingController implements Runnable
|
||||
LocalFolder localFolder = (LocalFolder)folder;
|
||||
boolean include = true;
|
||||
folder.refresh(prefs);
|
||||
if (displayableOnly && modeMismatch(account.getFolderDisplayMode(), folder.getDisplayClass()))
|
||||
String localFolderName = localFolder.getName();
|
||||
if (noSpecialFolders && (
|
||||
localFolderName.equals(account.getTrashFolderName()) ||
|
||||
localFolderName.equals(account.getOutboxFolderName()) ||
|
||||
localFolderName.equals(account.getDraftsFolderName()) ||
|
||||
localFolderName.equals(account.getSentFolderName()) ||
|
||||
localFolderName.equals(account.getErrorFolderName())))
|
||||
{
|
||||
include = false;
|
||||
}
|
||||
if (integrate && localFolder.isIntegrate() == false)
|
||||
else if (displayableOnly && modeMismatch(account.getFolderDisplayMode(), folder.getDisplayClass()))
|
||||
{
|
||||
include = false;
|
||||
}
|
||||
else if (integrate && localFolder.isIntegrate() == false)
|
||||
{
|
||||
include = false;
|
||||
|
||||
@ -816,7 +836,7 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
public void messagesFinished(int number)
|
||||
{
|
||||
listener.searchStats(stats);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -842,6 +862,10 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listener != null)
|
||||
{
|
||||
listener.searchStats(stats);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -26,8 +26,10 @@ import com.fsck.k9.activity.setup.Prefs;
|
||||
import com.fsck.k9.mail.Flag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener
|
||||
@ -484,7 +486,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
if (account instanceof SearchAccount)
|
||||
{
|
||||
SearchAccount searchAccount = (SearchAccount)account;
|
||||
MessageList.actionHandle(this, searchAccount.getDescription(), "", searchAccount.isIntegrate(), searchAccount.getRequiredFlags(), searchAccount.getForbiddenFlags());
|
||||
MessageList.actionHandle(this, searchAccount.getDescription(), searchAccount);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -827,116 +829,9 @@ 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.flaggedMessageCount.setOnClickListener(new AccountClickListener(account, SearchModifier.FLAGGED));
|
||||
holder.newMessageCount.setOnClickListener(new AccountClickListener(account, SearchModifier.UNREAD));
|
||||
|
||||
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)
|
||||
@ -992,4 +887,108 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
public View chip;
|
||||
}
|
||||
}
|
||||
private Flag[] combine(Flag[] set1, Flag[] set2)
|
||||
{
|
||||
if (set1 == null)
|
||||
{
|
||||
return set2;
|
||||
}
|
||||
if (set2 == null)
|
||||
{
|
||||
return set1;
|
||||
}
|
||||
Set<Flag> flags = new HashSet<Flag>();
|
||||
for (Flag flag : set1)
|
||||
{
|
||||
flags.add(flag);
|
||||
}
|
||||
for (Flag flag : set2)
|
||||
{
|
||||
flags.add(flag);
|
||||
}
|
||||
return flags.toArray(new Flag[0]);
|
||||
}
|
||||
|
||||
private class AccountClickListener implements OnClickListener
|
||||
{
|
||||
|
||||
final BaseAccount account;
|
||||
final SearchModifier searchModifier;
|
||||
AccountClickListener(BaseAccount nAccount, SearchModifier nSearchModifier )
|
||||
{
|
||||
account = nAccount;
|
||||
searchModifier = nSearchModifier;
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
String description = getString(R.string.search_title, account.getDescription(), getString(searchModifier.resId));
|
||||
if (account instanceof SearchAccount)
|
||||
{
|
||||
SearchAccount searchAccount = (SearchAccount)account;
|
||||
|
||||
MessageList.actionHandle(Accounts.this,
|
||||
description, "", searchAccount.isIntegrate(),
|
||||
combine(searchAccount.getRequiredFlags(), searchModifier.requiredFlags),
|
||||
combine(searchAccount.getForbiddenFlags(), searchModifier.forbiddenFlags));
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchSpecification searchSpec = new SearchSpecification()
|
||||
{
|
||||
@Override
|
||||
public String[] getAccountUuids()
|
||||
{
|
||||
return new String[] { account.getUuid() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag[] getForbiddenFlags()
|
||||
{
|
||||
return searchModifier.forbiddenFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag[] getRequiredFlags()
|
||||
{
|
||||
return searchModifier.requiredFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIntegrate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
MessageList.actionHandle(Accounts.this, description, searchSpec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private enum SearchModifier
|
||||
{
|
||||
FLAGGED(R.string.flagged_modifier, new Flag[] { Flag.FLAGGED}, null), UNREAD(R.string.unread_modifier, null, new Flag[] { Flag.SEEN} );
|
||||
|
||||
final int resId;
|
||||
final Flag[] requiredFlags;
|
||||
final Flag[] forbiddenFlags;
|
||||
|
||||
SearchModifier(int nResId, Flag[] nRequiredFlags, Flag[] nForbiddenFlags)
|
||||
{
|
||||
resId = nResId;
|
||||
requiredFlags = nRequiredFlags;
|
||||
forbiddenFlags = nForbiddenFlags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ public class MessageList
|
||||
private static final String EXTRA_QUERY_FLAGS = "queryFlags";
|
||||
private static final String EXTRA_FORBIDDEN_FLAGS = "forbiddenFlags";
|
||||
private static final String EXTRA_INTEGRATE = "integrate";
|
||||
private static final String EXTRA_ACCOUNT_UUIDS = "accountUuids";
|
||||
private static final String EXTRA_TITLE = "title";
|
||||
private static final String EXTRA_SEARCH_SPECIFICATION = "searchSpecification";
|
||||
|
||||
private ListView mListView;
|
||||
|
||||
@ -98,6 +98,7 @@ public class MessageList
|
||||
private Flag[] mQueryFlags = null;
|
||||
private Flag[] mForbiddenFlags = null;
|
||||
private boolean mIntegrate = false;
|
||||
private String[] mAccountUuids = null;
|
||||
private String mTitle;
|
||||
|
||||
private MessageListHandler mHandler = new MessageListHandler();
|
||||
@ -327,6 +328,25 @@ public class MessageList
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
public static void actionHandle(Context context, String title, SearchSpecification searchSpecification)
|
||||
{
|
||||
Intent intent = new Intent(context, MessageList.class);
|
||||
intent.putExtra(EXTRA_QUERY, searchSpecification.getQuery());
|
||||
if (searchSpecification.getRequiredFlags() != null)
|
||||
{
|
||||
intent.putExtra(EXTRA_QUERY_FLAGS, Utility.combine(searchSpecification.getRequiredFlags(), ','));
|
||||
}
|
||||
if (searchSpecification.getForbiddenFlags() != null)
|
||||
{
|
||||
intent.putExtra(EXTRA_FORBIDDEN_FLAGS, Utility.combine(searchSpecification.getForbiddenFlags(), ','));
|
||||
}
|
||||
intent.putExtra(EXTRA_INTEGRATE, searchSpecification.isIntegrate());
|
||||
intent.putExtra(EXTRA_ACCOUNT_UUIDS, searchSpecification.getAccountUuids());
|
||||
intent.putExtra(EXTRA_TITLE, title);
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||
{
|
||||
@ -393,6 +413,8 @@ public class MessageList
|
||||
}
|
||||
}
|
||||
mIntegrate = intent.getBooleanExtra(EXTRA_INTEGRATE, false);
|
||||
mAccountUuids = intent.getStringArrayExtra(EXTRA_ACCOUNT_UUIDS);
|
||||
|
||||
mTitle = intent.getStringExtra(EXTRA_TITLE);
|
||||
|
||||
// Take the initial folder into account only if we are *not* restoring the
|
||||
@ -466,7 +488,7 @@ public class MessageList
|
||||
}
|
||||
else if (mQueryString != null)
|
||||
{
|
||||
mController.searchLocalMessages(null, mQueryString, null, mIntegrate, mQueryFlags, mForbiddenFlags, mAdapter.mListener);
|
||||
mController.searchLocalMessages(mAccountUuids, mQueryString, null, mIntegrate, mQueryFlags, mForbiddenFlags, mAdapter.mListener);
|
||||
}
|
||||
|
||||
mHandler.refreshTitle();
|
||||
|
Loading…
Reference in New Issue
Block a user