taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit 8c9db6054c84782286b8d6b2ab0a202b4f14947c
parent 2b289b130bf782c63de6d04546080f941053cac4
Author: Iván Ávalos <avalos@disroot.org>
Date:   Fri,  5 Dec 2025 15:02:47 +0100

[wallet] improvements to QR rendering

Diffstat:
Mwallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt | 29+++++++++++++++++++----------
Mwallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt | 27+++++++++++++--------------
2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt b/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt @@ -23,6 +23,8 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -37,7 +39,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.produceState -import androidx.compose.ui.Alignment.Companion.CenterHorizontally +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.platform.LocalConfiguration @@ -68,16 +70,23 @@ fun ColumnScope.QrCodeUriComposable( val qrState = produceState(qrPlaceHolder) { value = QrCodeManager.makeQrCode(talerUri, qrCodeSize.value.toInt()).asImageBitmap() } - qrState.value?.let { qrCode -> - Image( - modifier = Modifier - .size(qrCodeSize) - .align(CenterHorizontally) - .padding(bottom = if (showContents) 8.dp else 0.dp), - bitmap = qrCode, - contentDescription = stringResource(id = R.string.button_scan_qr_code), - ) + + Box( + Modifier + .fillMaxWidth() + .aspectRatio(1f) + .padding(bottom = if (showContents) 8.dp else 0.dp), + contentAlignment = Alignment.Center, + ) { + qrState.value?.let { qrCode -> + Image( + modifier = Modifier.fillMaxSize(), + bitmap = qrCode, + contentDescription = stringResource(id = R.string.button_scan_qr_code), + ) + } } + if (inBetween != null) inBetween() val scrollState = rememberScrollState() if (showContents) { diff --git a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt @@ -18,13 +18,15 @@ package net.taler.wallet.peer import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment.Companion.CenterHorizontally import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -35,12 +37,9 @@ import net.taler.common.Amount import net.taler.common.CurrencySpecification import net.taler.common.Timestamp import net.taler.wallet.R -import net.taler.wallet.backend.TalerErrorCode.EXCHANGE_GENERIC_KYC_REQUIRED -import net.taler.wallet.backend.TalerErrorInfo import net.taler.wallet.balances.ScopeInfo import net.taler.wallet.compose.QrCodeUriComposable import net.taler.wallet.compose.TalerSurface -import net.taler.wallet.compose.getQrCodeSize import net.taler.wallet.transactions.ActionListener import net.taler.wallet.transactions.AmountType import net.taler.wallet.transactions.PeerInfoShort @@ -106,6 +105,9 @@ fun ColumnScope.PeerQrCode( talerUri: String?, instructionResId: Int, ) { + remember(state) { + 10.dp + } if (state == TransactionState(Pending) && state.minor != MergeKycRequired) { Text( modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp), @@ -127,15 +129,13 @@ fun ColumnScope.PeerQrCode( text = stringResource(id = R.string.receive_peer_invoice_uri), ) } - } else { - val qrCodeSize = getQrCodeSize() - CircularProgressIndicator( - modifier = Modifier - .padding(32.dp) - .size(qrCodeSize) - .align(CenterHorizontally), - ) - } + } else CircularProgressIndicator( + modifier = Modifier + .padding(45.dp) + .fillMaxWidth() + .aspectRatio(1f) + .align(CenterHorizontally), + ) } } @@ -155,7 +155,6 @@ fun TransactionPeerPushDebitPreview(loading: Boolean = false) { summary = "test invoice", ), talerUri = "https://exchange.example.org/peer/pull/credit", - error = TalerErrorInfo(code = EXCHANGE_GENERIC_KYC_REQUIRED), scopes = listOf(ScopeInfo.Exchange( currency = "TESTKUDOS", url = "exchange.test.taler.net",