Limit unified folder type search

master
M66B 3 months ago
parent 42ea0d1b8f
commit 97afde26a8

@ -2348,6 +2348,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
criteria.with_flagged = true;
criteria.with_flag_color = args.getInt("color");
criteria.with_folder_type = args.getString("type");
final long account = args.getLong("account", -1);
final long folder = args.getLong("folder", -1);

@ -128,6 +128,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.server = server;
this.criteria = criteria;
this.pageSize = pageSize;
if (this.folder != null || EntityFolder.INBOX.equals(this.criteria.with_folder_type))
this.criteria.with_folder_type = null;
}
State setCallback(IBoundaryCallbackMessages intf) {
@ -829,6 +832,13 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
return false;
}
if (criteria.with_folder_type != null) {
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(message.folder);
if (folder != null && !criteria.with_folder_type.equals(folder.type))
return false;
}
if (criteria.in_senders) {
if (contains(message.from, criteria.query, partial))
return true;
@ -1059,6 +1069,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
Long after = null;
Long before = null;
Integer touched = null;
String with_folder_type = null;
private static final String FROM = "from:";
private static final String TO = "to:";
@ -1318,6 +1329,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
Helper.humanReadableByteCount(with_size)));
if (touched != null)
flags.add(context.getString(R.string.title_search_flag_touched));
if (with_folder_type != null)
flags.add(EntityFolder.localizeType(context, with_folder_type));
return (query == null ? "" : query + " ")
+ (flags.size() > 0 ? "+" : "")
+ TextUtils.join(",", flags);
@ -1351,7 +1364,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.in_junk == other.in_junk &&
Objects.equals(this.after, other.after) &&
Objects.equals(this.before, other.before) &&
Objects.equals(this.touched, other.touched));
Objects.equals(this.touched, other.touched) &&
Objects.equals(this.with_folder_type, other.with_folder_type));
} else
return false;
}
@ -1406,6 +1420,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (touched != null)
json.put("touched", touched);
if (with_folder_type != null)
json.put("with_folder_type", with_folder_type);
return json;
}
@ -1460,6 +1477,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (json.has("touched"))
criteria.touched = json.getInt("touched");
if (json.has("with_folder_type"))
criteria.with_folder_type = json.getString("with_folder_type");
return criteria;
}
@ -1489,7 +1509,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" junk=" + in_junk +
" after=" + (after == null ? "" : new Date(after)) +
" before=" + (before == null ? "" : new Date(before)) +
" touched=" + touched;
" touched=" + touched +
" folder_type=" + with_folder_type;
}
}
}

@ -73,6 +73,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
final Bundle args = getArguments();
final long account = args.getLong("account", -1);
final long folder = args.getLong("folder", -1);
final String type = args.getString("type");
final Context context = getContext();
final boolean pro = ActivityBilling.isPro(context);
@ -473,6 +474,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
criteria.in_filenames = cbFileNames.isChecked();
criteria.in_headers = cbHeaders.isChecked();
criteria.in_html = cbHtml.isChecked();
criteria.with_folder_type = type;
criteria.with_unseen = cbUnseen.isChecked();
criteria.with_flagged = cbFlagged.isChecked();
criteria.with_hidden = cbHidden.isChecked();
@ -586,6 +588,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
dialog.dismiss();
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
criteria.with_folder_type = type;
int id = v.getId();
if (id == R.id.ibFlagged)
criteria.with_flagged = true;
@ -638,6 +641,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
dialog.dismiss();
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
criteria.with_folder_type = type;
criteria.touched = RECENTLY_TOUCHED;
FragmentMessages.search(

@ -6760,6 +6760,7 @@ public class FragmentMessages extends FragmentBase
Bundle args = new Bundle();
args.putLong("account", account);
args.putLong("folder", folder);
args.putString("type", type);
FragmentDialogSearch fragment = new FragmentDialogSearch();
fragment.setArguments(args);

Loading…
Cancel
Save