diff --git a/res/values/strings.xml b/res/values/strings.xml index 7ae6b65c4..4d8add132 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -229,10 +229,6 @@ You\'re already using this username for the account \"%s\". - - This password starts or ends with one or more - space characters. Many servers don\'t support passwords with spaces. diff --git a/src/com/android/email/activity/setup/AccountSettingsUtils.java b/src/com/android/email/activity/setup/AccountSettingsUtils.java index a254604b9..dbbd51ee7 100644 --- a/src/com/android/email/activity/setup/AccountSettingsUtils.java +++ b/src/com/android/email/activity/setup/AccountSettingsUtils.java @@ -21,12 +21,9 @@ import android.content.ContentValues; import android.content.Context; import android.content.res.XmlResourceParser; import android.net.Uri; -import android.text.Editable; import android.text.TextUtils; -import android.widget.EditText; import com.android.email.R; -import com.android.email.SecurityPolicy; import com.android.email.provider.AccountBackupRestore; import com.android.emailcommon.Logging; import com.android.emailcommon.VendorPolicyLoader; @@ -433,17 +430,4 @@ public class AccountSettingsUtils { return ((incoming != null) ? incoming : outgoing) + '.' + server.substring(keepFirstChar); } - /** - * Helper to set error status on password fields that have leading or trailing spaces - */ - public static void checkPasswordSpaces(Context context, EditText passwordField) { - Editable password = passwordField.getText(); - int length = password.length(); - if (length > 0) { - if (password.charAt(0) == ' ' || password.charAt(length-1) == ' ') { - passwordField.setError(context.getString(R.string.account_password_spaces_error)); - } - } - } - } diff --git a/src/com/android/email/activity/setup/AccountSetupCredentialsFragment.java b/src/com/android/email/activity/setup/AccountSetupCredentialsFragment.java index dcb824ab1..09623a2b8 100644 --- a/src/com/android/email/activity/setup/AccountSetupCredentialsFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupCredentialsFragment.java @@ -145,23 +145,25 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment mClientCertificateSelector.setCertificate(getArguments().getString(EXTRA_CLIENT_CERT)); // After any text edits, call validateFields() which enables or disables the Next button - mValidationTextWatcher = new TextWatcher() { - @Override - public void afterTextChanged(Editable s) { - validatePassword(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { } - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { } - }; + mValidationTextWatcher = new PasswordTextWatcher(); mImapPasswordText.addTextChangedListener(mValidationTextWatcher); mRegularPasswordText.addTextChangedListener(mValidationTextWatcher); return view; } + private class PasswordTextWatcher implements TextWatcher { + @Override + public void afterTextChanged(Editable s) { + validatePassword(); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { } + } + @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -243,9 +245,6 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment public void validatePassword() { setNextButtonEnabled(!TextUtils.isEmpty(getPassword())); - // Warn (but don't prevent) if password has leading/trailing spaces - AccountSettingsUtils.checkPasswordSpaces(mAppContext, mImapPasswordText); - AccountSettingsUtils.checkPasswordSpaces(mAppContext, mRegularPasswordText); } @Override diff --git a/src/com/android/email/activity/setup/AuthenticationView.java b/src/com/android/email/activity/setup/AuthenticationView.java index 7f1382800..2fb944f37 100644 --- a/src/com/android/email/activity/setup/AuthenticationView.java +++ b/src/com/android/email/activity/setup/AuthenticationView.java @@ -16,14 +16,11 @@ import android.widget.TextView; import com.android.email.R; import com.android.email.activity.UiUtilities; -import com.android.emailcommon.Device; import com.android.emailcommon.VendorPolicyLoader.OAuthProvider; import com.android.emailcommon.provider.Credential; import com.android.emailcommon.provider.HostAuth; import com.google.common.annotations.VisibleForTesting; -import java.io.IOException; - public class AuthenticationView extends LinearLayout implements OnClickListener { private final static String SUPER_STATE = "super_state"; @@ -44,8 +41,6 @@ public class AuthenticationView extends LinearLayout implements OnClickListener private View mClearOAuthView; private View mAddAuthenticationView; - private TextWatcher mValidationTextWatcher; - private boolean mOfferOAuth; private boolean mUseOAuth; private String mOAuthProvider; @@ -93,18 +88,21 @@ public class AuthenticationView extends LinearLayout implements OnClickListener mClearOAuthView.setOnClickListener(this); mAddAuthenticationView.setOnClickListener(this); - mValidationTextWatcher = new TextWatcher() { - @Override - public void afterTextChanged(Editable s) { - validateFields(); - } + final TextWatcher validationTextWatcher = new PasswordTextWatcher(); + mPasswordEdit.addTextChangedListener(validationTextWatcher); + } - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { } - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { } - }; - mPasswordEdit.addTextChangedListener(mValidationTextWatcher); + private class PasswordTextWatcher implements 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) { } } public void setAuthenticationCallback(final AuthenticationCallback host) { @@ -138,8 +136,6 @@ public class AuthenticationView extends LinearLayout implements OnClickListener mAuthenticationCallback.onValidateStateChanged(); mAuthenticationValid = valid; } - // Warn (but don't prevent) if password has leading/trailing spaces - AccountSettingsUtils.checkPasswordSpaces(getContext(), mPasswordEdit); } public void setAuthInfo(final boolean offerOAuth, final HostAuth hostAuth) {