Swipe delete / keep deleted

pull/203/head
M66B 3 years ago
parent c4763d4b12
commit 2444aad6c7

@ -2437,29 +2437,54 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private void onSwipeDelete(@NonNull TupleMessageEx message) {
Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete));
args.putString("remark", message.getRemark());
args.putLong("id", message.id);
args.putInt("faq", 160);
args.putString("notagain", "delete_asked");
args.putString("accept", getString(R.string.title_ask_delete_accept));
args.putBoolean("warning", true);
args.putLong("account", message.account == null ? -1 : message.account);
new SimpleTask<EntityAccount>() {
@Override
protected EntityAccount onExecute(Context context, Bundle args) throws Throwable {
long aid = args.getLong("account");
DB db = DB.getInstance(context);
return db.account().getAccount(aid);
}
@Override
protected void onExecuted(Bundle args, EntityAccount account) {
boolean leave_deleted = (account != null &&
account.protocol == EntityAccount.TYPE_POP &&
account.leave_deleted);
Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_ask_delete));
aargs.putString("remark", message.getRemark());
aargs.putLong("id", message.id);
aargs.putInt("faq", 160);
aargs.putString("notagain", "delete_asked");
aargs.putString("accept", getString(R.string.title_ask_delete_accept));
aargs.putBoolean("warning", true);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean delete_asked = prefs.getBoolean("delete_asked", false);
if (delete_asked) {
if (delete_asked || leave_deleted) {
Intent data = new Intent();
data.putExtra("args", args);
data.putExtra("args", aargs);
onActivityResult(REQUEST_MESSAGE_DELETE, RESULT_OK, data);
return;
}
FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(args);
ask.setArguments(aargs);
ask.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_DELETE);
ask.show(getParentFragmentManager(), "swipe:delete");
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentMessages.this, args, "message:delete");
}
private void swipeFolder(@NonNull TupleMessageEx message, @NonNull Long target) {
Bundle args = new Bundle();
args.putLong("id", message.id);

Loading…
Cancel
Save