Added option to enable/disable text search

This commit is contained in:
M66B
2019-12-16 20:50:49 +01:00
parent cbd0688582
commit 8e267439eb
3 changed files with 29 additions and 10 deletions

View File

@@ -261,8 +261,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean threading = prefs.getBoolean("threading", true);
boolean debug = (prefs.getBoolean("debug", false) || BuildConfig.BETA_RELEASE);
final boolean threading = prefs.getBoolean("threading", true);
final boolean search_text = prefs.getBoolean("search_text", true);
final boolean debug = (prefs.getBoolean("debug", false) || BuildConfig.BETA_RELEASE);
final EntityFolder browsable = db.folder().getBrowsableFolder(folder, query != null);
if (browsable == null)
@@ -352,19 +354,22 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
arg.writeAtom("CHARSET");
arg.writeAtom(StandardCharsets.UTF_8.name());
}
arg.writeAtom("OR");
arg.writeAtom("OR");
if (search_text)
arg.writeAtom("OR");
if (keywords)
arg.writeAtom("OR");
arg.writeAtom("OR");
arg.writeAtom("OR");
arg.writeAtom("OR");
arg.writeAtom("FROM");
arg.writeBytes(query.getBytes());
arg.writeAtom("TO");
arg.writeBytes(query.getBytes());
arg.writeAtom("SUBJECT");
arg.writeBytes(query.getBytes());
arg.writeAtom("BODY");
arg.writeBytes(query.getBytes());
if (search_text) {
arg.writeAtom("BODY");
arg.writeBytes(query.getBytes());
}
if (keywords) {
arg.writeAtom("KEYWORD");
arg.writeBytes(query.getBytes());

View File

@@ -869,18 +869,31 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override
protected void onExecuted(Bundle args, List<EntityAccount> accounts) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean search_text = prefs.getBoolean("search_text", true);
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), fabSearch);
popupMenu.getMenu().add(Menu.NONE, 0, 0, R.string.title_search_server).setEnabled(false);
popupMenu.getMenu().add(Menu.NONE, 0, 0, R.string.title_search_server)
.setEnabled(false);
popupMenu.getMenu().add(Menu.NONE, 1, 1, R.string.title_search_text)
.setCheckable(true).setChecked(search_text);
int order = 1;
int order = 2;
for (EntityAccount account : accounts)
popupMenu.getMenu().add(Menu.NONE, 0, order++, account.name)
popupMenu.getMenu().add(Menu.NONE, 2, order++, account.name)
.setIntent(new Intent().putExtra("account", account.id));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem target) {
if (target.getItemId() == 1) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean search_text = prefs.getBoolean("search_text", true);
prefs.edit().putBoolean("search_text", !search_text).apply();
return true;
}
Intent intent = target.getIntent();
if (intent == null)
return false;