Added forward raw auto confirm

This commit is contained in:
M66B 2022-03-31 10:13:20 +02:00
parent 1b7f370b06
commit 5c6bc7e6df
1 changed files with 15 additions and 6 deletions

View File

@ -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