diff options
author | Fup Duck <fupduck@sacknagel.com> | 2018-02-22 15:47:32 +0100 |
---|---|---|
committer | Fup Duck <fupduck@sacknagel.com> | 2018-02-22 15:47:32 +0100 |
commit | 0cf6368a993d23527802b3eba70ddeda4b5933c6 (patch) | |
tree | 09cb9af7026e4a10a783c032bbe0028572ebbbf6 | |
parent | af3ac0476f2b6320cd3e3ff8e17453d50bbace08 (diff) |
8867 - add url to username
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java index e6877756..15cd9617 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java @@ -186,7 +186,11 @@ public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseAc String username = usernameField.getText().toString(); String providerDomain = provider.getDomain(); if (username.endsWith(providerDomain)) { - return username.split("@" + providerDomain)[0]; + try { + return username.split("@" + providerDomain)[0]; + } catch (ArrayIndexOutOfBoundsException e) { + return ""; + } } return username; } @@ -240,9 +244,15 @@ public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseAc @Override public void afterTextChanged(Editable s) { if (getUsername().equalsIgnoreCase("")) { + s.clear(); usernameError.setError(getString(R.string.username_ask)); } else { usernameError.setError(null); + String suffix = "@" + provider.getDomain(); + if (!usernameField.getText().toString().endsWith(suffix)) { + s.append(suffix); + usernameField.setSelection(usernameField.getText().toString().indexOf('@')); + } } } }); |