Extracted setupTanView()

This commit is contained in:
dankl 2020-01-02 00:18:51 +01:00 committed by dankito
parent aa88c751dd
commit 29c65354be
1 changed files with 27 additions and 23 deletions

View File

@ -77,29 +77,7 @@ open class EnterTanDialog : DialogFragment() {
protected open fun setupUI(rootView: View) { protected open fun setupUI(rootView: View) {
setupSelectTanProcedureView(rootView) setupSelectTanProcedureView(rootView)
if (OpticalTanProcedures.contains(tanChallenge.tanProcedure.type)) { setupTanView(rootView)
if (account.tanMedia.isNotEmpty()) {
setupSelectTanMediumView(rootView)
}
if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanOptisch) {
val flickerCodeView = rootView.flickerCodeView
flickerCodeView.visibility = View.VISIBLE
flickerCodeView.setCode(FlickercodeDecoder().decodeChallenge(tanChallenge.tanChallenge))
}
else if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanQrCode
|| tanChallenge.tanProcedure.type == TanProcedureType.PhotoTan) {
rootView.tanImageView.visibility = View.VISIBLE
TanImageDecoder().decodeChallenge(tanChallenge.tanChallenge)?.let { tanImage ->
val bitmap = BitmapFactory.decodeByteArray(tanImage.imageBytes, 0, tanImage.imageBytes.size)
rootView.imgTanImageView.setImageBitmap(bitmap)
}
// TODO: what to do if decoding fails? At least a message should get shown to user
}
rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER
}
rootView.txtTanDescriptionToShowToUser.text = tanChallenge.messageToShowToUser rootView.txtTanDescriptionToShowToUser.text = tanChallenge.messageToShowToUser
@ -151,6 +129,32 @@ open class EnterTanDialog : DialogFragment() {
} }
} }
protected open fun setupTanView(rootView: View) {
if (OpticalTanProcedures.contains(tanChallenge.tanProcedure.type)) {
if (account.tanMedia.isNotEmpty()) {
setupSelectTanMediumView(rootView)
}
if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanOptisch) {
val flickerCodeView = rootView.flickerCodeView
flickerCodeView.visibility = View.VISIBLE
flickerCodeView.setCode(FlickercodeDecoder().decodeChallenge(tanChallenge.tanChallenge))
}
else if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanQrCode
|| tanChallenge.tanProcedure.type == TanProcedureType.PhotoTan) {
rootView.tanImageView.visibility = View.VISIBLE
TanImageDecoder().decodeChallenge(tanChallenge.tanChallenge)?.let { tanImage ->
val bitmap = BitmapFactory.decodeByteArray(tanImage.imageBytes, 0, tanImage.imageBytes.size)
rootView.imgTanImageView.setImageBitmap(bitmap)
}
// TODO: what to do if decoding fails? At least a message should get shown to user
}
rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER
}
}
protected open fun handleChangeTanMediumResponse(newUsedTanMedium: TanMedium, response: FinTsClientResponse) { protected open fun handleChangeTanMediumResponse(newUsedTanMedium: TanMedium, response: FinTsClientResponse) {
activity?.let { activity -> activity?.let { activity ->