only show one error at once
This commit is contained in:
parent
f334349cd6
commit
1c441a57e8
|
@ -153,6 +153,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
|
final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
|
||||||
if (mUsernameMode && mAccountJid.getText().toString().contains("@")) {
|
if (mUsernameMode && mAccountJid.getText().toString().contains("@")) {
|
||||||
mAccountJidLayout.setError(getString(R.string.invalid_username));
|
mAccountJidLayout.setError(getString(R.string.invalid_username));
|
||||||
|
removeErrorsOnAllBut(mAccountJidLayout);
|
||||||
mAccountJid.requestFocus();
|
mAccountJid.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -186,6 +187,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
mAccountJidLayout.setError(getString(R.string.invalid_jid));
|
mAccountJidLayout.setError(getString(R.string.invalid_jid));
|
||||||
}
|
}
|
||||||
mAccountJid.requestFocus();
|
mAccountJid.requestFocus();
|
||||||
|
removeErrorsOnAllBut(mAccountJidLayout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String hostname = null;
|
String hostname = null;
|
||||||
|
@ -196,18 +198,21 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
if (hostname.contains(" ")) {
|
if (hostname.contains(" ")) {
|
||||||
mHostnameLayout.setError(getString(R.string.not_valid_hostname));
|
mHostnameLayout.setError(getString(R.string.not_valid_hostname));
|
||||||
mHostname.requestFocus();
|
mHostname.requestFocus();
|
||||||
|
removeErrorsOnAllBut(mHostnameLayout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
numericPort = Integer.parseInt(port);
|
numericPort = Integer.parseInt(port);
|
||||||
if (numericPort < 0 || numericPort > 65535) {
|
if (numericPort < 0 || numericPort > 65535) {
|
||||||
mPortLayout.setError(getString(R.string.not_a_valid_port));
|
mPortLayout.setError(getString(R.string.not_a_valid_port));
|
||||||
|
removeErrorsOnAllBut(mPortLayout);
|
||||||
mPort.requestFocus();
|
mPort.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
mPortLayout.setError(getString(R.string.not_a_valid_port));
|
mPortLayout.setError(getString(R.string.not_a_valid_port));
|
||||||
|
removeErrorsOnAllBut(mPortLayout);
|
||||||
mPort.requestFocus();
|
mPort.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,6 +224,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
} else {
|
} else {
|
||||||
mAccountJidLayout.setError(getString(R.string.invalid_jid));
|
mAccountJidLayout.setError(getString(R.string.invalid_jid));
|
||||||
}
|
}
|
||||||
|
removeErrorsOnAllBut(mAccountJidLayout);
|
||||||
mAccountJid.requestFocus();
|
mAccountJid.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -239,6 +245,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
} else {
|
} else {
|
||||||
if (xmppConnectionService.findAccountByJid(jid) != null) {
|
if (xmppConnectionService.findAccountByJid(jid) != null) {
|
||||||
mAccountJidLayout.setError(getString(R.string.account_already_exists));
|
mAccountJidLayout.setError(getString(R.string.account_already_exists));
|
||||||
|
removeErrorsOnAllBut(mAccountJidLayout);
|
||||||
mAccountJid.requestFocus();
|
mAccountJid.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1061,8 +1068,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
keysCard.setVisibility(View.GONE);
|
keysCard.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
final TextInputLayout errorLayout;
|
||||||
if (this.mAccount.errorStatus()) {
|
if (this.mAccount.errorStatus()) {
|
||||||
final TextInputLayout errorLayout;
|
|
||||||
if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) {
|
if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) {
|
||||||
errorLayout = this.mPasswordLayout;
|
errorLayout = this.mPasswordLayout;
|
||||||
} else if (mShowOptions
|
} else if (mShowOptions
|
||||||
|
@ -1077,14 +1084,32 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
errorLayout.requestFocus();
|
errorLayout.requestFocus();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.mAccountJidLayout.setError(null);
|
errorLayout = null;
|
||||||
this.mPasswordLayout.setError(null);
|
|
||||||
this.mHostnameLayout.setError(null);
|
|
||||||
}
|
}
|
||||||
|
removeErrorsOnAllBut(errorLayout);
|
||||||
this.mStats.setVisibility(View.GONE);
|
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() {
|
private void showDeletePgpDialog() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.unpublish_pgp);
|
builder.setTitle(R.string.unpublish_pgp);
|
||||||
|
|
Loading…
Reference in a new issue