mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 16:43:26 +02:00
Allow disabling confirmation of deleting single messages
This commit is contained in:
@@ -4155,8 +4155,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
aargs.putString("remark", message.getRemark());
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putInt("faq", 160);
|
||||
aargs.putString("notagain", "delete_asked");
|
||||
aargs.putString("accept", context.getString(R.string.title_ask_delete_accept));
|
||||
aargs.putBoolean("warning", true);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", aargs);
|
||||
parentFragment.onActivityResult(FragmentMessages.REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_DELETE);
|
||||
|
||||
@@ -47,6 +47,7 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
||||
String remark = args.getString("remark");
|
||||
String confirm = args.getString("confirm");
|
||||
String notagain = args.getString("notagain");
|
||||
String accept = args.getString("accept");
|
||||
boolean warning = args.getBoolean("warning");
|
||||
int faq = args.getInt("faq");
|
||||
|
||||
@@ -58,6 +59,7 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
||||
TextView tvRemark = dview.findViewById(R.id.tvRemark);
|
||||
CheckBox cbConfirm = dview.findViewById(R.id.cbConfirm);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
TextView tvAccept = dview.findViewById(R.id.tvAccept);
|
||||
ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
|
||||
|
||||
tvMessage.setText(question);
|
||||
@@ -66,6 +68,8 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
||||
cbConfirm.setText(confirm);
|
||||
cbConfirm.setVisibility(confirm == null ? View.GONE : View.VISIBLE);
|
||||
cbNotAgain.setVisibility(notagain == null ? View.GONE : View.VISIBLE);
|
||||
tvAccept.setText(accept);
|
||||
tvAccept.setVisibility(View.GONE);
|
||||
ibInfo.setVisibility(faq == 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (warning) {
|
||||
@@ -80,8 +84,11 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putBoolean(notagain, isChecked).apply();
|
||||
if (accept == null) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putBoolean(notagain, isChecked).apply();
|
||||
}
|
||||
tvAccept.setVisibility(isChecked && accept != null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -98,9 +105,13 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (confirm == null || cbConfirm.isChecked())
|
||||
if (confirm == null || cbConfirm.isChecked()) {
|
||||
if (notagain != null && accept != null) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putBoolean(notagain, cbNotAgain.isChecked()).apply();
|
||||
}
|
||||
sendResult(Activity.RESULT_OK);
|
||||
else
|
||||
} else
|
||||
sendResult(Activity.RESULT_CANCELED);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2353,8 +2353,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
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);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", args);
|
||||
onActivityResult(REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(args);
|
||||
ask.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_DELETE);
|
||||
|
||||
@@ -160,7 +160,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
"selected_folders", "move_1_confirmed", "move_n_confirmed",
|
||||
"last_search_senders", "last_search_recipients", "last_search_subject", "last_search_keywords", "last_search_message",
|
||||
"identities_asked", "identities_primary_hint",
|
||||
"raw_asked", "all_read_asked",
|
||||
"raw_asked", "all_read_asked", "delete_asked",
|
||||
"cc_bcc", "inline_image_hint", "compose_reference", "send_dialog",
|
||||
"setup_reminder", "setup_advanced"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user