aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-03-16 22:54:01 +0100
committerChristian Schneppe <christian@pix-art.de>2018-03-16 22:54:01 +0100
commit8c53f23a9ba17e8e1fdebfc4bfbae6f632031273 (patch)
tree15576b201e8705b54c888742298ab026f2df0a2c
parentb5ed7cd0b2a12b78647e08e0d31664bd7bf478eb (diff)
only show one error at once
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 8bcb266f9..44d3d984c 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -152,6 +152,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
if (mUsernameMode && mAccountJid.getText().toString().contains("@")) {
mAccountJidLayout.setError(getString(R.string.invalid_username));
+ removeErrorsOnAllBut(mAccountJidLayout);
mAccountJid.requestFocus();
return;
}
@@ -185,6 +186,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
mAccountJidLayout.setError(getString(R.string.invalid_jid));
}
mAccountJid.requestFocus();
+ removeErrorsOnAllBut(mAccountJidLayout);
return;
}
String hostname = null;
@@ -195,18 +197,21 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (hostname.contains(" ")) {
mHostnameLayout.setError(getString(R.string.not_valid_hostname));
mHostname.requestFocus();
+ removeErrorsOnAllBut(mHostnameLayout);
return;
}
try {
numericPort = Integer.parseInt(port);
if (numericPort < 0 || numericPort > 65535) {
mPortLayout.setError(getString(R.string.not_a_valid_port));
+ removeErrorsOnAllBut(mPortLayout);
mPort.requestFocus();
return;
}
} catch (NumberFormatException e) {
mPortLayout.setError(getString(R.string.not_a_valid_port));
+ removeErrorsOnAllBut(mPortLayout);
mPort.requestFocus();
return;
}
@@ -218,6 +223,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else {
mAccountJidLayout.setError(getString(R.string.invalid_jid));
}
+ removeErrorsOnAllBut(mAccountJidLayout);
mAccountJid.requestFocus();
return;
}
@@ -247,6 +253,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else {
if (xmppConnectionService.findAccountByJid(jid) != null) {
mAccountJidLayout.setError(getString(R.string.account_already_exists));
+ removeErrorsOnAllBut(mAccountJidLayout);
mAccountJid.requestFocus();
return;
}
@@ -1099,8 +1106,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
keysCard.setVisibility(View.GONE);
}
} else {
+ final TextInputLayout errorLayout;
if (this.mAccount.errorStatus()) {
- final TextInputLayout errorLayout;
if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) {
errorLayout = this.mPasswordLayout;
} else if (mShowOptions
@@ -1115,14 +1122,32 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
errorLayout.requestFocus();
}
} else {
- this.mAccountJidLayout.setError(null);
- this.mPasswordLayout.setError(null);
- this.mHostnameLayout.setError(null);
+ errorLayout = null;
}
+ removeErrorsOnAllBut(errorLayout);
this.mStats.setVisibility(View.GONE);
}
}
+ private void removeErrorsOnAllBut(TextInputLayout exception) {
+ if (this.mAccountJidLayout != exception) {
+ this.mAccountJidLayout.setErrorEnabled(false);
+ this.mAccountJidLayout.setError(null);
+ }
+ if (this.mPasswordLayout != exception) {
+ this.mPasswordLayout.setErrorEnabled(false);
+ this.mPasswordLayout.setError(null);
+ }
+ if (this.mHostnameLayout != exception) {
+ this.mHostnameLayout.setErrorEnabled(false);
+ this.mHostnameLayout.setError(null);
+ }
+ if (this.mPortLayout != exception) {
+ this.mPortLayout.setErrorEnabled(false);
+ this.mPortLayout.setError(null);
+ }
+ }
+
private void showDeletePgpDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.unpublish_pgp);