From f75c061627cb1871ecf30593cf36fa9cd4d23464 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 16 Apr 2024 08:34:33 +0200 Subject: [PATCH] do not show captcha dialog when activity is gone --- .../conversations/ui/EditAccountActivity.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index bc4fab2cc..401995b9e 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -34,19 +34,13 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.databinding.DataBindingUtil; +import androidx.lifecycle.Lifecycle; import com.google.android.material.color.MaterialColors; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.textfield.TextInputLayout; import com.google.common.base.CharMatcher; -import org.openintents.openpgp.util.OpenPgpUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; - import eu.siacs.conversations.AppSettings; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; @@ -84,8 +78,16 @@ import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection.Features; import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.pep.Avatar; + import okhttp3.HttpUrl; +import org.openintents.openpgp.util.OpenPgpUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + public class EditAccountActivity extends OmemoActivity implements OnAccountUpdate, OnUpdateBlocklist, OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnMamPreferencesFetched { @@ -1324,6 +1326,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (mCaptchaDialog != null && mCaptchaDialog.isShowing()) { mCaptchaDialog.dismiss(); } + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { + Log.d(Config.LOGTAG,"activity not running when captcha was requested"); + return; + } final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(EditAccountActivity.this); final View view = getLayoutInflater().inflate(R.layout.captcha, null); final ImageView imageView = view.findViewById(R.id.captcha);