diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/MainActivity.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/MainActivity.kt index fb6ddcf0..34e9984d 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/MainActivity.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/MainActivity.kt @@ -11,8 +11,6 @@ import com.github.clans.fab.FloatingActionMenu import kotlinx.android.synthetic.main.action_view_account_menu_item.view.* import net.dankito.banking.fints4java.android.ui.MainWindowPresenter import net.dankito.banking.fints4java.android.ui.dialogs.AddAccountDialog -import net.dankito.banking.fints4java.android.ui.dialogs.EnterAtcDialog -import net.dankito.banking.fints4java.android.ui.dialogs.EnterTanDialog import net.dankito.banking.fints4java.android.ui.views.MainActivityFloatingActionMenuButton import net.dankito.banking.fints4java.android.util.Base64ServiceAndroid import net.dankito.banking.fints4javaBankingClientCreator @@ -33,20 +31,7 @@ class MainActivity : AppCompatActivity() { private lateinit var floatingActionMenuButton: MainActivityFloatingActionMenuButton - val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), - Base64ServiceAndroid(), object : BankingClientCallback { - - override fun enterTan(account: Account, tanChallenge: TanChallenge): EnterTanResult { - return getTanFromUserOffUiThread(account, tanChallenge) - } - - override fun enterTanGeneratorAtc(tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult { - return getAtcFromUserOffUiThread(tanMedium) - } - - }) - - private val router = RouterAndroid(this, presenter) + val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), Base64ServiceAndroid(), RouterAndroid(this)) override fun onCreate(savedInstanceState: Bundle?) { 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 692419da..481e1f53 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 @@ -3,6 +3,7 @@ package net.dankito.banking.fints4java.android.ui import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.IBankingClientCreator +import net.dankito.banking.ui.IRouter import net.dankito.banking.ui.model.Account import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount @@ -10,6 +11,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.ui.model.tan.EnterTanGeneratorAtcResult +import net.dankito.banking.ui.model.tan.EnterTanResult +import net.dankito.banking.ui.model.tan.TanChallenge +import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium import net.dankito.banking.util.IBase64Service import net.dankito.fints.banks.BankFinder import net.dankito.fints.model.BankInfo @@ -24,7 +29,7 @@ import kotlin.collections.ArrayList open class MainWindowPresenter( protected val bankingClientCreator: IBankingClientCreator, protected val base64Service: IBase64Service, - protected val callback: BankingClientCallback + protected val router: IRouter ) { companion object { @@ -44,6 +49,19 @@ open class MainWindowPresenter( protected val retrievedAccountTransactionsResponseListeners = mutableListOf<(BankAccount, GetTransactionsResponse) -> Unit>() + protected val callback: BankingClientCallback = object : BankingClientCallback { + + override fun enterTan(account: Account, tanChallenge: TanChallenge): EnterTanResult { + return router.getTanFromUserOffUiThread(account, tanChallenge) + } + + override fun enterTanGeneratorAtc(tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult { + return router.getAtcFromUserOffUiThread(tanMedium) + } + + } + + // TODO: move BankInfo out of fints4javaLib open fun addAccountAsync(bankInfo: BankInfo, customerId: String, pin: String, callback: (AddAccountResponse) -> Unit) {