1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 17:27:00 +00:00

Auto raw search in archive folder

This commit is contained in:
M66B 2020-08-09 17:18:06 +02:00
parent a8e433db83
commit 6c9ac31189

View file

@ -35,6 +35,7 @@ import androidx.preference.PreferenceManager;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
public class FragmentDialogSearch extends FragmentDialogBase { public class FragmentDialogSearch extends FragmentDialogBase {
@NonNull @NonNull
@ -295,9 +296,52 @@ public class FragmentDialogSearch extends FragmentDialogBase {
imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0); imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0);
FragmentMessages.search( if (criteria.query != null && criteria.query.startsWith("raw:"))
getContext(), getViewLifecycleOwner(), getParentFragmentManager(), new SimpleTask<EntityFolder>() {
account, folder, false, criteria); @Override
protected EntityFolder onExecute(Context context, Bundle args) throws Throwable {
long aid = args.getLong("account", -1);
DB db = DB.getInstance(context);
EntityAccount account = null;
if (aid < 0) {
List<EntityAccount> accounts = db.account().getSynchronizingAccounts();
if (accounts == null)
return null;
for (EntityAccount a : accounts)
if (a.isGmail())
if (account == null)
account = a;
else
return null;
} else
account = db.account().getAccount(aid);
if (account == null || !account.isGmail())
return null;
return db.folder().getFolderByType(account.id, EntityFolder.ARCHIVE);
}
@Override
protected void onExecuted(Bundle args, EntityFolder archive) {
FragmentMessages.search(
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
account,
archive == null ? folder : archive.id,
archive != null,
criteria);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(getContext(), getViewLifecycleOwner(), getArguments(), "search:raw");
else
FragmentMessages.search(
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
account, folder, false, criteria);
} }
}) })
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {