mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Fixes issue 849
This commit is contained in:
parent
2c3da067c3
commit
7b75b07f1f
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -134,10 +134,7 @@ public class AccountSetupBasics extends K9Activity
|
||||
boolean valid = Utility.requiredFieldValid(mEmailView)
|
||||
&& 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);
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user