From 8e897c3d69d65155a2fa7a4ce75bfc5bc13d7233 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 24 Jun 2017 09:40:53 +0200 Subject: offer to open website if ibb offers oob redirect --- .../pixart/messenger/ui/EditAccountActivity.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/main/java/de/pixart/messenger/ui') diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 320823120..e64322ac9 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -129,6 +129,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat public void onClick(final View v) { final String password = mPassword.getText().toString(); final String passwordConfirm = mPasswordConfirm.getText().toString(); + final boolean wasDisabled = mAccount != null && mAccount.getStatus() == Account.State.DISABLED; if (!mInitMode && passwordChangedInMagicCreateMode()) { gotoChangePassword(password); @@ -150,6 +151,19 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat mAccountJid.requestFocus(); return; } + + XmppConnection connection = mAccount == null ? null : mAccount.getXmppConnection(); + String url = connection != null && mAccount.getStatus() == Account.State.REGISTRATION_WEB ? connection.getWebRegistrationUrl() : null; + if (url != null && registerNewAccount && !wasDisabled) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return; + } catch (ActivityNotFoundException e) { + Toast.makeText(EditAccountActivity.this, R.string.application_found_to_open_website, Toast.LENGTH_SHORT); + return; + } + } + final Jid jid; try { if (mUsernameMode) { @@ -444,7 +458,13 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.mSaveButton.setText(R.string.connect); } } else { - this.mSaveButton.setText(R.string.next); + XmppConnection connection = mAccount == null ? null : mAccount.getXmppConnection(); + String url = connection != null && mAccount.getStatus() == Account.State.REGISTRATION_WEB ? connection.getWebRegistrationUrl() : null; + if (url != null && mRegisterNew.isChecked()) { + this.mSaveButton.setText(R.string.open_website); + } else { + this.mSaveButton.setText(R.string.next); + } } } } -- cgit v1.2.3