Implemented that user is allowed to set BIC by herself
This commit is contained in:
parent
4bbc65bfd5
commit
e880532cc5
|
@ -44,6 +44,8 @@ open class InputValidator {
|
|||
const val BicPatternString = "[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}(?:\\b|[A-Z0-9]{03})"
|
||||
val BicPattern = Pattern.compile("^" + BicPatternString + "$")
|
||||
|
||||
val InvalidBicCharactersPattern = Pattern.compile("[^A-Z0-9]")
|
||||
|
||||
|
||||
val InvalidSepaCharactersPattern = Pattern.compile("[^${SepaMessageCreator.AllowedSepaCharacters}]+")
|
||||
}
|
||||
|
@ -62,6 +64,15 @@ open class InputValidator {
|
|||
}
|
||||
|
||||
|
||||
open fun isValidBic(stringToTest: String): Boolean {
|
||||
return BicPattern.matcher(stringToTest).matches()
|
||||
}
|
||||
|
||||
open fun getInvalidBicCharacters(string: String): String {
|
||||
return getInvalidCharacters(string, InvalidBicCharactersPattern)
|
||||
}
|
||||
|
||||
|
||||
open fun containsOnlyValidSepaCharacters(stringToTest: String): Boolean {
|
||||
return sepaMessageCreator.containsOnlyAllowedCharacters(stringToTest)
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
|
||||
rootView.edtxtRemitteeName.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredRemitteeNameIsValid() }
|
||||
rootView.edtxtRemitteeIban.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredRemitteeIbanIsValid() }
|
||||
rootView.edtxtRemitteeBic.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredRemitteeBicIsValid() }
|
||||
rootView.edtxtAmount.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredAmountIsValid() }
|
||||
rootView.edtxtUsage.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredUsageTextIsValid() }
|
||||
|
||||
|
@ -226,24 +227,20 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
|
||||
edtxtRemitteeBank.setText(if (foundBank != null) (foundBank.name + " " + foundBank.city) else "")
|
||||
|
||||
edtxtRemitteeBic.setText(foundBank?.bic ?: "")
|
||||
edtxtRemitteeBic.setText(foundBank?.bic ?: "") // TODO: check if user entered BIC to not overwrite self entered BIC
|
||||
lytRemitteeBic.error = null
|
||||
|
||||
if (foundBankForEnteredIban) {
|
||||
lytRemitteeBic.error = null
|
||||
lytRemitteeIban.error = null
|
||||
}
|
||||
|
||||
checkIfRequiredDataEnteredOnUiThread()
|
||||
}
|
||||
|
||||
protected open fun checkIfRequiredDataEnteredOnUiThread() {
|
||||
val isRemitteeNameValid = isRemitteeNameValid()
|
||||
val isValidIban = isRemitteeIbanValid()
|
||||
val isAmountValid = isAmountGreaterZero()
|
||||
val isUsageTextValid = isUsageTextValid()
|
||||
|
||||
btnTransferMoney.isEnabled = isRemitteeNameValid && isValidIban
|
||||
&& edtxtRemitteeBic?.text.toString().isNotEmpty() // TODO: check if it is of length is 8 or 11?
|
||||
&& isAmountValid && isUsageTextValid
|
||||
btnTransferMoney.isEnabled = isRemitteeNameValid() && isRemitteeIbanValid()
|
||||
&& isRemitteeBicValid()
|
||||
&& isAmountGreaterZero() && isUsageTextValid()
|
||||
}
|
||||
|
||||
protected open fun checkIfEnteredRemitteeNameIsValid() {
|
||||
|
@ -264,11 +261,13 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
protected open fun checkIfEnteredRemitteeIbanIsValid() {
|
||||
val enteredIban = edtxtRemitteeIban.text.toString()
|
||||
|
||||
if (isRemitteeIbanValid()) {
|
||||
lytRemitteeIban.error = null
|
||||
}
|
||||
else {
|
||||
val invalidIbanCharacters = inputValidator.getInvalidIbanCharacters(edtxtRemitteeIban.text.toString())
|
||||
val invalidIbanCharacters = inputValidator.getInvalidIbanCharacters(enteredIban)
|
||||
if (invalidIbanCharacters.isNotEmpty()) {
|
||||
lytRemitteeIban.error = context?.getString(R.string.error_invalid_iban_characters_entered, invalidIbanCharacters)
|
||||
}
|
||||
|
@ -277,7 +276,7 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
if (foundBankForEnteredIban) {
|
||||
if (foundBankForEnteredIban || enteredIban.isBlank()) {
|
||||
lytRemitteeBic.error = null
|
||||
}
|
||||
else {
|
||||
|
@ -289,6 +288,32 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
return inputValidator.isValidIban(edtxtRemitteeIban.text.toString())
|
||||
}
|
||||
|
||||
protected open fun checkIfEnteredRemitteeBicIsValid() {
|
||||
if (isRemitteeBicValid()) {
|
||||
lytRemitteeBic.error = null
|
||||
}
|
||||
else {
|
||||
val enteredBic = edtxtRemitteeBic.text.toString()
|
||||
|
||||
if (enteredBic.isBlank()) {
|
||||
lytRemitteeBic.error = context?.getString(R.string.error_no_bic_entered)
|
||||
}
|
||||
else {
|
||||
val invalidBicCharacters = inputValidator.getInvalidBicCharacters(enteredBic)
|
||||
if (invalidBicCharacters.isNotEmpty()) {
|
||||
lytRemitteeBic.error = context?.getString(R.string.error_invalid_bic_characters_entered, invalidBicCharacters)
|
||||
}
|
||||
else {
|
||||
lytRemitteeBic.error = context?.getString(R.string.error_invalid_bic_pattern_entered)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun isRemitteeBicValid(): Boolean {
|
||||
return inputValidator.isValidBic(edtxtRemitteeBic.text.toString())
|
||||
}
|
||||
|
||||
protected open fun checkIfEnteredAmountIsValid() {
|
||||
if (isAmountGreaterZero()) {
|
||||
lytAmount.error = null
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_transfer_money_input_fields_height"
|
||||
android:inputType="text"
|
||||
android:enabled="false"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
<string name="error_invalid_iban_characters_entered">Unzulässige(s) Zeichen eingegeben: %s</string>
|
||||
<string name="error_invalid_iban_pattern_entered">IBANs bestehen aus folgendem Muster: DE12 1234 5678 9012 3456 78</string>
|
||||
<string name="error_no_bank_found_for_entered_iban">Es wurde keine Bank zur eingegebenen IBAN gefunden.</string>
|
||||
<string name="error_no_bic_entered">Bitte geben Sie die BIC des Empfängers ein</string>
|
||||
<string name="error_invalid_bic_characters_entered">Unzulässige(s) Zeichen eingegeben: %s</string>
|
||||
<string name="error_invalid_bic_pattern_entered">Eine BIC besteht aus 8 oder 11 Zeichen und folgt dem Muster: ABCDED12(XYZ)</string>
|
||||
<string name="error_no_amount_entered">Bitte geben Sie den zu überweisenden Betrag ein</string>
|
||||
<string name="error_invalid_amount_entered">Bitte geben Sie einen Betrag größer 0 ein.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
<string name="error_invalid_iban_characters_entered">Invalid character(s) entered: %s</string>
|
||||
<string name="error_invalid_iban_pattern_entered">IBAN has to have pattern: EN12 1234 5678 9012 3456 78</string>
|
||||
<string name="error_no_bank_found_for_entered_iban">No bank found for entered IBAN.</string>
|
||||
<string name="error_no_bic_entered">Please enter remittee\'s BIC</string>
|
||||
<string name="error_invalid_bic_characters_entered">Invalid character(s) entered: %s</string>
|
||||
<string name="error_invalid_bic_pattern_entered">A BIC consists of 8 or 11 characters and has the pattern: ABCDED12(XYZ)</string>
|
||||
<string name="error_no_amount_entered">Please enter the amount to be transferred</string>
|
||||
<string name="error_invalid_amount_entered">Please enter an amount greater zero.</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue