From 02a5ecfb869d7dcd757f667a6073604e19c629c4 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Thu, 5 Jan 2023 20:26:54 -0600 Subject: [wallet] Limit purpose to 100 characters #0007483 --- .../taler/wallet/peer/OutgoingPullIntroComposable.kt | 16 ++++++++++++++-- .../taler/wallet/peer/OutgoingPushIntroComposable.kt | 17 +++++++++++++++-- wallet/src/main/res/values/strings.xml | 1 + 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'wallet/src') diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullIntroComposable.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullIntroComposable.kt index 5faea07..e66d628 100644 --- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullIntroComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullIntroComposable.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -67,11 +68,14 @@ fun OutgoingPullIntroComposable( val exchangeItem = exchangeState.value OutlinedTextField( modifier = Modifier - .padding(16.dp) + .fillMaxWidth() + .padding(top = 16.dp, start = 16.dp, end = 16.dp) .focusRequester(focusRequester), + singleLine = true, value = subject, onValueChange = { input -> - subject = input + if (input.length <= 100) + subject = input }, isError = subject.isBlank(), label = { @@ -86,6 +90,14 @@ fun OutgoingPullIntroComposable( LaunchedEffect(Unit) { focusRequester.requestFocus() } + Text( + modifier = Modifier + .fillMaxWidth() + .padding(top = 5.dp, end = 16.dp), + color = if (subject.isBlank()) colorResource(R.color.red) else Color.Unspecified, + text = stringResource(R.string.char_count, subject.length, 100), + textAlign = TextAlign.End, + ) Text( modifier = Modifier.padding(horizontal = 16.dp), text = stringResource(id = R.string.amount_chosen), diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushIntroComposable.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushIntroComposable.kt index 915d002..6815565 100644 --- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushIntroComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushIntroComposable.kt @@ -38,6 +38,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import net.taler.common.Amount @@ -70,10 +71,14 @@ fun OutgoingPushIntroComposable( var subject by rememberSaveable { mutableStateOf("") } OutlinedTextField( - modifier = Modifier.padding(horizontal = 16.dp), + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + singleLine = true, value = subject, onValueChange = { input -> - subject = input + if (input.length <= 100) + subject = input }, isError = subject.isBlank(), label = { @@ -85,6 +90,14 @@ fun OutgoingPushIntroComposable( ) } ) + Text( + modifier = Modifier + .fillMaxWidth() + .padding(top = 5.dp, end = 16.dp), + color = if (subject.isBlank()) colorResource(R.color.red) else Color.Unspecified, + text = stringResource(R.string.char_count, subject.length, 100), + textAlign = TextAlign.End, + ) Text( modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp), text = stringResource(R.string.send_peer_warning), diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml index eb15021..bedec24 100644 --- a/wallet/src/main/res/values/strings.xml +++ b/wallet/src/main/res/values/strings.xml @@ -56,6 +56,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card Menu or Currency + %1$d/%2$d Operation requires internet access. Please ensure your internet connection works and try again. Error: This Taler URI is not supported. -- cgit v1.2.3