Implemented not showing an error message if user cancelled action (e.g. entering TAN or selecting a TAN medium)

This commit is contained in:
dankito 2020-04-29 22:46:31 +02:00
parent 4d64bc79bf
commit ec2c8fc5c9
12 changed files with 37 additions and 28 deletions

View File

@ -274,7 +274,7 @@ open class TransferMoneyDialog @JvmOverloads constructor(
dialogService.showInfoMessage(String.format(messages["transfer.money.dialog.message.transfer.cash.success"],
transferData.amount, currency, transferData.creditorName), null, currentStage)
}
else {
else if (response.userCancelledAction == false) {
dialogService.showErrorMessage(String.format(messages["transfer.money.dialog.message.transfer.cash.error"],
transferData.amount, currency, transferData.creditorName, response.errorToShowToUser), null, response.error, currentStage)
}

View File

@ -196,7 +196,7 @@ open class EnterTanDialog(
close()
}
else {
else if (response.userCancelledAction == false) {
dialogService.showErrorMessageOnUiThread(String.format(messages["enter.tan.dialog.tan.error.changing.tan.medium"],
newUsedTanMedium.displayName, response.errorToShowToUser), null, response.error, currentStage)
}

View File

@ -14,9 +14,10 @@ open class AddAccountResponse(
bookedTransactionsOfLast90Days: Map<BankAccount, List<AccountTransaction>> = mapOf(),
unbookedTransactionsOfLast90Days: Map<BankAccount, List<Any>> = mapOf(),
balances: Map<BankAccount, BigDecimal> = mapOf(),
error: Exception? = null
error: Exception? = null,
userCancelledAction: Boolean = false
)
: GetTransactionsResponse(isSuccessful, errorToShowToUser, bookedTransactionsOfLast90Days, unbookedTransactionsOfLast90Days, balances, error) {
: GetTransactionsResponse(isSuccessful, errorToShowToUser, bookedTransactionsOfLast90Days, unbookedTransactionsOfLast90Days, balances, error, userCancelledAction) {
override fun toString(): String {
return account.toString() + " " + super.toString()

View File

@ -4,7 +4,8 @@ package net.dankito.banking.ui.model.responses
open class BankingClientResponse(
val isSuccessful: Boolean,
val errorToShowToUser: String?,
val error: Exception? = null
val error: Exception? = null,
val userCancelledAction: Boolean = false // TODO: not implemented in hbci4jBankingClient yet
) {

View File

@ -11,6 +11,7 @@ open class GetTransactionsResponse(
val bookedTransactions: Map<BankAccount, List<AccountTransaction>> = mapOf(),
val unbookedTransactions: Map<BankAccount, List<Any>> = mapOf(),
val balances: Map<BankAccount, BigDecimal> = mapOf(),
error: Exception? = null
error: Exception? = null,
userCancelledAction: Boolean = false
)
: BankingClientResponse(isSuccessful, errorToShowToUser, error)
: BankingClientResponse(isSuccessful, errorToShowToUser, error, userCancelledAction)

View File

@ -205,7 +205,7 @@ open class EnterTanDialog : DialogFragment() {
}
.show()
}
else {
else if (response.userCancelledAction == false) {
AlertDialog.Builder(context)
.setMessage(context.getString(R.string.dialog_enter_tan_error_changing_tan_medium, newUsedTanMedium.displayName, response.errorToShowToUser))
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }

View File

@ -213,21 +213,23 @@ open class TransferMoneyDialog : DialogFragment() {
protected open fun handleTransferMoneyResultOnUiThread(transferData: TransferMoneyData, response: BankingClientResponse) {
context?.let { context ->
val message = if (response.isSuccessful) {
context.getString(R.string.dialog_transfer_money_message_transfer_successful,
String.format("%.02f", transferData.amount), "", transferData.creditorName) // TODO: where to get currency from?
}
else {
context.getString(R.string.dialog_transfer_money_message_transfer_failed,
String.format("%.02f", transferData.amount), "", transferData.creditorName, // TODO: where to get currency from?
response.errorToShowToUser
)
}
if (response.userCancelledAction == false) {
val message = if (response.isSuccessful) {
context.getString(R.string.dialog_transfer_money_message_transfer_successful,
String.format("%.02f", transferData.amount), "", transferData.creditorName) // TODO: where to get currency from?
}
else {
context.getString(R.string.dialog_transfer_money_message_transfer_failed,
String.format("%.02f", transferData.amount), "", transferData.creditorName, // TODO: where to get currency from?
response.errorToShowToUser
)
}
AlertDialog.Builder(context)
.setMessage(message)
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
.show()
AlertDialog.Builder(context)
.setMessage(message)
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
.show()
}
this.dismiss()
}

View File

@ -158,7 +158,7 @@ class HomeFragment : Fragment() {
if (response.isSuccessful) {
updateTransactionsToDisplayOnUiThread()
}
else {
else if (response.userCancelledAction == false) { // if user cancelled entering TAN then don't show a error message
AlertDialog.Builder(activity) // TODO: may show account name in message
.setMessage(activity.getString(R.string.fragment_home_could_not_retrieve_account_transactions, response.errorToShowToUser))
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }

View File

@ -42,6 +42,7 @@ open class fints4javaModelMapper {
mappedBookedTransactions,
mapOf(), // TODO: map unbooked transactions
balances,
response.userCancelledAction,
response.exception)
}
@ -51,7 +52,7 @@ open class fints4javaModelMapper {
mapOf(bankAccount to mapTransactions(bankAccount, response.bookedTransactions)),
mapOf(), // TODO: map unbooked transactions
response.balance?.let { mapOf(bankAccount to it) } ?: mapOf(),
response.exception)
response.exception, response.userCancelledAction)
}
open fun mapErrorToShowToUser(response: FinTsClientResponse): String? {

View File

@ -663,7 +663,7 @@ open class FinTsClient @JvmOverloads constructor(
else if (enteredTanResult.enteredTan == null) {
// i tried to send a HKTAN with cancelJob = true but then i saw there are no tan procedures that support cancellation (at least not at my bank)
// but it's not required anyway, tan times out after some time. Simply don't respond anything and close dialog
response.tanRequiredButNotProvided = true
response.tanRequiredButUserDidNotEnterOne = true
}
else {
return sendTanToBank(enteredTanResult.enteredTan, tanResponse, bank, customer, dialogData)

View File

@ -27,11 +27,11 @@ open class Response(
open val responseContainsErrors: Boolean
get() = exception == null && messageFeedback?.isError == true
open var tanRequiredButNotProvided = false
open var tanRequiredButUserDidNotEnterOne = false
open val successful: Boolean
get() = noTanProcedureSelected == false && couldCreateMessage && didReceiveResponse
&& responseContainsErrors == false && tanRequiredButNotProvided == false
&& responseContainsErrors == false && tanRequiredButUserDidNotEnterOne == false
open val isStrongAuthenticationRequired: Boolean
get() = tanResponse?.isStrongAuthenticationRequired == true

View File

@ -20,6 +20,8 @@ open class FinTsClientResponse(
*/
val exception: Exception? = null,
val userCancelledAction: Boolean = false,
val isJobAllowed: Boolean = true,
val isJobVersionSupported: Boolean = true,
val allowedVersions: List<Int> = listOf(),
@ -29,7 +31,8 @@ open class FinTsClientResponse(
constructor(response: Response) : this(response.successful, response.noTanProcedureSelected,
response.isStrongAuthenticationRequired, response.tanResponse, response.errorsToShowToUser,
response.exception, response.messageCreationError?.isJobAllowed ?: true,
response.exception, response.tanRequiredButUserDidNotEnterOne,
response.messageCreationError?.isJobAllowed ?: true,
response.messageCreationError?.isJobVersionSupported ?: true,
response.messageCreationError?.allowedVersions ?: listOf(),
response.messageCreationError?.supportedVersions ?: listOf())