Start onboarding where we left off
Stephen Paul Weber
created
If they didn't cancel but rather chose an option which could not be completed
under inversion, start where we left off.
Change summary
src/cheogram/java/eu/siacs/conversations/utils/SignupUtils.java | 2
src/main/java/eu/siacs/conversations/entities/Conversation.java | 19
src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 7
3 files changed, 23 insertions(+), 5 deletions(-)
Detailed changes
@@ -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);
}
@@ -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) {
@@ -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 {