diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/util/IBase64Service.kt b/BankingUiCommon/src/main/java/net/dankito/banking/util/IBase64Service.kt new file mode 100644 index 00000000..1f01c7e8 --- /dev/null +++ b/BankingUiCommon/src/main/java/net/dankito/banking/util/IBase64Service.kt @@ -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 + +} \ No newline at end of file diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/Base64ServiceAndroid.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/Base64ServiceAndroid.kt index 271cbd89..e07f404b 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/Base64ServiceAndroid.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/Base64ServiceAndroid.kt @@ -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 diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/MainWindowPresenter.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/MainWindowPresenter.kt index 1b2f2185..b5333440 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/MainWindowPresenter.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/MainWindowPresenter.kt @@ -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 diff --git a/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/util/UiCommonBase64ServiceWrapper.kt b/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/util/UiCommonBase64ServiceWrapper.kt new file mode 100644 index 00000000..602e355a --- /dev/null +++ b/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/util/UiCommonBase64ServiceWrapper.kt @@ -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) + } + +} \ No newline at end of file