diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt index 6c169ee3..2e5038d8 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt @@ -122,31 +122,33 @@ open class EnterTanDialog : DialogFragment() { } protected open fun setupSelectTanMediumView(rootView: View) { - rootView.lytTanMedium.visibility = View.VISIBLE + val tanMediaForTanProcedure = presenter.getTanMediaForTanProcedure(customer, tanChallenge.tanProcedure) - tanMediumAdapter.setItems(customer.tanMediaSorted) + if (tanMediaForTanProcedure.size > 1) { + rootView.lytTanMedium.visibility = View.VISIBLE - rootView.spnTanMedium.adapter = tanMediumAdapter - rootView.spnTanMedium.onItemSelectedListener = ListItemSelectedListener(tanMediumAdapter) { selectedTanMedium -> - // TODO: implement logic to change a mobile phone as TAN medium - if (selectedTanMedium.status != TanMediumStatus.Used) { - (selectedTanMedium as? TanGeneratorTanMedium)?.let { tanGeneratorTanMedium -> - tanEnteredCallback(EnterTanResult.userAsksToChangeTanMedium(tanGeneratorTanMedium) { response -> - handleChangeTanMediumResponse(selectedTanMedium, response) - }) - // TODO: find a way to update account.tanMedia afterwards + tanMediumAdapter.setItems(customer.tanMediaSorted) + + rootView.spnTanMedium.adapter = tanMediumAdapter + rootView.spnTanMedium.onItemSelectedListener = ListItemSelectedListener(tanMediumAdapter) { selectedTanMedium -> + // TODO: implement logic to change a mobile phone as TAN medium + if (selectedTanMedium.status != TanMediumStatus.Used) { + (selectedTanMedium as? TanGeneratorTanMedium)?.let { tanGeneratorTanMedium -> + tanEnteredCallback(EnterTanResult.userAsksToChangeTanMedium(tanGeneratorTanMedium) { response -> + handleChangeTanMediumResponse(selectedTanMedium, response) + }) + // TODO: find a way to update account.tanMedia afterwards + } + + // TODO: ensure that only TanGeneratorTanMedium instances get added to spinner? } - - // TODO: ensure that only TanGeneratorTanMedium instances get added to spinner? } } } protected open fun setupTanView(rootView: View) { if (OpticalTanProcedures.contains(tanChallenge.tanProcedure.type)) { - if (customer.tanMedia.isNotEmpty()) { - setupSelectTanMediumView(rootView) - } + setupSelectTanMediumView(rootView) if (tanChallenge is FlickerCodeTanChallenge) { setupFlickerCodeTanView(rootView) diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index 6893d2d7..e256ad08 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -10,10 +10,6 @@ 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.bankfinder.IBankFinder import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.IRemitteeSearcher @@ -23,6 +19,7 @@ import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPd import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResultType import net.dankito.banking.ui.model.parameters.GetTransactionsParameter import net.dankito.banking.ui.model.settings.AppSettings +import net.dankito.banking.ui.model.tan.* import net.dankito.banking.util.* import net.dankito.banking.util.extraction.IInvoiceDataExtractor import net.dankito.banking.util.extraction.ITextExtractorRegistry @@ -48,6 +45,9 @@ open class BankingPresenter( ) { companion object { + val ChipTanTanProcedures = listOf(TanProcedureType.ChipTanManuell, TanProcedureType.ChipTanFlickercode, TanProcedureType.ChipTanUsb, + TanProcedureType.ChipTanQrCode, TanProcedureType.ChipTanPhotoTanMatrixCode) + protected const val OneDayMillis = 24 * 60 * 60 * 1000 protected val MessageLogEntryDateFormatter = DateFormatter("yyyy.MM.dd HH:mm:ss.SSS") @@ -677,6 +677,18 @@ open class BankingPresenter( } + open fun getTanMediaForTanProcedure(bank: Customer, tanProcedure: TanProcedure): List { + if (ChipTanTanProcedures.contains(tanProcedure.type)) { + return bank.tanMediaSorted.filterIsInstance() + } + else if (tanProcedure.type == TanProcedureType.SmsTan) { + return bank.tanMediaSorted.filterIsInstance() + } + + return listOf() + } + + var appSettings: AppSettings = AppSettings() protected set