Add possibility to ignore spaces in EditTexts

This commit is contained in:
Michael Schättgen 2019-05-21 21:18:01 +02:00
parent 57e3574693
commit 3556cd0e66
2 changed files with 12 additions and 4 deletions

View file

@ -14,9 +14,17 @@ public class EditTextHelper {
}
public static char[] getEditTextChars(EditText text) {
Editable editable = text.getText();
char[] chars = new char[editable.length()];
editable.getChars(0, editable.length(), chars, 0);
return getEditTextChars(text, false);
}
public static char[] getEditTextChars(EditText text, boolean removeSpaces) {
String editTextString = text.getText().toString();
if (removeSpaces) {
editTextString = editTextString.replaceAll("\\s","");
}
char[] chars = new char[editTextString.length()];
editTextString.getChars(0, editTextString.length(), chars, 0);
return chars;
}

View file

@ -444,7 +444,7 @@ public class EditEntryActivity extends AegisActivity {
byte[] secret;
try {
secret = Base32.decode(EditTextHelper.getEditTextChars(_textSecret));
secret = Base32.decode(EditTextHelper.getEditTextChars(_textSecret, true));
} catch (Base32Exception e) {
throw new ParseException("Secret is not valid base32.");
}