Fixed search on keyword

pull/147/head
M66B 6 years ago
parent 3754a55ab7
commit 0ab8452495

@ -44,6 +44,7 @@ import javax.mail.search.FlagTerm;
import javax.mail.search.FromStringTerm; import javax.mail.search.FromStringTerm;
import javax.mail.search.OrTerm; import javax.mail.search.OrTerm;
import javax.mail.search.RecipientStringTerm; import javax.mail.search.RecipientStringTerm;
import javax.mail.search.SearchTerm;
import javax.mail.search.SubjectTerm; import javax.mail.search.SubjectTerm;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
@ -168,22 +169,26 @@ public class ViewModelBrowse extends ViewModel {
Log.i("Boundary searching=" + state.search); Log.i("Boundary searching=" + state.search);
if (state.search == null) if (state.search == null)
state.imessages = state.ifolder.getMessages(); state.imessages = state.ifolder.getMessages();
else else {
state.imessages = state.ifolder.search( SearchTerm term = new OrTerm(
new OrTerm(
new FromStringTerm(state.search),
new RecipientStringTerm(Message.RecipientType.TO, state.search)
),
new OrTerm( new OrTerm(
new OrTerm( new SubjectTerm(state.search),
new OrTerm( new BodyTerm(state.search)
new FromStringTerm(state.search),
new RecipientStringTerm(Message.RecipientType.TO, state.search)
),
new OrTerm(
new SubjectTerm(state.search),
new BodyTerm(state.search)
)
),
new FlagTerm(new Flags(Helper.sanitizeKeyword(state.search)), true)
) )
); );
if (folder.keywords.length > 0) {
Log.i("Boundary search for keywords");
term = new OrTerm(term, new FlagTerm(
new Flags(Helper.sanitizeKeyword(state.search)), true));
}
state.imessages = state.ifolder.search(term);
}
Log.i("Boundary found messages=" + state.imessages.length); Log.i("Boundary found messages=" + state.imessages.length);
state.index = state.imessages.length - 1; state.index = state.imessages.length - 1;

Loading…
Cancel
Save