From 5c6bc7e6df77f2305ad3c30a3d951efb968e8d5a Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 31 Mar 2022 10:13:20 +0200 Subject: [PATCH] Added forward raw auto confirm --- .../email/FragmentDialogForwardRaw.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogForwardRaw.java b/app/src/main/java/eu/faircode/email/FragmentDialogForwardRaw.java index 576859157e..b352cd8379 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogForwardRaw.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogForwardRaw.java @@ -31,6 +31,7 @@ import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; @@ -51,6 +52,8 @@ import java.util.Objects; public class FragmentDialogForwardRaw extends FragmentDialogBase { private boolean enabled; + private static final long AUTO_CONFIRM_DELAY = 10 * 1000L; + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { @@ -174,8 +177,16 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase { ld.removeObserver(this); getArguments().putLong("account", args.getLong("account")); getArguments().putLongArray("ids", ids); + enabled = true; - setButtonEnabled(enabled); + Button ok = getPositiveButton(); + ok.setEnabled(enabled); + ok.postDelayed(new Runnable() { + @Override + public void run() { + getPositiveButton().performClick(); + } + }, AUTO_CONFIRM_DELAY); } } }); @@ -208,13 +219,11 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase { @Override public void onStart() { super.onStart(); - setButtonEnabled(enabled); + getPositiveButton().setEnabled(enabled); } - void setButtonEnabled(boolean enabled) { - ((AlertDialog) getDialog()) - .getButton(AlertDialog.BUTTON_POSITIVE) - .setEnabled(enabled); + private Button getPositiveButton() { + return ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE); } @Override