Added IBase64Service to UiCommon to wrap away fints4java IBase64Service

This commit is contained in:
dankl 2020-01-08 17:52:12 +01:00 committed by dankito
parent 15d282a175
commit 6579dcfe3a
4 changed files with 33 additions and 4 deletions

View File

@ -0,0 +1,12 @@
package net.dankito.banking.util
import java.nio.charset.Charset
interface IBase64Service {
fun encode(text: String, charset: Charset): String
fun decode(base64: String, charset: Charset): String
}

View File

@ -1,7 +1,7 @@
package net.dankito.banking.fints4java.android
import android.util.Base64
import net.dankito.fints.util.IBase64Service
import net.dankito.banking.util.IBase64Service
import java.nio.charset.Charset

View File

@ -1,7 +1,7 @@
package net.dankito.banking.fints4java.android.ui
import net.dankito.banking.ui.IBankingClient
import net.dankito.banking.ui.BankingClientCallback
import net.dankito.banking.ui.IBankingClient
import net.dankito.banking.ui.model.Account
import net.dankito.banking.ui.model.AccountTransaction
import net.dankito.banking.ui.model.BankAccount
@ -9,9 +9,10 @@ import net.dankito.banking.ui.model.parameters.TransferMoneyData
import net.dankito.banking.ui.model.responses.AddAccountResponse
import net.dankito.banking.ui.model.responses.BankingClientResponse
import net.dankito.banking.ui.model.responses.GetTransactionsResponse
import net.dankito.banking.util.IBase64Service
import net.dankito.banking.util.UiCommonBase64ServiceWrapper
import net.dankito.fints.banks.BankFinder
import net.dankito.fints.model.BankInfo
import net.dankito.fints.util.IBase64Service
import net.dankito.utils.IThreadPool
import net.dankito.utils.ThreadPool
import net.dankito.utils.web.client.OkHttpWebClient
@ -44,7 +45,7 @@ open class MainWindowPresenter(protected val base64Service: IBase64Service,
// TODO: move BankInfo out of fints4javaLib
open fun addAccountAsync(bankInfo: BankInfo, customerId: String, pin: String, callback: (AddAccountResponse) -> Unit) {
val newClient = net.dankito.banking.fints4javaBankingClient(bankInfo, customerId, pin, OkHttpWebClient(), base64Service, threadPool, this.callback)
val newClient = net.dankito.banking.fints4javaBankingClient(bankInfo, customerId, pin, OkHttpWebClient(), UiCommonBase64ServiceWrapper(base64Service), threadPool, this.callback)
newClient.addAccountAsync { response ->
val account = response.account

View File

@ -0,0 +1,16 @@
package net.dankito.banking.util
import java.nio.charset.Charset
open class UiCommonBase64ServiceWrapper(protected val base64Service: IBase64Service) : net.dankito.fints.util.IBase64Service {
override fun encode(text: String, charset: Charset): String {
return base64Service.encode(text, charset)
}
override fun decode(base64: String, charset: Charset): String {
return base64Service.decode(base64, charset)
}
}