diff --git a/src/com/android/email/activity/setup/AccountSettingsUtils.java b/src/com/android/email/activity/setup/AccountSettingsUtils.java index b1b5d40d2..f8f2cc23f 100644 --- a/src/com/android/email/activity/setup/AccountSettingsUtils.java +++ b/src/com/android/email/activity/setup/AccountSettingsUtils.java @@ -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)); + } + } + } + } diff --git a/src/com/android/email/activity/setup/AccountSetupBasics.java b/src/com/android/email/activity/setup/AccountSetupBasics.java index bad0d8761..4e11b8b9b 100644 --- a/src/com/android/email/activity/setup/AccountSetupBasics.java +++ b/src/com/android/email/activity/setup/AccountSetupBasics.java @@ -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]; diff --git a/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java b/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java index 67b4c2da7..de0184b82 100644 --- a/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java @@ -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; } diff --git a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java index f489ae4fa..d7e038fa3 100644 --- a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java @@ -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() { diff --git a/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java b/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java index f265c7d65..0177bce35 100644 --- a/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java @@ -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); } /**