mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-02 00:25:10 -04:00
refactor search code to allow us to search on specific fields.
This commit is contained in:
parent
cce6a95c2c
commit
49c4a4f97c
@ -898,8 +898,10 @@ public class MessagingController implements Runnable
|
||||
|
||||
try
|
||||
{
|
||||
String[] queryFields = {"html_content","subject","sender_list"};
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
localStore.searchForMessages(retrievalListener, query, foldersToSearch,
|
||||
localStore.searchForMessages(retrievalListener, queryFields
|
||||
, query, foldersToSearch,
|
||||
messagesToSearch == null ? null : messagesToSearch.toArray(new Message[0]),
|
||||
requiredFlags, forbiddenFlags);
|
||||
|
||||
|
@ -644,7 +644,7 @@ public class LocalStore extends Store implements Serializable
|
||||
return true;
|
||||
}
|
||||
|
||||
public Message[] searchForMessages(MessageRetrievalListener listener, String queryString,
|
||||
public Message[] searchForMessages(MessageRetrievalListener listener, String[] queryFields, String queryString,
|
||||
List<LocalFolder> folders, Message[] messages, final Flag[] requiredFlags, final Flag[] forbiddenFlags) throws MessagingException
|
||||
{
|
||||
List<String> args = new LinkedList<String>();
|
||||
@ -652,11 +652,22 @@ public class LocalStore extends Store implements Serializable
|
||||
StringBuilder whereClause = new StringBuilder();
|
||||
if (queryString != null && queryString.length() > 0)
|
||||
{
|
||||
boolean anyAdded = false;
|
||||
String likeString = "%"+queryString+"%";
|
||||
whereClause.append(" AND (html_content LIKE ? OR subject LIKE ? OR sender_list LIKE ?)");
|
||||
args.add(likeString);
|
||||
args.add(likeString);
|
||||
args.add(likeString);
|
||||
whereClause.append(" AND (");
|
||||
for (String queryField : queryFields) {
|
||||
|
||||
if (anyAdded == true)
|
||||
{
|
||||
whereClause.append(" OR ");
|
||||
}
|
||||
whereClause.append(queryField + " LIKE ? ");
|
||||
args.add(likeString);
|
||||
anyAdded = true;
|
||||
}
|
||||
|
||||
|
||||
whereClause.append(" )");
|
||||
}
|
||||
if (folders != null && folders.size() > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user