am 8f319d1c: am b3412d7f: Merge "Handle leading/trailing space in passwords" into honeycomb

* commit '8f319d1c3e164baafed62515114dfc699baa940f':
  Handle leading/trailing space in passwords
This commit is contained in:
Andy Stadler 2011-01-19 16:47:55 -08:00 committed by Android Git Automerger
commit 5c296e8746
5 changed files with 32 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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

View File

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