mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
Code style cleanup
This commit is contained in:
parent
fff94956f4
commit
20ed1ebe61
@ -36,8 +36,8 @@ import com.fsck.k9.mail.Message;
|
|||||||
import com.fsck.k9.mail.store.StorageManager;
|
import com.fsck.k9.mail.store.StorageManager;
|
||||||
import com.fsck.k9.search.LocalSearch;
|
import com.fsck.k9.search.LocalSearch;
|
||||||
import com.fsck.k9.search.SearchSpecification;
|
import com.fsck.k9.search.SearchSpecification;
|
||||||
import com.fsck.k9.search.SearchSpecification.ATTRIBUTE;
|
import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||||
import com.fsck.k9.search.SearchSpecification.SEARCHFIELD;
|
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||||
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
||||||
|
|
||||||
|
|
||||||
@ -134,8 +134,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER));
|
mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER));
|
||||||
|
|
||||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||||
mSearch.or(new SearchCondition(SEARCHFIELD.SENDER, ATTRIBUTE.CONTAINS, query));
|
mSearch.or(new SearchCondition(Searchfield.SENDER, Attribute.CONTAINS, query));
|
||||||
mSearch.or(new SearchCondition(SEARCHFIELD.SUBJECT, ATTRIBUTE.CONTAINS, query));
|
mSearch.or(new SearchCondition(Searchfield.SUBJECT, Attribute.CONTAINS, query));
|
||||||
|
|
||||||
mIsRemote = true;
|
mIsRemote = true;
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
public void showMoreFromSameSender(String senderAddress) {
|
public void showMoreFromSameSender(String senderAddress) {
|
||||||
LocalSearch tmpSearch = new LocalSearch("From " + senderAddress);
|
LocalSearch tmpSearch = new LocalSearch("From " + senderAddress);
|
||||||
tmpSearch.addAccountUuids(mSearch.getAccountUuids());
|
tmpSearch.addAccountUuids(mSearch.getAccountUuids());
|
||||||
tmpSearch.and(SEARCHFIELD.SENDER, senderAddress, ATTRIBUTE.CONTAINS);
|
tmpSearch.and(Searchfield.SENDER, senderAddress, Attribute.CONTAINS);
|
||||||
|
|
||||||
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false);
|
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false);
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
public void showThread(Account account, String folderName, long threadRootId) {
|
public void showThread(Account account, String folderName, long threadRootId) {
|
||||||
LocalSearch tmpSearch = new LocalSearch();
|
LocalSearch tmpSearch = new LocalSearch();
|
||||||
tmpSearch.addAccountUuids(mSearch.getAccountUuids());
|
tmpSearch.addAccountUuids(mSearch.getAccountUuids());
|
||||||
tmpSearch.and(SEARCHFIELD.THREAD_ROOT, String.valueOf(threadRootId), ATTRIBUTE.EQUALS);
|
tmpSearch.and(Searchfield.THREAD_ROOT, String.valueOf(threadRootId), Attribute.EQUALS);
|
||||||
|
|
||||||
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false);
|
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false);
|
||||||
addMessageListFragment(fragment);
|
addMessageListFragment(fragment);
|
||||||
|
@ -71,7 +71,7 @@ import com.fsck.k9.mail.store.StorageManager.StorageProvider;
|
|||||||
import com.fsck.k9.provider.AttachmentProvider;
|
import com.fsck.k9.provider.AttachmentProvider;
|
||||||
import com.fsck.k9.search.ConditionsTreeNode;
|
import com.fsck.k9.search.ConditionsTreeNode;
|
||||||
import com.fsck.k9.search.LocalSearch;
|
import com.fsck.k9.search.LocalSearch;
|
||||||
import com.fsck.k9.search.SearchSpecification.SEARCHFIELD;
|
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -936,7 +936,7 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
|
|
||||||
// update some references in the search that have to be bound to this one store
|
// update some references in the search that have to be bound to this one store
|
||||||
for (ConditionsTreeNode node : search.getLeafSet()) {
|
for (ConditionsTreeNode node : search.getLeafSet()) {
|
||||||
if (node.mCondition.field == SEARCHFIELD.FOLDER) {
|
if (node.mCondition.field == Searchfield.FOLDER) {
|
||||||
// TODO find better solution
|
// TODO find better solution
|
||||||
if (isFolderId(node.mCondition.value)) {
|
if (isFolderId(node.mCondition.value)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -9,8 +9,8 @@ import android.database.Cursor;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.fsck.k9.search.SearchSpecification.ATTRIBUTE;
|
import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||||
import com.fsck.k9.search.SearchSpecification.SEARCHFIELD;
|
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||||
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,12 +19,10 @@ import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
|||||||
*
|
*
|
||||||
* TODO removing conditions from the tree
|
* TODO removing conditions from the tree
|
||||||
* TODO implement NOT as a node again
|
* TODO implement NOT as a node again
|
||||||
*
|
|
||||||
* @author dzan
|
|
||||||
*/
|
*/
|
||||||
public class ConditionsTreeNode implements Parcelable{
|
public class ConditionsTreeNode implements Parcelable {
|
||||||
|
|
||||||
public enum OPERATOR {
|
public enum Operator {
|
||||||
AND, OR, CONDITION;
|
AND, OR, CONDITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +34,7 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
* If mValue isn't CONDITION then mCondition contains a real
|
* If mValue isn't CONDITION then mCondition contains a real
|
||||||
* condition, otherwise it's null.
|
* condition, otherwise it's null.
|
||||||
*/
|
*/
|
||||||
public OPERATOR mValue;
|
public Operator mValue;
|
||||||
public SearchCondition mCondition;
|
public SearchCondition mCondition;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -71,7 +69,7 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
// other nodes
|
// other nodes
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
tmp = buildNodeFromRow(cursor);
|
tmp = buildNodeFromRow(cursor);
|
||||||
if (tmp.mRightMPTTMarker < stack.peek().mRightMPTTMarker ){
|
if (tmp.mRightMPTTMarker < stack.peek().mRightMPTTMarker) {
|
||||||
stack.peek().mLeft = tmp;
|
stack.peek().mLeft = tmp;
|
||||||
stack.push(tmp);
|
stack.push(tmp);
|
||||||
} else {
|
} else {
|
||||||
@ -94,11 +92,11 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
ConditionsTreeNode result = null;
|
ConditionsTreeNode result = null;
|
||||||
SearchCondition condition = null;
|
SearchCondition condition = null;
|
||||||
|
|
||||||
OPERATOR tmpValue = ConditionsTreeNode.OPERATOR.valueOf(cursor.getString(5));
|
Operator tmpValue = ConditionsTreeNode.Operator.valueOf(cursor.getString(5));
|
||||||
|
|
||||||
if (tmpValue == OPERATOR.CONDITION) {
|
if (tmpValue == Operator.CONDITION) {
|
||||||
condition = new SearchCondition(SEARCHFIELD.valueOf(cursor.getString(0)),
|
condition = new SearchCondition(Searchfield.valueOf(cursor.getString(0)),
|
||||||
ATTRIBUTE.valueOf(cursor.getString(2)), cursor.getString(1));
|
Attribute.valueOf(cursor.getString(2)), cursor.getString(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new ConditionsTreeNode(condition);
|
result = new ConditionsTreeNode(condition);
|
||||||
@ -116,10 +114,10 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
public ConditionsTreeNode(SearchCondition condition) {
|
public ConditionsTreeNode(SearchCondition condition) {
|
||||||
mParent = null;
|
mParent = null;
|
||||||
mCondition = condition;
|
mCondition = condition;
|
||||||
mValue = OPERATOR.CONDITION;
|
mValue = Operator.CONDITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionsTreeNode(ConditionsTreeNode parent, OPERATOR op) {
|
public ConditionsTreeNode(ConditionsTreeNode parent, Operator op) {
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
mValue = op;
|
mValue = op;
|
||||||
mCondition = null;
|
mCondition = null;
|
||||||
@ -138,7 +136,7 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public ConditionsTreeNode and(ConditionsTreeNode expr) throws Exception {
|
public ConditionsTreeNode and(ConditionsTreeNode expr) throws Exception {
|
||||||
return add(expr, OPERATOR.AND);
|
return add(expr, Operator.AND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +166,7 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public ConditionsTreeNode or(ConditionsTreeNode expr) throws Exception {
|
public ConditionsTreeNode or(ConditionsTreeNode expr) throws Exception {
|
||||||
return add(expr, OPERATOR.OR);
|
return add(expr, Operator.OR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,10 +242,17 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
Stack<ConditionsTreeNode> stack = new Stack<ConditionsTreeNode>();
|
Stack<ConditionsTreeNode> stack = new Stack<ConditionsTreeNode>();
|
||||||
stack.push(this);
|
stack.push(this);
|
||||||
|
|
||||||
while(!stack.isEmpty()) {
|
while (!stack.isEmpty()) {
|
||||||
ConditionsTreeNode current = stack.pop( );
|
ConditionsTreeNode current = stack.pop();
|
||||||
if( current.mLeft != null ) stack.push( current.mLeft );
|
|
||||||
if( current.mRight != null ) stack.push( current.mRight );
|
if (current.mLeft != null) {
|
||||||
|
stack.push(current.mLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.mRight != null) {
|
||||||
|
stack.push(current.mRight);
|
||||||
|
}
|
||||||
|
|
||||||
result.add(current);
|
result.add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +278,7 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
* @return New parent node, containing the operator.
|
* @return New parent node, containing the operator.
|
||||||
* @throws Exception Throws when the provided new node does not have a null parent.
|
* @throws Exception Throws when the provided new node does not have a null parent.
|
||||||
*/
|
*/
|
||||||
private ConditionsTreeNode add(ConditionsTreeNode node, OPERATOR op) throws Exception{
|
private ConditionsTreeNode add(ConditionsTreeNode node, Operator op) throws Exception {
|
||||||
if (node.mParent != null) {
|
if (node.mParent != null) {
|
||||||
throw new Exception("Can only add new expressions from root node down.");
|
throw new Exception("Can only add new expressions from root node down.");
|
||||||
}
|
}
|
||||||
@ -285,8 +290,8 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
if (mParent != null) {
|
if (mParent != null) {
|
||||||
mParent.updateChild(this, tmpNode);
|
mParent.updateChild(this, tmpNode);
|
||||||
}
|
}
|
||||||
this.mParent = tmpNode;
|
|
||||||
|
|
||||||
|
this.mParent = tmpNode;
|
||||||
node.mParent = tmpNode;
|
node.mParent = tmpNode;
|
||||||
|
|
||||||
return tmpNode;
|
return tmpNode;
|
||||||
@ -317,21 +322,21 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
* @return Set of leaves being completed.
|
* @return Set of leaves being completed.
|
||||||
*/
|
*/
|
||||||
private HashSet<ConditionsTreeNode> getLeafSet(HashSet<ConditionsTreeNode> leafSet) {
|
private HashSet<ConditionsTreeNode> getLeafSet(HashSet<ConditionsTreeNode> leafSet) {
|
||||||
// if we ended up in a leaf, add ourself and return
|
|
||||||
if (mLeft == null && mRight == null) {
|
if (mLeft == null && mRight == null) {
|
||||||
|
// if we ended up in a leaf, add ourself and return
|
||||||
leafSet.add(this);
|
leafSet.add(this);
|
||||||
return leafSet;
|
return leafSet;
|
||||||
// we didn't end up in a leaf
|
|
||||||
} else {
|
|
||||||
if (mLeft != null) {
|
|
||||||
mLeft.getLeafSet(leafSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mRight != null) {
|
|
||||||
mRight.getLeafSet(leafSet);
|
|
||||||
}
|
|
||||||
return leafSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we didn't end up in a leaf
|
||||||
|
if (mLeft != null) {
|
||||||
|
mLeft.getLeafSet(leafSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRight != null) {
|
||||||
|
mRight.getLeafSet(leafSet);
|
||||||
|
}
|
||||||
|
return leafSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -343,12 +348,15 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
*/
|
*/
|
||||||
private int applyMPTTLabel(int label) {
|
private int applyMPTTLabel(int label) {
|
||||||
mLeftMPTTMarker = label;
|
mLeftMPTTMarker = label;
|
||||||
if (mLeft != null){
|
|
||||||
|
if (mLeft != null) {
|
||||||
label = mLeft.applyMPTTLabel(label += 1);
|
label = mLeft.applyMPTTLabel(label += 1);
|
||||||
}
|
}
|
||||||
if (mRight != null){
|
|
||||||
|
if (mRight != null) {
|
||||||
label = mRight.applyMPTTLabel(label += 1);
|
label = mRight.applyMPTTLabel(label += 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
++label;
|
++label;
|
||||||
mRightMPTTMarker = label;
|
mRightMPTTMarker = label;
|
||||||
return label;
|
return label;
|
||||||
@ -374,26 +382,31 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
dest.writeParcelable(mRight, flags);
|
dest.writeParcelable(mRight, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<ConditionsTreeNode> CREATOR
|
public static final Parcelable.Creator<ConditionsTreeNode> CREATOR =
|
||||||
= new Parcelable.Creator<ConditionsTreeNode>() {
|
new Parcelable.Creator<ConditionsTreeNode>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public ConditionsTreeNode createFromParcel(Parcel in) {
|
public ConditionsTreeNode createFromParcel(Parcel in) {
|
||||||
return new ConditionsTreeNode(in);
|
return new ConditionsTreeNode(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ConditionsTreeNode[] newArray(int size) {
|
public ConditionsTreeNode[] newArray(int size) {
|
||||||
return new ConditionsTreeNode[size];
|
return new ConditionsTreeNode[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ConditionsTreeNode(Parcel in) {
|
private ConditionsTreeNode(Parcel in) {
|
||||||
mValue = OPERATOR.values()[in.readInt()];
|
mValue = Operator.values()[in.readInt()];
|
||||||
mCondition = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
mCondition = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
||||||
mLeft = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
mLeft = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
||||||
mRight = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
mRight = in.readParcelable(ConditionsTreeNode.class.getClassLoader());
|
||||||
mParent = null;
|
mParent = null;
|
||||||
|
|
||||||
if (mLeft != null) {
|
if (mLeft != null) {
|
||||||
mLeft.mParent = this;
|
mLeft.mParent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mRight != null) {
|
if (mRight != null) {
|
||||||
mRight.mParent = this;
|
mRight.mParent = this;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,10 @@ import com.fsck.k9.mail.Flag;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a local search.
|
* This class represents a local search.
|
||||||
|
*
|
||||||
* Removing conditions could be done through matching there unique id in the leafset and then
|
* Removing conditions could be done through matching there unique id in the leafset and then
|
||||||
* removing them from the tree.
|
* removing them from the tree.
|
||||||
*
|
*
|
||||||
* @author dzan
|
|
||||||
*
|
|
||||||
* TODO implement a complete addAllowedFolder method
|
* TODO implement a complete addAllowedFolder method
|
||||||
* TODO conflicting conditions check on add
|
* TODO conflicting conditions check on add
|
||||||
* TODO duplicate condition checking?
|
* TODO duplicate condition checking?
|
||||||
@ -43,7 +41,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
* Use this only if the search won't be saved. Saved searches need
|
* Use this only if the search won't be saved. Saved searches need
|
||||||
* a name!
|
* a name!
|
||||||
*/
|
*/
|
||||||
public LocalSearch(){}
|
public LocalSearch() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -141,7 +139,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
*
|
*
|
||||||
* @throws IllegalConditionException
|
* @throws IllegalConditionException
|
||||||
*/
|
*/
|
||||||
public void and(SEARCHFIELD field, String value, ATTRIBUTE attribute) {
|
public void and(Searchfield field, String value, Attribute attribute) {
|
||||||
and(new SearchCondition(field, attribute, value));
|
and(new SearchCondition(field, attribute, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +224,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
public void allRequiredFlags(Flag[] requiredFlags) {
|
public void allRequiredFlags(Flag[] requiredFlags) {
|
||||||
if (requiredFlags != null) {
|
if (requiredFlags != null) {
|
||||||
for (Flag f : requiredFlags) {
|
for (Flag f : requiredFlags) {
|
||||||
and(new SearchCondition(SEARCHFIELD.FLAG, ATTRIBUTE.CONTAINS, f.name()));
|
and(new SearchCondition(Searchfield.FLAG, Attribute.CONTAINS, f.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +238,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
public void allForbiddenFlags(Flag[] forbiddenFlags) {
|
public void allForbiddenFlags(Flag[] forbiddenFlags) {
|
||||||
if (forbiddenFlags != null) {
|
if (forbiddenFlags != null) {
|
||||||
for (Flag f : forbiddenFlags) {
|
for (Flag f : forbiddenFlags) {
|
||||||
and(new SearchCondition(SEARCHFIELD.FLAG, ATTRIBUTE.NOT_CONTAINS, f.name()));
|
and(new SearchCondition(Searchfield.FLAG, Attribute.NOT_CONTAINS, f.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +259,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
* - do and on root of it & rest of search
|
* - do and on root of it & rest of search
|
||||||
* - do or between folder nodes
|
* - do or between folder nodes
|
||||||
*/
|
*/
|
||||||
mConditions = and(new SearchCondition(SEARCHFIELD.FOLDER, ATTRIBUTE.EQUALS, name));
|
mConditions = and(new SearchCondition(Searchfield.FOLDER, Attribute.EQUALS, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -272,8 +270,8 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
public List<String> getFolderNames() {
|
public List<String> getFolderNames() {
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
ArrayList<String> results = new ArrayList<String>();
|
||||||
for (ConditionsTreeNode node : mLeafSet) {
|
for (ConditionsTreeNode node : mLeafSet) {
|
||||||
if (node.mCondition.field == SEARCHFIELD.FOLDER
|
if (node.mCondition.field == Searchfield.FOLDER &&
|
||||||
&& node.mCondition.attribute == ATTRIBUTE.EQUALS) {
|
node.mCondition.attribute == Attribute.EQUALS) {
|
||||||
results.add(node.mCondition.value);
|
results.add(node.mCondition.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,8 +296,8 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
*/
|
*/
|
||||||
public String getRemoteSearchArguments() {
|
public String getRemoteSearchArguments() {
|
||||||
for (ConditionsTreeNode node : getLeafSet()) {
|
for (ConditionsTreeNode node : getLeafSet()) {
|
||||||
if (node.getCondition().field == SEARCHFIELD.SUBJECT
|
if (node.getCondition().field == Searchfield.SUBJECT ||
|
||||||
|| node.getCondition().field == SEARCHFIELD.SENDER ) {
|
node.getCondition().field == Searchfield.SENDER ) {
|
||||||
return node.getCondition().value;
|
return node.getCondition().value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,8 +309,9 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
*
|
*
|
||||||
* @return Name of the search.
|
* @return Name of the search.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return (mName == null ? "" : mName);
|
return (mName == null) ? "" : mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,7 +332,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
@Override
|
@Override
|
||||||
public String[] getAccountUuids() {
|
public String[] getAccountUuids() {
|
||||||
if (mAccountUuids.size() == 0) {
|
if (mAccountUuids.size() == 0) {
|
||||||
return new String[] {SearchSpecification.ALL_ACCOUNTS};
|
return new String[] { SearchSpecification.ALL_ACCOUNTS };
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] tmp = new String[mAccountUuids.size()];
|
String[] tmp = new String[mAccountUuids.size()];
|
||||||
@ -367,12 +366,15 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
dest.writeParcelable(mConditions, flags);
|
dest.writeParcelable(mConditions, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<LocalSearch> CREATOR
|
public static final Parcelable.Creator<LocalSearch> CREATOR =
|
||||||
= new Parcelable.Creator<LocalSearch>() {
|
new Parcelable.Creator<LocalSearch>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public LocalSearch createFromParcel(Parcel in) {
|
public LocalSearch createFromParcel(Parcel in) {
|
||||||
return new LocalSearch(in);
|
return new LocalSearch(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LocalSearch[] newArray(int size) {
|
public LocalSearch[] newArray(int size) {
|
||||||
return new LocalSearch[size];
|
return new LocalSearch[size];
|
||||||
}
|
}
|
||||||
@ -380,7 +382,7 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
|
|
||||||
public LocalSearch(Parcel in) {
|
public LocalSearch(Parcel in) {
|
||||||
mName = in.readString();
|
mName = in.readString();
|
||||||
mPredefined = in.readByte() == 1;
|
mPredefined = (in.readByte() == 1);
|
||||||
mAccountUuids.addAll(in.createStringArrayList());
|
mAccountUuids.addAll(in.createStringArrayList());
|
||||||
mConditions = in.readParcelable(LocalSearch.class.getClassLoader());
|
mConditions = in.readParcelable(LocalSearch.class.getClassLoader());
|
||||||
mLeafSet = mConditions.getLeafSet();
|
mLeafSet = mConditions.getLeafSet();
|
||||||
|
@ -31,19 +31,21 @@ public class SearchAccount implements BaseAccount {
|
|||||||
context.getString(R.string.integrated_inbox_detail));
|
context.getString(R.string.integrated_inbox_detail));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mEmail = null;
|
private String mEmail;
|
||||||
private String mDescription = null;
|
private String mDescription;
|
||||||
private LocalSearch mSearch = null;
|
private LocalSearch mSearch;
|
||||||
private String mFakeUuid = null;
|
private String mFakeUuid;
|
||||||
|
|
||||||
|
public SearchAccount(LocalSearch search, String description, String email)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
public SearchAccount(LocalSearch search, String description, String email) throws IllegalArgumentException{
|
|
||||||
if (search == null) {
|
if (search == null) {
|
||||||
throw new IllegalArgumentException("Provided LocalSearch was null");
|
throw new IllegalArgumentException("Provided LocalSearch was null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mSearch = search;
|
mSearch = search;
|
||||||
this.mDescription = description;
|
mDescription = description;
|
||||||
this.mEmail = email;
|
mEmail = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +72,6 @@ public class SearchAccount implements BaseAccount {
|
|||||||
return mSearch;
|
return mSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/*
|
/*
|
||||||
* This will only be used when accessed as an Account. If that
|
* This will only be used when accessed as an Account. If that
|
||||||
* is the case we don't want to return the uuid of a real account since
|
* is the case we don't want to return the uuid of a real account since
|
||||||
@ -78,8 +79,9 @@ public class SearchAccount implements BaseAccount {
|
|||||||
* a Search then methods from LocalSearch will be called which do handle
|
* a Search then methods from LocalSearch will be called which do handle
|
||||||
* things nice.
|
* things nice.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
if (mFakeUuid == null){
|
if (mFakeUuid == null) {
|
||||||
mFakeUuid = UUID.randomUUID().toString();
|
mFakeUuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
return mFakeUuid;
|
return mFakeUuid;
|
||||||
|
@ -7,8 +7,8 @@ import com.fsck.k9.mail.Flag;
|
|||||||
* This enum represents filtering parameters used by {@link com.fsck.k9.search.SearchAccount}.
|
* This enum represents filtering parameters used by {@link com.fsck.k9.search.SearchAccount}.
|
||||||
*/
|
*/
|
||||||
public enum SearchModifier {
|
public enum SearchModifier {
|
||||||
FLAGGED(R.string.flagged_modifier, new Flag[]{Flag.FLAGGED}, null),
|
FLAGGED(R.string.flagged_modifier, new Flag[] { Flag.FLAGGED }, null),
|
||||||
UNREAD(R.string.unread_modifier, null, new Flag[]{Flag.SEEN});
|
UNREAD(R.string.unread_modifier, null, new Flag[] { Flag.SEEN });
|
||||||
|
|
||||||
public final int resId;
|
public final int resId;
|
||||||
public final Flag[] requiredFlags;
|
public final Flag[] requiredFlags;
|
||||||
|
@ -34,13 +34,13 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// ATTRIBUTE enum
|
// ATTRIBUTE enum
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public enum ATTRIBUTE {
|
public enum Attribute {
|
||||||
CONTAINS(false), EQUALS(false), STARTSWITH(false), ENDSWITH(false),
|
CONTAINS(false), EQUALS(false), STARTSWITH(false), ENDSWITH(false),
|
||||||
NOT_CONTAINS(true), NOT_EQUALS(true), NOT_STARTSWITH(true), NOT_ENDSWITH(true);
|
NOT_CONTAINS(true), NOT_EQUALS(true), NOT_STARTSWITH(true), NOT_ENDSWITH(true);
|
||||||
|
|
||||||
private boolean mNegation;
|
private boolean mNegation;
|
||||||
|
|
||||||
private ATTRIBUTE(boolean negation) {
|
private Attribute(boolean negation) {
|
||||||
this.mNegation = negation;
|
this.mNegation = negation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
|
|
||||||
return (mNegation ? " NOT LIKE " : " LIKE ") + queryPart;
|
return (mNegation ? " NOT LIKE " : " LIKE ") + queryPart;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// SEARCHFIELD enum
|
// SEARCHFIELD enum
|
||||||
@ -86,7 +86,7 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
* preview, mime_type
|
* preview, mime_type
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum SEARCHFIELD {
|
public enum Searchfield {
|
||||||
SUBJECT("subject"), DATE("date"), UID("uid"), FLAG("flags"),
|
SUBJECT("subject"), DATE("date"), UID("uid"), FLAG("flags"),
|
||||||
SENDER("sender_list"), TO("to_list"), CC("cc_list"), FOLDER("folder_id"),
|
SENDER("sender_list"), TO("to_list"), CC("cc_list"), FOLDER("folder_id"),
|
||||||
BCC("bcc_list"), REPLY_TO("reply_to_list"), MESSAGE("text_content"),
|
BCC("bcc_list"), REPLY_TO("reply_to_list"), MESSAGE("text_content"),
|
||||||
@ -94,7 +94,7 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
|
|
||||||
private String dbName;
|
private String dbName;
|
||||||
|
|
||||||
private SEARCHFIELD(String dbName) {
|
private Searchfield(String dbName) {
|
||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +116,12 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
*
|
*
|
||||||
* @author dzan
|
* @author dzan
|
||||||
*/
|
*/
|
||||||
public class SearchCondition implements Parcelable{
|
public class SearchCondition implements Parcelable {
|
||||||
public String value;
|
public String value;
|
||||||
public ATTRIBUTE attribute;
|
public Attribute attribute;
|
||||||
public SEARCHFIELD field;
|
public Searchfield field;
|
||||||
|
|
||||||
public SearchCondition(SEARCHFIELD field, ATTRIBUTE attribute, String value) {
|
public SearchCondition(Searchfield field, Attribute attribute, String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
this.field = field;
|
this.field = field;
|
||||||
@ -129,8 +129,8 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
|
|
||||||
private SearchCondition(Parcel in) {
|
private SearchCondition(Parcel in) {
|
||||||
this.value = in.readString();
|
this.value = in.readString();
|
||||||
this.attribute = ATTRIBUTE.values()[in.readInt()];
|
this.attribute = Attribute.values()[in.readInt()];
|
||||||
this.field = SEARCHFIELD.values()[in.readInt()];
|
this.field = Searchfield.values()[in.readInt()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toHumanString() {
|
public String toHumanString() {
|
||||||
@ -146,16 +146,14 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof SearchCondition) {
|
if (o instanceof SearchCondition) {
|
||||||
SearchCondition tmp = (SearchCondition) o;
|
SearchCondition tmp = (SearchCondition) o;
|
||||||
if (tmp.attribute == attribute
|
if (tmp.attribute == attribute &&
|
||||||
&& tmp.value.equals(value)
|
tmp.field == field &&
|
||||||
&& tmp.field == field) {
|
tmp.value.equals(value)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -170,12 +168,15 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
dest.writeInt(field.ordinal());
|
dest.writeInt(field.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<SearchCondition> CREATOR
|
public static final Parcelable.Creator<SearchCondition> CREATOR =
|
||||||
= new Parcelable.Creator<SearchCondition>() {
|
new Parcelable.Creator<SearchCondition>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public SearchCondition createFromParcel(Parcel in) {
|
public SearchCondition createFromParcel(Parcel in) {
|
||||||
return new SearchCondition(in);
|
return new SearchCondition(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SearchCondition[] newArray(int size) {
|
public SearchCondition[] newArray(int size) {
|
||||||
return new SearchCondition[size];
|
return new SearchCondition[size];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user