Implemented hiding when neither an error nor an hint is displayed
This commit is contained in:
parent
4f75968efa
commit
1ac426ecb8
|
@ -38,6 +38,7 @@ import net.dankito.banking.util.ValidationResult
|
||||||
import net.dankito.utils.multiplatform.toBigDecimal
|
import net.dankito.utils.multiplatform.toBigDecimal
|
||||||
import net.dankito.utils.android.extensions.asActivity
|
import net.dankito.utils.android.extensions.asActivity
|
||||||
import net.dankito.utils.android.extensions.getDimension
|
import net.dankito.utils.android.extensions.getDimension
|
||||||
|
import net.dankito.utils.android.extensions.getResourceIdentifier
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
import java.text.DecimalFormatSymbols
|
import java.text.DecimalFormatSymbols
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -348,10 +349,12 @@ open class TransferMoneyDialog : DialogFragment() {
|
||||||
if (foundBank != null) {
|
if (foundBank != null) {
|
||||||
txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_bic_detected_from_iban, foundBank.bic, foundBank.name)
|
txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_bic_detected_from_iban, foundBank.bic, foundBank.name)
|
||||||
txtRecipientBankInfo.visibility = View.VISIBLE
|
txtRecipientBankInfo.visibility = View.VISIBLE
|
||||||
|
setIbanValidationErrorVisibility()
|
||||||
}
|
}
|
||||||
else if (enteredIban.length >= InputValidator.MinimumLengthToDetermineBicFromIban) {
|
else if (enteredIban.length >= InputValidator.MinimumLengthToDetermineBicFromIban) {
|
||||||
txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_could_not_determine_bic_from_iban, enteredIban.substring(4, InputValidator.MinimumLengthToDetermineBicFromIban))
|
txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_could_not_determine_bic_from_iban, enteredIban.substring(4, InputValidator.MinimumLengthToDetermineBicFromIban))
|
||||||
txtRecipientBankInfo.visibility = View.VISIBLE
|
txtRecipientBankInfo.visibility = View.VISIBLE
|
||||||
|
setIbanValidationErrorVisibility()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
txtRecipientBankInfo.visibility = View.GONE
|
txtRecipientBankInfo.visibility = View.GONE
|
||||||
|
@ -360,6 +363,21 @@ open class TransferMoneyDialog : DialogFragment() {
|
||||||
checkIfRequiredDataEnteredOnUiThread()
|
checkIfRequiredDataEnteredOnUiThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun setIbanValidationErrorVisibility() {
|
||||||
|
getIbanTextInputErrorView()?.let { textInputError ->
|
||||||
|
val displaysErrorOrHint = lytRecipientIban.error != null || lytRecipientIban.helperText != null
|
||||||
|
(textInputError.parent?.parent as? ViewGroup)?.visibility = if (displaysErrorOrHint) View.VISIBLE else View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun getIbanTextInputErrorView(): TextView? {
|
||||||
|
requireContext().getResourceIdentifier("textinput_error", "id")?.let { textInputErrorId ->
|
||||||
|
return lytRecipientIban.findViewById(textInputErrorId)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun checkIfRequiredDataEnteredOnUiThread() {
|
protected open fun checkIfRequiredDataEnteredOnUiThread() {
|
||||||
btnTransferMoney.isEnabled = validRecipientNameEntered && validRecipientIbanEntered
|
btnTransferMoney.isEnabled = validRecipientNameEntered && validRecipientIbanEntered
|
||||||
&& validRecipientBicEntered
|
&& validRecipientBicEntered
|
||||||
|
@ -393,6 +411,7 @@ open class TransferMoneyDialog : DialogFragment() {
|
||||||
this.validRecipientIbanEntered = validationResult.validationSuccessfulOrCouldCorrectString
|
this.validRecipientIbanEntered = validationResult.validationSuccessfulOrCouldCorrectString
|
||||||
|
|
||||||
showValidationResult(lytRecipientIban, validationResult)
|
showValidationResult(lytRecipientIban, validationResult)
|
||||||
|
setIbanValidationErrorVisibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun checkIfEnteredRecipientIbanIsValidAfterFocusLost() {
|
protected open fun checkIfEnteredRecipientIbanIsValidAfterFocusLost() {
|
||||||
|
@ -402,6 +421,7 @@ open class TransferMoneyDialog : DialogFragment() {
|
||||||
|
|
||||||
if (validationResult.validationSuccessful == false) { // only update hint / error if validation fails, don't hide previous hint / error otherwise
|
if (validationResult.validationSuccessful == false) { // only update hint / error if validation fails, don't hide previous hint / error otherwise
|
||||||
showValidationResult(lytRecipientIban, validationResult)
|
showValidationResult(lytRecipientIban, validationResult)
|
||||||
|
setIbanValidationErrorVisibility()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue