|
|
@ -67,6 +67,8 @@ import java.io.IOException;
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
|
@ -227,9 +229,14 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
|
|
|
Pattern pattern = Pattern.compile("[a-zA-Z0-9_]+");
|
|
|
|
|
|
|
|
Matcher matcher = pattern.matcher(s.toString());
|
|
|
|
if (s.toString().isEmpty()) {
|
|
|
|
if (s.toString().isEmpty()) {
|
|
|
|
name.getInput().setError("Invalid");
|
|
|
|
name.getInput().setError("Invalid");
|
|
|
|
finishButton.setEnabled(false);
|
|
|
|
finishButton.setEnabled(false);
|
|
|
|
|
|
|
|
} else if (!matcher.matches()) {
|
|
|
|
|
|
|
|
name.getInput().setError("Invalid (a-z, A-Z, 0-9 and _ only)");
|
|
|
|
|
|
|
|
finishButton.setEnabled(false);
|
|
|
|
} else if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
|
|
|
|
} else if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
|
|
|
|
name.getInput().setError(getString(R.string.CreateProfileActivity_too_long));
|
|
|
|
name.getInput().setError(getString(R.string.CreateProfileActivity_too_long));
|
|
|
|
finishButton.setEnabled(false);
|
|
|
|
finishButton.setEnabled(false);
|
|
|
|