Added mark all read

pull/182/head
M66B 5 years ago
parent 6906d6aa34
commit 718e5797ff

@ -3512,6 +3512,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
language_detection && folder && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q);
menu.findItem(R.id.menu_select_all).setVisible(folder);
menu.findItem(R.id.menu_select_found).setVisible(viewType == AdapterMessage.ViewType.SEARCH);
menu.findItem(R.id.menu_mark_all_read).setVisible(folder);
menu.findItem(R.id.menu_force_sync).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);
menu.findItem(R.id.menu_force_send).setVisible(outbox);
@ -3633,6 +3634,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuSelectAll();
return true;
case R.id.menu_mark_all_read:
onMenuMarkAllRead();
return true;
case R.id.menu_force_sync:
onMenuForceSync();
return true;
@ -3828,6 +3833,51 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
});
}
private void onMenuMarkAllRead() {
ViewModelMessages model = new ViewModelProvider(getActivity()).get(ViewModelMessages.class);
model.getIds(getContext(), getViewLifecycleOwner(), new Observer<List<Long>>() {
@Override
public void onChanged(List<Long> ids) {
Bundle args = new Bundle();
args.putLongArray("ids", Helper.toLongArray(ids));
new SimpleTask<Void>() {
@Override
protected void onPreExecute(Bundle args) {
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
}
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long[] ids = args.getLongArray("ids");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
for (long id : ids) {
EntityMessage message = db.message().getMessage(id);
if (message != null)
EntityOperation.queue(context, message, EntityOperation.SEEN, true);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentMessages.this, args, "message:read");
}
});
}
private void onMenuForceSync() {
ServiceSynchronize.reload(getContext(), null, true, "force sync");
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();

@ -128,6 +128,11 @@
android:title="@string/title_select_found"
app:showAsAction="never" />
<item
android:id="@+id/menu_mark_all_read"
android:title="@string/title_mark_all_read"
app:showAsAction="never" />
<item
android:id="@+id/menu_force_sync"
android:title="@string/title_force_sync"

@ -999,6 +999,7 @@
<string name="title_select_language">Select language</string>
<string name="title_select_all">Select all</string>
<string name="title_select_found">Select found</string>
<string name="title_mark_all_read">Mark all read</string>
<string name="title_force_sync">Force sync</string>
<string name="title_force_send">Force send</string>

Loading…
Cancel
Save