Added menu to mark message unread

Fixes #132
This commit is contained in:
M66B 2018-09-19 09:05:25 +00:00
parent 1de4dc4f90
commit 2f3e44b70b
2 changed files with 43 additions and 0 deletions

View File

@ -697,6 +697,9 @@ public class FragmentMessage extends FragmentEx {
case R.id.menu_show_headers: case R.id.menu_show_headers:
onMenuShowHeaders(); onMenuShowHeaders();
return true; return true;
case R.id.menu_unseen:
onMenuUnseen();
return true;
case R.id.menu_answer: case R.id.menu_answer:
onMenuAnswer(); onMenuAnswer();
return true; return true;
@ -783,6 +786,40 @@ public class FragmentMessage extends FragmentEx {
}.load(this, new Bundle()); }.load(this, new Bundle());
} }
private void onMenuUnseen() {
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Void>() {
@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() { private void onMenuAnswer() {
DB.getInstance(getContext()).answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer<List<EntityAnswer>>() { DB.getInstance(getContext()).answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer<List<EntityAnswer>>() {
@Override @Override

View File

@ -39,6 +39,12 @@
android:title="@string/title_show_html" android:title="@string/title_show_html"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_unseen"
android:icon="@drawable/baseline_mail_24"
android:title="@string/title_unseen"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_answer" android:id="@+id/menu_answer"
android:icon="@drawable/baseline_reply_24" android:icon="@drawable/baseline_reply_24"