Handle leading/trailing space in passwords
* Allow, but provide warnings via EditText.setError() * Remove one last instance of password trim() Bug: 2981433 Change-Id: I406a4f8b8f27cc5ce90424a8cafe88a677e72f45 Signed-off-by: Andy Stadler <stadler@google.com>
This commit is contained in:
parent
4911af8879
commit
858c282277
@ -26,7 +26,9 @@ import com.android.email.provider.EmailContent.AccountColumns;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
@ -213,4 +215,20 @@ 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) {
|
||||
// STOPSHIP - there is a bug in the framework that makes these flicker.
|
||||
// If the bug cannot be fixed shortly, then this should be pulled before we ship
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -362,6 +362,9 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||
&& Utility.isTextViewNotEmpty(mPasswordView)
|
||||
&& mEmailValidator.isValid(mEmailView.getText().toString().trim());
|
||||
onEnableProceedButtons(valid);
|
||||
|
||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||
AccountSettingsUtils.checkPasswordSpaces(this, mPasswordView);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,7 +403,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||
*/
|
||||
private void finishAutoSetup() {
|
||||
String email = mEmailView.getText().toString().trim();
|
||||
String password = mPasswordView.getText().toString().trim();
|
||||
String password = mPasswordView.getText().toString();
|
||||
String[] emailParts = email.split("@");
|
||||
String user = emailParts[0];
|
||||
String domain = emailParts[1];
|
||||
|
@ -294,6 +294,10 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
|
||||
}
|
||||
}
|
||||
enableNextButton(enabled);
|
||||
|
||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||
AccountSettingsUtils.checkPasswordSpaces(mContext, mPasswordView);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
@ -394,6 +394,9 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
|
||||
}
|
||||
}
|
||||
enableNextButton(enabled);
|
||||
|
||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||
AccountSettingsUtils.checkPasswordSpaces(mContext, mPasswordView);
|
||||
}
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
|
@ -332,6 +332,9 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
|
||||
}
|
||||
}
|
||||
enableNextButton(enabled);
|
||||
|
||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||
AccountSettingsUtils.checkPasswordSpaces(mContext, mPasswordView);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user