mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-27 08:23:24 +00:00
Search improvements
This commit is contained in:
parent
2b42df6ba3
commit
f5775f178e
2 changed files with 28 additions and 5 deletions
|
@ -397,7 +397,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
else {
|
||||
viewType = AdapterMessage.ViewType.SEARCH;
|
||||
setTitle(server ? R.string.title_search_server : R.string.title_search);
|
||||
setTitle(server ? R.string.title_search_server : R.string.title_search_device);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -972,11 +972,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", account);
|
||||
args.putLong("folder", folder);
|
||||
|
||||
new SimpleTask<List<EntityAccount>>() {
|
||||
@Override
|
||||
protected List<EntityAccount> onExecute(Context context, Bundle args) {
|
||||
long aid = args.getLong("account");
|
||||
long fid = args.getLong("folder");
|
||||
|
||||
List<EntityAccount> result = new ArrayList<>();
|
||||
DB db = DB.getInstance(context);
|
||||
|
@ -991,6 +993,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
result.add(account);
|
||||
}
|
||||
|
||||
if (folder > 0) {
|
||||
EntityFolder folder = db.folder().getFolder(fid);
|
||||
if (folder != null)
|
||||
args.putString("folderName", folder.getDisplayName(context));
|
||||
}
|
||||
|
||||
if (result.size() == 0)
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_search));
|
||||
else
|
||||
|
@ -1004,17 +1012,22 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), fabSearch);
|
||||
|
||||
int order = 0;
|
||||
|
||||
SpannableString ss = new SpannableString(getString(R.string.title_search_server));
|
||||
ss.setSpan(new StyleSpan(Typeface.ITALIC), 0, ss.length(), 0);
|
||||
ss.setSpan(new RelativeSizeSpan(0.9f), 0, ss.length(), 0);
|
||||
popupMenu.getMenu().add(Menu.NONE, 0, 0, ss)
|
||||
popupMenu.getMenu().add(Menu.NONE, 0, order++, ss)
|
||||
.setEnabled(false);
|
||||
popupMenu.getMenu().add(Menu.NONE, 1, 1, R.string.title_search_text)
|
||||
popupMenu.getMenu().add(Menu.NONE, 1, order++, R.string.title_search_text)
|
||||
.setCheckable(true).setChecked(search_text);
|
||||
|
||||
int order = 2;
|
||||
String folderName = args.getString("folderName", null);
|
||||
if (!TextUtils.isEmpty(folderName))
|
||||
popupMenu.getMenu().add(Menu.NONE, 2, order++, folderName);
|
||||
|
||||
for (EntityAccount account : accounts)
|
||||
popupMenu.getMenu().add(Menu.NONE, 2, order++, account.name)
|
||||
popupMenu.getMenu().add(Menu.NONE, 3, order++, account.name)
|
||||
.setIntent(new Intent().putExtra("account", account.id));
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
|
@ -1027,6 +1040,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
return true;
|
||||
}
|
||||
|
||||
if (target.getItemId() == 2) {
|
||||
search(
|
||||
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
|
||||
account, folder,
|
||||
true,
|
||||
query);
|
||||
return true;
|
||||
}
|
||||
|
||||
Intent intent = target.getIntent();
|
||||
if (intent == null)
|
||||
return false;
|
||||
|
|
|
@ -893,6 +893,7 @@
|
|||
<string name="title_signature_store">Store</string>
|
||||
|
||||
<string name="title_search">Search</string>
|
||||
<string name="title_search_device">Search on device</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>
|
||||
|
|
Loading…
Reference in a new issue