From d114f3736d2df40767ba6db6a45b32ccddc16267 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 7 Mar 2023 16:40:51 -0500 Subject: [PATCH] Allow cancel onboarding If this is just a register not part of inversion, archive the conversation when they say "no thanks" so they get back to their regular first start experience. If this is part of inversion, remove the onboarding account since they aren't going to use it and set a flag so we know to redirect to magic create instead of back to the welcome screen. The flag also lets us know not to offer cheogram again right after magic create like we normally would. Then we can clear the flag out and move on as usual. --- .../java/eu/siacs/conversations/utils/SignupUtils.java | 5 ++--- .../eu/siacs/conversations/entities/Conversation.java | 8 ++++++++ .../siacs/conversations/ui/StartConversationActivity.java | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java b/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java index fb088234a24e10ea315bafebd910e28df9caa270..790ea14bfacdd132ef9033cfac3e9ff545613592 100644 --- a/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java +++ b/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java @@ -62,7 +62,7 @@ public class SignupUtils { if (Config.X509_VERIFICATION) { intent = new Intent(activity, ManageAccountActivity.class); } else if (Config.MAGIC_CREATE_DOMAIN != null) { - intent = getSignUpIntent(activity); + intent = activity.xmppConnectionService.getPreferences().getBoolean("onboarding_canceled", false) ? new Intent(activity, MagicCreateActivity.class) : getSignUpIntent(activity); } else { intent = new Intent(activity, EditAccountActivity.class); } @@ -70,8 +70,7 @@ public class SignupUtils { intent = new Intent(activity, StartConversationActivity.class); } } - intent.putExtra("init", true); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return intent; } -} \ No newline at end of file +} diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index b09ff01fe7775abd573379780e61877efea918a3..86343cb2fbc1fa3fb6df857099203786740e5b26 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2498,6 +2498,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } if (responseElement == null && command.getAttribute("status") != null && (command.getAttribute("status").equals("completed") || command.getAttribute("status").equals("canceled"))) { + if (mNode.equals("jabber:iq:register") && command.getAttribute("status").equals("canceled")) { + if (xmppConnectionService.isOnboarding()) { + xmppConnectionService.getPreferences().edit().putBoolean("onboarding_canceled", true).commit(); + xmppConnectionService.deleteAccount(getAccount()); + } + xmppConnectionService.archiveConversation(Conversation.this); + } + removeSession(this); return; } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 139b80b1c85cb63f68e2ab5e6345623859120618..541ee116a4f4d53af27382dd42302ad3a8d0fdbe 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -917,7 +917,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne configureHomeButton(); Intent intent = pendingViewIntent.pop(); - if (intent != null && intent.getBooleanExtra("init", false)) { + if (intent != null && intent.getBooleanExtra("init", false) && !xmppConnectionService.getPreferences().getBoolean("onboarding_canceled", false)) { Account selectedAccount = xmppConnectionService.getAccounts().get(0); final String accountJid = intent.getStringExtra(EXTRA_ACCOUNT); intent = null; @@ -1033,6 +1033,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } } + xmppConnectionService.getPreferences().edit().remove("onboarding_canceled").commit(); + if (intent != null && processViewIntent(intent)) { filter(null); } else {