Added informationForUser, but not exposing it to user as it may causes overflow exception of used QR code library

This commit is contained in:
dankito 2024-10-03 21:33:58 +02:00
parent 1520d19625
commit e3f9c78b95
2 changed files with 15 additions and 4 deletions

View File

@ -54,11 +54,13 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
var reference by remember { mutableStateOf("") }
var informationForUser by remember { mutableStateOf("") }
val epcQrCodeBytes by remember(receiverName, iban, bic, amount, reference) {
val epcQrCodeBytes by remember(receiverName, iban, bic, amount, reference, informationForUser) {
derivedStateOf {
if (receiverName.isNotBlank() && iban.isNotBlank()) {
epcQrCodeService.generateEpcQrCode(receiverName, iban, bic.takeUnless { it.isBlank() }, amount.takeUnless { it.isBlank() }, reference.takeUnless { it.isBlank() })
epcQrCodeService.generateEpcQrCode(receiverName, iban, bic.takeUnless { it.isBlank() }, amount.takeUnless { it.isBlank() }, reference.takeUnless { it.isBlank() }, informationForUser.takeUnless { it.isBlank() })
} else {
null
}
@ -152,6 +154,15 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
keyboardOptions = KeyboardOptions.ImeNext
)
// not exposing it to user as it's a) not displayed by most apps and b) may causes overflow of used QR code library
// OutlinedTextField(
// label = { Text("Information für den Nutzer (optional)") },
// value = informationForUser,
// onValueChange = { informationForUser = it },
// modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
// keyboardOptions = KeyboardOptions.ImeNext
// )
}
}
}

View File

@ -6,10 +6,10 @@ import net.codinux.banking.epcqrcode.EpcQrCodeGenerator
class EpcQrCodeService {
fun generateEpcQrCode(receiverName: String, iban: String, bic: String?, amount: String?, reference: String?, heightAndWidth: Int = EpcQrCode.DefaultHeightAndWidth): ByteArray {
fun generateEpcQrCode(receiverName: String, iban: String, bic: String?, amount: String?, reference: String?, informationForUser: String? = null, heightAndWidth: Int = EpcQrCode.DefaultHeightAndWidth): ByteArray {
val generator = EpcQrCodeGenerator()
return generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, qrCodeHeightAndWidth = heightAndWidth)).bytes
return generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, informationForUser, qrCodeHeightAndWidth = heightAndWidth)).bytes
}
}