From 117bb2e5e0501b5e83c98383f75f91a0e2a3028d Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 23 Jul 2020 12:39:46 +0200 Subject: [PATCH] Extracted setupFlickerCodeTanView() and setupImageTanView() --- .../ui/android/dialogs/EnterTanDialog.kt | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) 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 5fdd4e35..a83c1aea 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 @@ -145,27 +145,10 @@ open class EnterTanDialog : DialogFragment() { } if (tanChallenge is FlickerCodeTanChallenge) { - val flickerCodeView = rootView.flickerCodeView - flickerCodeView.visibility = View.VISIBLE - - val flickerCode = (tanChallenge as FlickerCodeTanChallenge).flickerCode - if (flickerCode.decodingSuccessful) { - flickerCodeView.setCode(flickerCode, presenter.appSettings.flickerCodeSettings) - } - else { - showDecodingTanChallengeFailedErrorDelayed(flickerCode.decodingError) - } + setupFlickerCodeTanView(rootView) } else if (tanChallenge is ImageTanChallenge) { - rootView.tanImageView.visibility = View.VISIBLE - - val decodedImage = (tanChallenge as ImageTanChallenge).image - if (decodedImage.decodingSuccessful) { - rootView.tanImageView.setImage(tanChallenge as ImageTanChallenge, if (isQrTan(tanChallenge)) presenter.appSettings.qrCodeSettings else presenter.appSettings.photoTanSettings) - } - else { - showDecodingTanChallengeFailedErrorDelayed(decodedImage.decodingError) - } + setupImageTanView(rootView) } rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER // TODO: is this always true that TAN is a number? @@ -180,6 +163,31 @@ open class EnterTanDialog : DialogFragment() { } } + protected open fun setupFlickerCodeTanView(rootView: View) { + val flickerCodeView = rootView.flickerCodeView + flickerCodeView.visibility = View.VISIBLE + + val flickerCode = (tanChallenge as FlickerCodeTanChallenge).flickerCode + if (flickerCode.decodingSuccessful) { + flickerCodeView.setCode(flickerCode, presenter.appSettings.flickerCodeSettings) + } + else { + showDecodingTanChallengeFailedErrorDelayed(flickerCode.decodingError) + } + } + + protected open fun setupImageTanView(rootView: View) { + rootView.tanImageView.visibility = View.VISIBLE + + val decodedImage = (tanChallenge as ImageTanChallenge).image + if (decodedImage.decodingSuccessful) { + rootView.tanImageView.setImage(tanChallenge as ImageTanChallenge, if (isQrTan(tanChallenge)) presenter.appSettings.qrCodeSettings else presenter.appSettings.photoTanSettings) + } + else { + showDecodingTanChallengeFailedErrorDelayed(decodedImage.decodingError) + } + } + /** * This method gets called right on start up before dialog is shown -> Alert would get displayed before dialog and