From c35c4b14c9e7d68137d8a958b64c773e7ec5d150 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Fri, 7 Oct 2011 18:03:16 -0700 Subject: [PATCH] Fix persistent "empty name" error. We were never clearing the error state when typing in a field that needed to be non-empty. Bug: 5422268 Change-Id: Iabe8c6f6c348b4210695c3eeff98e79e60f83d08 --- .../email/activity/setup/AccountSetupNames.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/activity/setup/AccountSetupNames.java b/src/com/android/email/activity/setup/AccountSetupNames.java index 99e23676b..94d043b2f 100644 --- a/src/com/android/email/activity/setup/AccountSetupNames.java +++ b/src/com/android/email/activity/setup/AccountSetupNames.java @@ -74,13 +74,16 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi mNextButton.setOnClickListener(this); TextWatcher validationTextWatcher = new TextWatcher() { + @Override public void afterTextChanged(Editable s) { validateFields(); } + @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } + @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }; @@ -162,16 +165,18 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi * Check input fields for legal values and enable/disable next button */ private void validateFields() { - boolean newEnabled = true; + boolean enableNextButton = true; // Validation is based only on the "user name" field, not shown for EAS accounts if (!mEasAccount) { String userName = mName.getText().toString().trim(); - newEnabled = !TextUtils.isEmpty(userName); - if (!newEnabled) { + if (TextUtils.isEmpty(userName)) { + enableNextButton = false; mName.setError(getString(R.string.account_setup_names_user_name_empty_error)); + } else { + mName.setError(null); } } - mNextButton.setEnabled(newEnabled); + mNextButton.setEnabled(enableNextButton); } /**