1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

Fixes issue 849

This commit is contained in:
cketti 2010-02-13 17:26:54 +00:00
parent 2c3da067c3
commit 7b75b07f1f
2 changed files with 11 additions and 6 deletions

View File

@ -1,11 +1,19 @@
package com.fsck.k9;
import android.text.util.Rfc822Tokenizer;
import java.util.regex.Pattern;
import android.widget.AutoCompleteTextView.Validator;
public class EmailAddressValidator implements Validator
{
// Source: http://www.regular-expressions.info/email.html
private static Pattern p = Pattern.compile(
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +
"(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" +
"@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+" +
"[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
public CharSequence fixText(CharSequence invalidText)
{
return "";
@ -13,6 +21,6 @@ public class EmailAddressValidator implements Validator
public boolean isValid(CharSequence text)
{
return Rfc822Tokenizer.tokenize(text).length > 0;
return p.matcher(text).matches();
}
}

View File

@ -135,9 +135,6 @@ public class AccountSetupBasics extends K9Activity
&& Utility.requiredFieldValid(mPasswordView)
&& mEmailValidator.isValid(email);
//FIXME: "foo@bar .com" will validate
/*&& email.contains("@"); */ // Not sure if this is a good idea or not
mNextButton.setEnabled(valid);
mManualSetupButton.setEnabled(valid);
/*