Added option to enable/disable text search

pull/169/head
M66B 6 years ago
parent cbd0688582
commit 8e267439eb

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

@ -869,18 +869,31 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override @Override
protected void onExecuted(Bundle args, List<EntityAccount> accounts) { 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); 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) 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)); .setIntent(new Intent().putExtra("account", account.id));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem target) { 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(); Intent intent = target.getIntent();
if (intent == null) if (intent == null)
return false; return false;

@ -733,6 +733,7 @@
<string name="title_search">Search</string> <string name="title_search">Search</string>
<string name="title_search_server">Search on server</string> <string name="title_search_server">Search on server</string>
<string name="title_search_text">Search in text</string>
<string name="title_search_in">Search in</string> <string name="title_search_in">Search in</string>
<string name="title_sort_on">Sort on</string> <string name="title_sort_on">Sort on</string>

Loading…
Cancel
Save