Implemented showing decoding error

This commit is contained in:
dankito 2024-09-26 13:54:27 +02:00
parent b805a070eb
commit 14cb9c789c
4 changed files with 73 additions and 36 deletions

View File

@ -34,6 +34,19 @@ fun EnterTanDialogPreview_TanImage() {
EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { } EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { }
} }
@Preview
@Composable
fun EnterTanDialogPreview_TanImage_DecodingError() {
val tanMethod = TanMethod("photoTAN-Verfahren", TanMethodType.photoTan, "902", 6, AllowedTanFormat.Numeric)
val tanImage = TanImage("image/png", "", "Ja Hoppla, da ist dann wohl etwas schief gelaufen. Hinterfragen Sie Ihre eigene Existenz woran das liegen könnte!")
val bank = BankViewInfo("10010010", "Ihr krasser Login Name", "Phantasie Bank", BankingGroup.Comdirect)
val tanChallenge = TanChallenge(TanChallengeType.Image, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethod.identifier, listOf(tanMethod), null, emptyList(), tanImage, null, bank)
EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { }
}
@Preview @Preview
@Composable @Composable
fun EnterTanDialogPreview_WithMultipleTanMedia() { // shows that dialog is really long if a TAN Image, select box for TAN Media, bank name, bank account, ... gets displayed fun EnterTanDialogPreview_WithMultipleTanMedia() { // shows that dialog is really long if a TAN Image, select box for TAN Media, bank name, bank account, ... gets displayed
@ -67,3 +80,13 @@ fun EnterTanDialogPreview_Flickercode() {
EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { } EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { }
} }
@Preview
@Composable
fun EnterTanDialogPreview_Flickercode_DecodingError() {
val tanMethods = listOf(TanMethod("chipTAN Flickercode", TanMethodType.ChipTanFlickercode, "902"))
val bank = BankViewInfo("12345678", "SupiDupiNutzer", "Abzockbank", BankingGroup.Postbank)
val tanChallenge = TanChallenge(TanChallengeType.Flickercode, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethods.first().identifier, tanMethods, bank = bank, flickerCode = FlickerCode("100880077104", "", decodingError = "Ja Hoppla, da ist dann wohl etwas schief gelaufen."))
EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { }
}

View File

@ -14,6 +14,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import net.codinux.banking.client.model.tan.FlickerCode import net.codinux.banking.client.model.tan.FlickerCode
import net.codinux.banking.ui.model.Config.NewLine
import net.codinux.banking.ui.service.tan.Bit import net.codinux.banking.ui.service.tan.Bit
import net.codinux.banking.ui.service.tan.FlickerCodeAnimator import net.codinux.banking.ui.service.tan.FlickerCodeAnimator
import net.codinux.banking.ui.service.tan.Step import net.codinux.banking.ui.service.tan.Step
@ -99,6 +100,11 @@ fun ChipTanFlickerCodeView(flickerCode: FlickerCode, textColor: Color = Color.Bl
Column(Modifier.fillMaxWidth()) { Column(Modifier.fillMaxWidth()) {
flickerCode.decodingError?.let {
Text("Hier sollte eigentlich ein FlickerCode stehen, dieser konnte jedoch nicht dekodiert werden:${NewLine}${flickerCode.decodingError}", color = MaterialTheme.colors.error, modifier = Modifier.padding(vertical = 8.dp))
}
flickerCode.parsedDataSet?.let {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) { Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
ImageSizeControls(true, true, textColor, { decreaseSize() }, { increaseSize() }) ImageSizeControls(true, true, textColor, { decreaseSize() }, { increaseSize() })
@ -145,6 +151,7 @@ fun ChipTanFlickerCodeView(flickerCode: FlickerCode, textColor: Color = Color.Bl
} }
} }
} }
}
DisposableEffect(animator) { DisposableEffect(animator) {

View File

@ -24,6 +24,7 @@ import net.codinux.banking.ui.config.Colors
import net.codinux.banking.ui.forms.CaptionText import net.codinux.banking.ui.forms.CaptionText
import net.codinux.banking.ui.forms.OutlinedTextField import net.codinux.banking.ui.forms.OutlinedTextField
import net.codinux.banking.ui.forms.Select import net.codinux.banking.ui.forms.Select
import net.codinux.banking.ui.model.Config.NewLine
import net.codinux.banking.ui.model.TanChallengeReceived import net.codinux.banking.ui.model.TanChallengeReceived
import net.codinux.banking.ui.model.error.ErroneousAction import net.codinux.banking.ui.model.error.ErroneousAction
import net.codinux.banking.ui.service.createImageBitmap import net.codinux.banking.ui.service.createImageBitmap
@ -142,6 +143,10 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
} }
challenge.tanImage?.let { tanImage -> challenge.tanImage?.let { tanImage ->
tanImage.decodingError?.let {
Text("Hier sollte eigentlich das TAN Bild angezeigt werden, dieses konnte jedoch nicht dekodiert werden:$NewLine${tanImage.decodingError}", color = MaterialTheme.colors.error, modifier = Modifier.padding(vertical = 8.dp))
}
if (tanImage.decodingSuccessful) { if (tanImage.decodingSuccessful) {
val imageBytes = Base64.decode(tanImage.imageBytesBase64) val imageBytes = Base64.decode(tanImage.imageBytesBase64)

View File

@ -29,12 +29,14 @@ class FlickerCodeAnimator {
fun animateFlickerCode(flickerCode: FlickerCode, showStep: (Step) -> Unit) { // TODO: find better coroutine scope fun animateFlickerCode(flickerCode: FlickerCode, showStep: (Step) -> Unit) { // TODO: find better coroutine scope
stop() // stop may still running previous animation stop() // stop may still running previous animation
flickerCode.parsedDataSet?.let { parsedDataSet ->
animationJob = GlobalScope.launch(Dispatchers.Default) { animationJob = GlobalScope.launch(Dispatchers.Default) {
val steps = FlickerCodeStepsCalculator().calculateSteps(flickerCode.parsedDataSet) val steps = FlickerCodeStepsCalculator().calculateSteps(parsedDataSet)
calculateAnimation(steps, showStep) calculateAnimation(steps, showStep)
} }
} }
}
private suspend fun calculateAnimation(steps: List<Step>, showStep: (Step) -> Unit) { private suspend fun calculateAnimation(steps: List<Step>, showStep: (Step) -> Unit) {
var currentStepIndex = 0 var currentStepIndex = 0