Skip to content

Commit b95a7d0

Browse files
AlgirdasPundziusmateusz-markowicz
authored andcommitted
Introduce character limit on nps submission field
1 parent 6983070 commit b95a7d0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/main/java/com/protonvpn/android/ui/promooffers/NpsActivity.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private fun RateMeScreen(
146146
var selectedRating by rememberSaveable { mutableStateOf<Int?>(null) }
147147
var additionalDetails by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue()) }
148148
var showAdditionalDetails by rememberSaveable { mutableStateOf(false) }
149+
var inputLimitReached by rememberSaveable { mutableStateOf(false) }
149150
val scrollState = rememberScrollState()
150151
val isScrolled = remember { derivedStateOf { scrollState.value > 0 } }
151152
val topAppBarColor = animateColorAsState(
@@ -219,8 +220,15 @@ private fun RateMeScreen(
219220
ProtonOutlinedTextField(
220221
value = additionalDetails,
221222
onValueChange = {
222-
additionalDetails = it
223+
if (it.text.codePoints().count() <= 250) {
224+
additionalDetails = it
225+
inputLimitReached = false
226+
} else {
227+
inputLimitReached = true
228+
}
223229
},
230+
errorText = stringResource(R.string.nps_submit_error_char_limit),
231+
isError = inputLimitReached,
224232
assistiveText = stringResource(R.string.nps_additional_comment_optional),
225233
textStyle = ProtonTheme.typography.defaultNorm,
226234
backgroundColor = ProtonTheme.colors.backgroundSecondary,

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -1468,5 +1468,6 @@
14681468
<string name="nps_rating_low_values_explain">0 is very unlikely</string>
14691469
<string name="nps_rating_high_values_explain">10 is very likely</string>
14701470
<string name="nps_toast_submit_message">Thanks for sharing. Your feedback helps us improve Proton VPN.</string>
1471+
<string name="nps_submit_error_char_limit">Your answer should be 250 characters or shorter</string>
14711472
<string name="nps_button_submit_title">Share anonymously</string>
14721473
</resources>

0 commit comments

Comments
 (0)