From a814987b7e97a38e7f4d974bbd62283a5087ff0b Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 8 Mar 2023 16:31:42 -0500 Subject: [PATCH] Start onboarding where we left off If they didn't cancel but rather chose an option which could not be completed under inversion, start where we left off. --- .../conversations/utils/SignupUtils.java | 2 +- .../conversations/entities/Conversation.java | 19 ++++++++++++++++++- .../ui/StartConversationActivity.java | 7 ++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java b/src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java index 790ea14bfacdd132ef9033cfac3e9ff545613592..14dc3f79443f98597f8f2306e522284327bb8a3f 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 = activity.xmppConnectionService.getPreferences().getBoolean("onboarding_canceled", false) ? new Intent(activity, MagicCreateActivity.class) : getSignUpIntent(activity); + intent = activity.xmppConnectionService.getPreferences().contains("onboarding_action") ? new Intent(activity, MagicCreateActivity.class) : getSignUpIntent(activity); } else { intent = new Intent(activity, EditAccountActivity.class); } diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 86343cb2fbc1fa3fb6df857099203786740e5b26..7fcfe916a962c8a7443c099f1596d786e6c2af48 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2500,7 +2500,9 @@ 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(); + if (!xmppConnectionService.getPreferences().contains("onboarding_action")) { + xmppConnectionService.getPreferences().edit().putString("onboarding_action", "cancel").commit(); + } xmppConnectionService.deleteAccount(getAccount()); } xmppConnectionService.archiveConversation(Conversation.this); @@ -2529,6 +2531,17 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl actionsAdapter.add(Pair.create("close", "close")); } + Data dataForm = null; + if (responseElement != null && responseElement.getName().equals("x") && responseElement.getNamespace().equals("jabber:x:data")) dataForm = Data.parse(responseElement); + if (mNode.equals("jabber:iq:register") && + xmppConnectionService.getPreferences().contains("onboarding_action") && + dataForm != null && dataForm.getFieldByName("gateway-jid") != null) { + + + dataForm.put("gateway-jid", xmppConnectionService.getPreferences().getString("onboarding_action", "")); + execute(); + } + xmppConnectionService.getPreferences().edit().remove("onboarding_action").commit(); notifyDataSetChanged(); } @@ -2772,6 +2785,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl c.setAttribute("action", "execute"); } + if (mNode.equals("jabber:iq:register") && xmppConnectionService.isOnboarding() && form.getValue("gateway-jid") != null) { + xmppConnectionService.getPreferences().edit().putString("onboarding_action", form.getValue("gateway-jid")).commit(); + } + responseElement.setAttribute("type", "submit"); Element rsm = responseElement.findChild("set", "http://jabber.org/protocol/rsm"); if (rsm != null) { diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index ffe01c886d19aaf7ba65b62418ff009ce2026611..14d32493b48e98551f2bb206c6aeddefa8471f08 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -917,7 +917,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne configureHomeButton(); Intent intent = pendingViewIntent.pop(); - if (intent != null && intent.getBooleanExtra("init", false) && !xmppConnectionService.getPreferences().getBoolean("onboarding_canceled", false)) { + final boolean onboardingCancel = xmppConnectionService.getPreferences().getString("onboarding_action", "").equals("cancel"); + if (onboardingCancel) xmppConnectionService.getPreferences().edit().remove("onboarding_action").commit(); + + if (intent != null && intent.getBooleanExtra("init", false) && !onboardingCancel) { Account selectedAccount = xmppConnectionService.getAccounts().get(0); final String accountJid = intent.getStringExtra(EXTRA_ACCOUNT); intent = null; @@ -1033,8 +1036,6 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } } - xmppConnectionService.getPreferences().edit().remove("onboarding_canceled").commit(); - if (intent != null && processViewIntent(intent)) { filter(null); } else {