added null check to Jid.of in edit account

This commit is contained in:
Daniel Gultsch 2018-05-03 15:59:14 +02:00
parent 6fe5c5e770
commit b5423b39a0

View file

@ -158,7 +158,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString()))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString())));
return; return;
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
Toast.makeText(EditAccountActivity.this, R.string.application_found_to_open_website, Toast.LENGTH_SHORT); Toast.makeText(EditAccountActivity.this, R.string.application_found_to_open_website, Toast.LENGTH_SHORT).show();
return; return;
} }
} }
@ -170,7 +170,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else { } else {
jid = Jid.of(binding.accountJid.getText().toString()); jid = Jid.of(binding.accountJid.getText().toString());
} }
} catch (final IllegalArgumentException e) { } catch (final NullPointerException | IllegalArgumentException e) {
if (mUsernameMode) { if (mUsernameMode) {
mAccountJidLayout.setError(getString(R.string.invalid_username)); mAccountJidLayout.setError(getString(R.string.invalid_username));
} else { } else {
@ -755,7 +755,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} }
private String getUserModeDomain() { private String getUserModeDomain() {
if (mAccount != null) { if (mAccount != null && mAccount.getJid().getDomain() != null) {
return mAccount.getJid().getDomain(); return mAccount.getJid().getDomain();
} else { } else {
return Config.DOMAIN_LOCK; return Config.DOMAIN_LOCK;