Double confirm permanent deletion

pull/198/head
M66B 3 years ago
parent 6344653f2f
commit b056a2f8d9

@ -44,6 +44,7 @@ public class FragmentDialogAsk extends FragmentDialogBase {
Bundle args = getArguments();
String question = args.getString("question");
String remark = args.getString("remark");
String confirm = args.getString("confirm");
String notagain = args.getString("notagain");
boolean warning = args.getBoolean("warning");
@ -53,11 +54,14 @@ public class FragmentDialogAsk extends FragmentDialogBase {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null);
TextView tvMessage = dview.findViewById(R.id.tvMessage);
TextView tvRemark = dview.findViewById(R.id.tvRemark);
CheckBox cbConfirm = dview.findViewById(R.id.cbConfirm);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
tvMessage.setText(question);
tvRemark.setText(remark);
tvRemark.setVisibility(remark == null ? View.GONE : View.VISIBLE);
cbConfirm.setText(confirm);
cbConfirm.setVisibility(confirm == null ? View.GONE : View.VISIBLE);
cbNotAgain.setVisibility(notagain == null ? View.GONE : View.VISIBLE);
if (warning) {
@ -82,7 +86,10 @@ public class FragmentDialogAsk extends FragmentDialogBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sendResult(Activity.RESULT_OK);
if (confirm == null || cbConfirm.isChecked())
sendResult(Activity.RESULT_OK);
else
sendResult(Activity.RESULT_CANCELED);
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

@ -338,7 +338,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private NumberFormat NF = NumberFormat.getNumberInstance();
private static final int MAX_MORE = 100; // messages
private static final int MAX_PERMANENT_DELETE = 10; // messages
private static final int MAX_SEND_RAW = 50; // messages
private static final int SWIPE_DISABLE_SELECT_DURATION = 1500; // milliseconds
private static final float LUMINANCE_THRESHOLD = 0.7f;
@ -2951,16 +2950,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
popupMenu.getMenu().add(Menu.NONE, R.string.title_trash, order++, R.string.title_trash)
.setIcon(R.drawable.twotone_delete_24);
if (result.isTrash || !result.hasTrash || result.isJunk ||
ids.length < MAX_PERMANENT_DELETE || true) { // is trash or no trash or is junk
if (result.isTrash || !result.hasTrash || result.isJunk || true) { // is trash or no trash or is junk
SpannableStringBuilder del = new SpannableStringBuilder();
del.append(getString(R.string.title_delete_permanently));
int pos = del.length();
del.append(" (<").append(NF.format(MAX_PERMANENT_DELETE)).append(')');
del.setSpan(new RelativeSizeSpan(0.7f), pos, del.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_permanently, order++, del)
.setIcon(R.drawable.twotone_delete_forever_24)
.setEnabled(ids.length < MAX_PERMANENT_DELETE);
.setIcon(R.drawable.twotone_delete_forever_24);
}
if (result.accounts.size() > 0 /* IMAP */ && ids.length < MAX_SEND_RAW)
@ -3363,7 +3359,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Bundle aargs = new Bundle();
aargs.putString("question", getResources()
.getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size()));
aargs.putString("remark", getString(R.string.title_no_undo));
aargs.putString("confirm", getString(R.string.title_no_undo));
aargs.putLongArray("ids", Helper.toLongArray(ids));
aargs.putBoolean("warning", true);
@ -3744,7 +3740,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Bundle aargs = new Bundle();
aargs.putString("question", getResources()
.getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size()));
aargs.putString("remark", getString(R.string.title_no_undo));
aargs.putString("confirm", getString(R.string.title_no_undo));
aargs.putLongArray("ids", Helper.toLongArray(ids));
aargs.putBoolean("warning", true);

@ -31,6 +31,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
<CheckBox
android:id="@+id/cbConfirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/title_no_undo"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
@ -39,6 +49,6 @@
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" />
app:layout_constraintTop_toBottomOf="@id/cbConfirm" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

@ -949,7 +949,7 @@
<string name="title_move_to_account">Move to %1$s &#8230;</string>
<string name="title_report_spam">Treat as spam</string>
<string name="title_delete_permanently">Delete permanently</string>
<string name="title_no_undo">This cannot be undone!</string>
<string name="title_no_undo">I understand this cannot be undone</string>
<string name="title_snooze">Snooze &#8230;</string>
<string name="title_archive">Archive</string>
<string name="title_reply">Reply</string>

Loading…
Cancel
Save