|
|
|
@ -3834,48 +3834,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));
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putString("type", type);
|
|
|
|
|
args.putLong("folder", folder);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPreExecute(Bundle args) {
|
|
|
|
|
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
String type = args.getString("type");
|
|
|
|
|
long folder = args.getLong("folder");
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
long[] ids = args.getLongArray("ids");
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
|
|
|
|
|
boolean filter_unknown = prefs.getBoolean("filter_unknown", false);
|
|
|
|
|
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true);
|
|
|
|
|
String filter_language = prefs.getString("filter_language", null);
|
|
|
|
|
boolean language_detection = prefs.getBoolean("language_detection", false);
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
List<Long> ids = db.message().getMessageUnseen(
|
|
|
|
|
folder < 0 ? null : folder,
|
|
|
|
|
folder < 0 ? type : null,
|
|
|
|
|
filter_unflagged, filter_unknown, filter_snoozed,
|
|
|
|
|
language_detection ? filter_language : null);
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentMessages.this, args, "message:read");
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}.execute(FragmentMessages.this, args, "message:read");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onMenuForceSync() {
|
|
|
|
|