From 3fa205d463540d45ac3e053e27952c53452d6a19 Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Thu, 15 Feb 2018 11:03:38 +0100 Subject: [PATCH] Don't add account if user cancels. Fixes #2797 --- .../conversations/ui/EditAccountActivity.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 8e86f0cdc..e775fa5fb 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -263,7 +263,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat @Override public void onClick(final View v) { - deleteMagicCreatedAccountAndReturnIfNecessary(); + deleteAccountAndReturnIfNecessary(); finish(); } }; @@ -296,23 +296,22 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat @Override public boolean onNavigateUp() { - deleteMagicCreatedAccountAndReturnIfNecessary(); + deleteAccountAndReturnIfNecessary(); return super.onNavigateUp(); } @Override public void onBackPressed() { - deleteMagicCreatedAccountAndReturnIfNecessary(); + deleteAccountAndReturnIfNecessary(); super.onBackPressed(); } - private void deleteMagicCreatedAccountAndReturnIfNecessary() { - if (Config.MAGIC_CREATE_DOMAIN != null - && mAccount != null - && mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) - && mAccount.isOptionSet(Account.OPTION_REGISTER) - && xmppConnectionService.getAccounts().size() == 1) { + private void deleteAccountAndReturnIfNecessary() { + if (mInitMode && mAccount != null && !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY)) { xmppConnectionService.deleteAccount(mAccount); + } + + if (xmppConnectionService.getAccounts().size() == 0) { Intent intent = new Intent(EditAccountActivity.this, WelcomeActivity.class); WelcomeActivity.addInviteUri(intent, getIntent()); startActivity(intent);