diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-12-27 20:53:01 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-12-27 20:53:01 +0100 |
commit | 1e50689658d0d2363e0fe965d99e50dd4bc66adf (patch) | |
tree | c35bfefb9299104484fa776f886d5c8a3d602a7c /src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java | |
parent | 1056adb285a367b7485e447e1a673a0885e9167e (diff) |
transport invitee from welcome activity to start conversations activity
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java index b3dc782ad..6a2beaf8c 100644 --- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java +++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java @@ -58,35 +58,33 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher { mUsername = findViewById(R.id.username); mRandom = new SecureRandom(); Button next = findViewById(R.id.create_account); - next.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String username = mUsername.getText().toString(); - if (username.contains("@") || username.length() < 3) { + next.setOnClickListener(v -> { + String username = mUsername.getText().toString(); + if (username.contains("@") || username.length() < 3) { + mUsername.setError(getString(R.string.invalid_username)); + mUsername.requestFocus(); + } else { + mUsername.setError(null); + try { + Jid jid = Jid.fromParts(username.toLowerCase(), Config.MAGIC_CREATE_DOMAIN, null); + Account account = xmppConnectionService.findAccountByJid(jid); + if (account == null) { + account = new Account(jid, createPassword()); + account.setOption(Account.OPTION_REGISTER, true); + account.setOption(Account.OPTION_DISABLED, true); + account.setOption(Account.OPTION_MAGIC_CREATE, true); + xmppConnectionService.createAccount(account); + } + Intent intent = new Intent(MagicCreateActivity.this, EditAccountActivity.class); + intent.putExtra("jid", account.getJid().toBareJid().toString()); + intent.putExtra("init", true); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show(); + WelcomeActivity.addInvitee(intent, getIntent()); + startActivity(intent); + } catch (InvalidJidException e) { mUsername.setError(getString(R.string.invalid_username)); mUsername.requestFocus(); - } else { - mUsername.setError(null); - try { - Jid jid = Jid.fromParts(username.toLowerCase(), Config.MAGIC_CREATE_DOMAIN, null); - Account account = xmppConnectionService.findAccountByJid(jid); - if (account == null) { - account = new Account(jid, createPassword()); - account.setOption(Account.OPTION_REGISTER, true); - account.setOption(Account.OPTION_DISABLED, true); - account.setOption(Account.OPTION_MAGIC_CREATE, true); - xmppConnectionService.createAccount(account); - } - Intent intent = new Intent(MagicCreateActivity.this, EditAccountActivity.class); - intent.putExtra("jid", account.getJid().toBareJid().toString()); - intent.putExtra("init", true); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show(); - startActivity(intent); - } catch (InvalidJidException e) { - mUsername.setError(getString(R.string.invalid_username)); - mUsername.requestFocus(); - } } } }); |