Implemented passing MessageLogEntryType on to UI so that it has the possibility to translate the message prefix
This commit is contained in:
parent
8b7e1f7020
commit
ae7f6328e3
|
@ -22,18 +22,16 @@ open class MessageLogCollector {
|
|||
|
||||
// in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData
|
||||
open val messageLogWithoutSensitiveData: List<MessageLogEntry>
|
||||
get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.time, it.bank) }
|
||||
get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) }
|
||||
|
||||
|
||||
open fun addMessageLog(message: String, type: MessageLogEntryType, bank: BankData) {
|
||||
val timeStamp = Date()
|
||||
val messagePrefix = "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" // currently no need to translate
|
||||
val prettyPrintMessage = prettyPrintHbciMessage(message)
|
||||
val prettyPrintMessageWithPrefix = "$messagePrefix$prettyPrintMessage"
|
||||
|
||||
log.debug { prettyPrintMessageWithPrefix }
|
||||
log.debug { "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" + prettyPrintMessage }
|
||||
|
||||
messageLog.add(MessageLogEntry(prettyPrintMessageWithPrefix, timeStamp, bank))
|
||||
messageLog.add(MessageLogEntry(prettyPrintMessage, type, timeStamp, bank))
|
||||
}
|
||||
|
||||
protected open fun prettyPrintHbciMessage(message: String): String {
|
||||
|
|
|
@ -4,13 +4,14 @@ import net.dankito.utils.multiplatform.Date
|
|||
|
||||
|
||||
open class MessageLogEntry(
|
||||
val message: String,
|
||||
val time: Date,
|
||||
val bank: BankData
|
||||
open val message: String,
|
||||
open val type: MessageLogEntryType,
|
||||
open val time: Date,
|
||||
open val bank: BankData
|
||||
) {
|
||||
|
||||
override fun toString(): String {
|
||||
return message
|
||||
return "$type $message"
|
||||
}
|
||||
|
||||
}
|
|
@ -4,9 +4,10 @@ import net.dankito.utils.multiplatform.Date
|
|||
|
||||
|
||||
open class MessageLogEntry(
|
||||
val message: String,
|
||||
val time: Date,
|
||||
val bank: TypedBankData
|
||||
open val message: String,
|
||||
open val type: MessageLogEntryType,
|
||||
open val time: Date,
|
||||
open val bank: TypedBankData
|
||||
) {
|
||||
|
||||
override fun toString(): String {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package net.dankito.banking.ui.model
|
||||
|
||||
|
||||
enum class MessageLogEntryType {
|
||||
|
||||
Sent,
|
||||
|
||||
Received
|
||||
|
||||
}
|
|
@ -799,10 +799,14 @@ open class BankingPresenter(
|
|||
})
|
||||
|
||||
return logEntries.map { entry ->
|
||||
MessageLogEntryDateFormatter.format(entry.time) + " " + entry.bank.bankCode + " " + entry.message
|
||||
MessageLogEntryDateFormatter.format(entry.time) + " " + getMessageLogPrefix(entry) + "\r\n" + entry.bank.bankCode + " " + entry.message
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getMessageLogPrefix(entry: MessageLogEntry): String {
|
||||
return "${if (entry.type == MessageLogEntryType.Sent) "Sending" else "Received"} message:" // TODO: translate
|
||||
}
|
||||
|
||||
|
||||
open fun showAddAccountDialog() {
|
||||
router.showAddAccountDialog(this)
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.dankito.banking.fints.webclient.IWebClient
|
|||
import net.dankito.banking.fints.webclient.KtorWebClient
|
||||
import net.dankito.banking.extensions.toMoney
|
||||
import net.dankito.banking.fints.model.BankData
|
||||
import net.dankito.banking.fints.model.MessageLogEntryType
|
||||
import net.dankito.banking.fints.response.client.FinTsClientResponse
|
||||
import net.dankito.banking.ui.model.*
|
||||
import net.dankito.banking.ui.model.MessageLogEntry
|
||||
|
@ -54,7 +55,14 @@ open class fints4kBankingClient(
|
|||
|
||||
|
||||
override val messageLogWithoutSensitiveData: List<MessageLogEntry>
|
||||
get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, it.time, bank) }
|
||||
get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, map(it.type), it.time, bank) }
|
||||
|
||||
protected open fun map(type: MessageLogEntryType): net.dankito.banking.ui.model.MessageLogEntryType {
|
||||
return when (type) {
|
||||
MessageLogEntryType.Sent -> net.dankito.banking.ui.model.MessageLogEntryType.Sent
|
||||
MessageLogEntryType.Received -> net.dankito.banking.ui.model.MessageLogEntryType.Received
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addAccountAsync(callback: (AddAccountResponse) -> Unit) {
|
||||
|
|
Loading…
Reference in New Issue