am 784b61cc: am 34a686ab: am dfb7fe91: Remove password spaces warning

* commit '784b61cca1849d287bc8aa28702936edfcbd292b':
  Remove password spaces warning
This commit is contained in:
Tony Mantler 2014-11-02 17:37:13 +00:00 committed by Android Git Automerger
commit 685f2f1d64
4 changed files with 27 additions and 52 deletions

View File

@ -229,10 +229,6 @@
<string name="account_duplicate_dlg_message_fmt">
You\'re already using this username for the account \"<xliff:g id="duplicate">%s</xliff:g>\".
</string>
<!-- String that is displayed as error text for passwords with leading or trailing
spaces. [CHAR LIMIT=none] -->
<string name="account_password_spaces_error">This password starts or ends with one or more
space characters. Many servers don\'t support passwords with spaces.</string>
<!-- On check-settings screen, this is the initially-displayed message. -->
<string name="account_setup_check_settings_retr_info_msg">

View File

@ -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));
}
}
}
}

View File

@ -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

View File

@ -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) {