diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 8021a640fc..9e34058bd7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -697,6 +697,9 @@ public class FragmentMessage extends FragmentEx { case R.id.menu_show_headers: onMenuShowHeaders(); return true; + case R.id.menu_unseen: + onMenuUnseen(); + return true; case R.id.menu_answer: onMenuAnswer(); return true; @@ -783,6 +786,40 @@ public class FragmentMessage extends FragmentEx { }.load(this, new Bundle()); } + private void onMenuUnseen() { + Bundle args = new Bundle(); + args.putLong("id", message.id); + + new SimpleTask() { + @Override + protected Void onLoad(Context context, Bundle args) throws Throwable { + long id = args.getLong("id"); + + DB db = DB.getInstance(context); + try { + db.beginTransaction(); + + EntityMessage message = db.message().getMessage(id); + db.message().setMessageUiSeen(message.id, false); + EntityOperation.queue(db, message, EntityOperation.SEEN, true); + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + + EntityOperation.process(context); + + return null; + } + + @Override + protected void onLoaded(Bundle args, Void data) { + finish(); + } + }.load(this, args); + } + private void onMenuAnswer() { DB.getInstance(getContext()).answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer>() { @Override diff --git a/app/src/main/res/menu/menu_view.xml b/app/src/main/res/menu/menu_view.xml index db9f641913..52172e91f5 100644 --- a/app/src/main/res/menu/menu_view.xml +++ b/app/src/main/res/menu/menu_view.xml @@ -39,6 +39,12 @@ android:title="@string/title_show_html" app:showAsAction="never" /> + +