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

Added batch hide

This commit is contained in:
M66B 2019-10-28 09:12:49 +01:00
parent 102e86c41d
commit 0c94c973da

View file

@ -1763,6 +1763,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
result.flagged = true; result.flagged = true;
else else
result.unflagged = true; result.unflagged = true;
if (threaded.folder.equals(message.folder))
if (message.ui_snoozed == null)
result.visible = true;
else
result.hidden = true;
} }
EntityFolder folder = db.folder().getFolder(message.folder); EntityFolder folder = db.folder().getFolder(message.folder);
@ -1815,6 +1821,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
popupMenu.getMenu().add(Menu.NONE, R.string.title_snooze, order++, R.string.title_snooze); popupMenu.getMenu().add(Menu.NONE, R.string.title_snooze, order++, R.string.title_snooze);
if (result.visible)
popupMenu.getMenu().add(Menu.NONE, R.string.title_hide, order++, R.string.title_hide);
if (result.hidden)
popupMenu.getMenu().add(Menu.NONE, R.string.title_unhide, order++, R.string.title_unhide);
if (result.unflagged) if (result.unflagged)
popupMenu.getMenu().add(Menu.NONE, R.string.title_flag, order++, R.string.title_flag); popupMenu.getMenu().add(Menu.NONE, R.string.title_flag, order++, R.string.title_flag);
if (result.flagged) if (result.flagged)
@ -1854,6 +1865,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
case R.string.title_snooze: case R.string.title_snooze:
onActionSnoozeSelection(); onActionSnoozeSelection();
return true; return true;
case R.string.title_hide:
onHideSelection(true);
return true;
case R.string.title_unhide:
onHideSelection(false);
return true;
case R.string.title_flag: case R.string.title_flag:
onActionFlagSelection(true, null); onActionFlagSelection(true, null);
return true; return true;
@ -1991,6 +2008,51 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fragment.show(getParentFragmentManager(), "messages:snooze"); fragment.show(getParentFragmentManager(), "messages:snooze");
} }
private void onHideSelection(boolean hide) {
Bundle args = new Bundle();
args.putLongArray("ids", getSelection());
args.putBoolean("hide", hide);
selectionTracker.clearSelection();
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
boolean hide = args.getBoolean("hide");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
for (long id : ids) {
EntityMessage message = db.message().getMessage(id);
if (message == null)
continue;
List<EntityMessage> messages = db.message().getMessagesByThread(
message.account, message.thread, threading ? null : id, message.folder);
for (EntityMessage threaded : messages) {
db.message().setMessageSnoozed(threaded.id, hide ? Long.MAX_VALUE : null);
EntityMessage.snooze(context, threaded.id, hide ? Long.MAX_VALUE : null);
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "messages:flag");
}
private void onActionFlagSelection(boolean flagged, Integer color) { private void onActionFlagSelection(boolean flagged, Integer color) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLongArray("ids", getSelection()); args.putLongArray("ids", getSelection());
@ -4589,6 +4651,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private class MoreResult { private class MoreResult {
boolean seen; boolean seen;
boolean unseen; boolean unseen;
boolean visible;
boolean hidden;
boolean flagged; boolean flagged;
boolean unflagged; boolean unflagged;
Boolean hasArchive; Boolean hasArchive;