mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-16 06:25:06 -05:00
Clone LocalSearch object before modifying it for unread/starred search
This commit is contained in:
parent
faa666394c
commit
65b3a57340
@ -64,7 +64,6 @@ import com.fsck.k9.Preferences;
|
|||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
|
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
|
||||||
import com.fsck.k9.activity.misc.NonConfigurationInstance;
|
import com.fsck.k9.activity.misc.NonConfigurationInstance;
|
||||||
import com.fsck.k9.activity.setup.AccountSettings;
|
|
||||||
import com.fsck.k9.activity.setup.AccountSetupBasics;
|
import com.fsck.k9.activity.setup.AccountSetupBasics;
|
||||||
import com.fsck.k9.activity.setup.Prefs;
|
import com.fsck.k9.activity.setup.Prefs;
|
||||||
import com.fsck.k9.activity.setup.WelcomeMessage;
|
import com.fsck.k9.activity.setup.WelcomeMessage;
|
||||||
@ -1788,7 +1787,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
|||||||
LocalSearch search = null;
|
LocalSearch search = null;
|
||||||
|
|
||||||
if (account instanceof SearchAccount) {
|
if (account instanceof SearchAccount) {
|
||||||
search = ((SearchAccount) account).getRelatedSearch();
|
search = ((SearchAccount) account).getRelatedSearch().clone();
|
||||||
search.setName(description);
|
search.setName(description);
|
||||||
} else {
|
} else {
|
||||||
search = new LocalSearch(description);
|
search = new LocalSearch(description);
|
||||||
|
@ -124,6 +124,35 @@ public class ConditionsTreeNode implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* package */ ConditionsTreeNode cloneTree() {
|
||||||
|
if (mParent != null) {
|
||||||
|
throw new IllegalStateException("Can't call cloneTree() for a non-root node");
|
||||||
|
}
|
||||||
|
|
||||||
|
ConditionsTreeNode copy = new ConditionsTreeNode(mCondition.clone());
|
||||||
|
|
||||||
|
copy.mLeftMPTTMarker = mLeftMPTTMarker;
|
||||||
|
copy.mRightMPTTMarker = mRightMPTTMarker;
|
||||||
|
|
||||||
|
copy.mLeft = (mLeft == null) ? null : mLeft.cloneNode(copy);
|
||||||
|
copy.mRight = (mRight == null) ? null : mRight.cloneNode(copy);
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConditionsTreeNode cloneNode(ConditionsTreeNode parent) {
|
||||||
|
ConditionsTreeNode copy = new ConditionsTreeNode(parent, mValue);
|
||||||
|
|
||||||
|
copy.mCondition = mCondition.clone();
|
||||||
|
copy.mLeftMPTTMarker = mLeftMPTTMarker;
|
||||||
|
copy.mRightMPTTMarker = mRightMPTTMarker;
|
||||||
|
|
||||||
|
copy.mLeft = (mLeft == null) ? null : mLeft.cloneNode(copy);
|
||||||
|
copy.mRight = (mRight == null) ? null : mRight.cloneNode(copy);
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Public modifiers
|
// Public modifiers
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
@ -80,6 +80,15 @@ public class LocalSearch implements SearchSpecification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalSearch clone() {
|
||||||
|
ConditionsTreeNode conditions = (mConditions == null) ? null : mConditions.cloneTree();
|
||||||
|
|
||||||
|
LocalSearch copy = new LocalSearch(mName, conditions, null, mPredefined);
|
||||||
|
copy.mAccountUuids = new HashSet<String>(mAccountUuids);
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Public manipulation methods
|
// Public manipulation methods
|
||||||
|
@ -134,6 +134,11 @@ public interface SearchSpecification extends Parcelable {
|
|||||||
this.field = Searchfield.values()[in.readInt()];
|
this.field = Searchfield.values()[in.readInt()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SearchCondition clone() {
|
||||||
|
return new SearchCondition(field, attribute, value);
|
||||||
|
}
|
||||||
|
|
||||||
public String toHumanString() {
|
public String toHumanString() {
|
||||||
return field.toString() + attribute.toString();
|
return field.toString() + attribute.toString();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user