Remove password spaces warning
b/17409681 Change-Id: Ia411999fc7652b520f17fa2538980d9ba4bd172a
This commit is contained in:
parent
0ee421760a
commit
dfb7fe91e6
|
@ -229,10 +229,6 @@
|
||||||
<string name="account_duplicate_dlg_message_fmt">
|
<string name="account_duplicate_dlg_message_fmt">
|
||||||
You\'re already using this username for the account \"<xliff:g id="duplicate">%s</xliff:g>\".
|
You\'re already using this username for the account \"<xliff:g id="duplicate">%s</xliff:g>\".
|
||||||
</string>
|
</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. -->
|
<!-- On check-settings screen, this is the initially-displayed message. -->
|
||||||
<string name="account_setup_check_settings_retr_info_msg">
|
<string name="account_setup_check_settings_retr_info_msg">
|
||||||
|
|
|
@ -21,12 +21,9 @@ import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.XmlResourceParser;
|
import android.content.res.XmlResourceParser;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
import com.android.email.SecurityPolicy;
|
|
||||||
import com.android.email.provider.AccountBackupRestore;
|
import com.android.email.provider.AccountBackupRestore;
|
||||||
import com.android.emailcommon.Logging;
|
import com.android.emailcommon.Logging;
|
||||||
import com.android.emailcommon.VendorPolicyLoader;
|
import com.android.emailcommon.VendorPolicyLoader;
|
||||||
|
@ -433,17 +430,4 @@ public class AccountSettingsUtils {
|
||||||
return ((incoming != null) ? incoming : outgoing) + '.' + server.substring(keepFirstChar);
|
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,23 +145,25 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
||||||
mClientCertificateSelector.setCertificate(getArguments().getString(EXTRA_CLIENT_CERT));
|
mClientCertificateSelector.setCertificate(getArguments().getString(EXTRA_CLIENT_CERT));
|
||||||
|
|
||||||
// After any text edits, call validateFields() which enables or disables the Next button
|
// After any text edits, call validateFields() which enables or disables the Next button
|
||||||
mValidationTextWatcher = new TextWatcher() {
|
mValidationTextWatcher = new PasswordTextWatcher();
|
||||||
@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) { }
|
|
||||||
};
|
|
||||||
mImapPasswordText.addTextChangedListener(mValidationTextWatcher);
|
mImapPasswordText.addTextChangedListener(mValidationTextWatcher);
|
||||||
mRegularPasswordText.addTextChangedListener(mValidationTextWatcher);
|
mRegularPasswordText.addTextChangedListener(mValidationTextWatcher);
|
||||||
|
|
||||||
return view;
|
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
|
@Override
|
||||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
@ -243,9 +245,6 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
||||||
|
|
||||||
public void validatePassword() {
|
public void validatePassword() {
|
||||||
setNextButtonEnabled(!TextUtils.isEmpty(getPassword()));
|
setNextButtonEnabled(!TextUtils.isEmpty(getPassword()));
|
||||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
|
||||||
AccountSettingsUtils.checkPasswordSpaces(mAppContext, mImapPasswordText);
|
|
||||||
AccountSettingsUtils.checkPasswordSpaces(mAppContext, mRegularPasswordText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,14 +16,11 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
import com.android.email.activity.UiUtilities;
|
import com.android.email.activity.UiUtilities;
|
||||||
import com.android.emailcommon.Device;
|
|
||||||
import com.android.emailcommon.VendorPolicyLoader.OAuthProvider;
|
import com.android.emailcommon.VendorPolicyLoader.OAuthProvider;
|
||||||
import com.android.emailcommon.provider.Credential;
|
import com.android.emailcommon.provider.Credential;
|
||||||
import com.android.emailcommon.provider.HostAuth;
|
import com.android.emailcommon.provider.HostAuth;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class AuthenticationView extends LinearLayout implements OnClickListener {
|
public class AuthenticationView extends LinearLayout implements OnClickListener {
|
||||||
|
|
||||||
private final static String SUPER_STATE = "super_state";
|
private final static String SUPER_STATE = "super_state";
|
||||||
|
@ -44,8 +41,6 @@ public class AuthenticationView extends LinearLayout implements OnClickListener
|
||||||
private View mClearOAuthView;
|
private View mClearOAuthView;
|
||||||
private View mAddAuthenticationView;
|
private View mAddAuthenticationView;
|
||||||
|
|
||||||
private TextWatcher mValidationTextWatcher;
|
|
||||||
|
|
||||||
private boolean mOfferOAuth;
|
private boolean mOfferOAuth;
|
||||||
private boolean mUseOAuth;
|
private boolean mUseOAuth;
|
||||||
private String mOAuthProvider;
|
private String mOAuthProvider;
|
||||||
|
@ -93,18 +88,21 @@ public class AuthenticationView extends LinearLayout implements OnClickListener
|
||||||
mClearOAuthView.setOnClickListener(this);
|
mClearOAuthView.setOnClickListener(this);
|
||||||
mAddAuthenticationView.setOnClickListener(this);
|
mAddAuthenticationView.setOnClickListener(this);
|
||||||
|
|
||||||
mValidationTextWatcher = new TextWatcher() {
|
final TextWatcher validationTextWatcher = new PasswordTextWatcher();
|
||||||
@Override
|
mPasswordEdit.addTextChangedListener(validationTextWatcher);
|
||||||
public void afterTextChanged(Editable s) {
|
}
|
||||||
validateFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private class PasswordTextWatcher implements TextWatcher {
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) { }
|
public void afterTextChanged(Editable s) {
|
||||||
};
|
validateFields();
|
||||||
mPasswordEdit.addTextChangedListener(mValidationTextWatcher);
|
}
|
||||||
|
|
||||||
|
@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) {
|
public void setAuthenticationCallback(final AuthenticationCallback host) {
|
||||||
|
@ -138,8 +136,6 @@ public class AuthenticationView extends LinearLayout implements OnClickListener
|
||||||
mAuthenticationCallback.onValidateStateChanged();
|
mAuthenticationCallback.onValidateStateChanged();
|
||||||
mAuthenticationValid = valid;
|
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) {
|
public void setAuthInfo(final boolean offerOAuth, final HostAuth hostAuth) {
|
||||||
|
|
Loading…
Reference in New Issue