Skip to content

Commit ea99e33

Browse files
authored
Merge pull request #284 from open-eid/MOPPAND-1607
Change blocked PUK code message
2 parents 1bc3341 + f7fac0a commit ea99e33

File tree

17 files changed

+140
-48
lines changed

17 files changed

+140
-48
lines changed

app/src/main/kotlin/ee/ria/DigiDoc/fragment/screen/AccessibilityScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fun AccessibilityScreen(
163163
text2 = ".",
164164
linkText = stringResource(R.string.main_accessibility_link_tag),
165165
linkUrl = stringResource(R.string.main_accessibility_link_url),
166-
showLinkOnOneLine = true,
166+
newLineBeforeText2 = false,
167167
textStyle =
168168
TextStyle(
169169
color = MaterialTheme.colorScheme.onBackground,

app/src/main/kotlin/ee/ria/DigiDoc/fragment/screen/DiagnosticsScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ fun DiagnosticsScreen(
668668
text2 = R.string.main_diagnostics_restart_message_restart_now,
669669
linkText = R.string.main_diagnostics_restart_message_read_more,
670670
linkUrl = R.string.main_diagnostics_restart_message_href,
671+
newLineBeforeLink = true,
672+
newLineBeforeText2 = true,
671673
)
672674

673675
CancelAndOkButtonRow(

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/myeid/MyEidScreen.kt

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ import androidx.compose.ui.semantics.contentDescription
6161
import androidx.compose.ui.semantics.role
6262
import androidx.compose.ui.semantics.semantics
6363
import androidx.compose.ui.semantics.testTagsAsResourceId
64+
import androidx.compose.ui.text.TextStyle
65+
import androidx.compose.ui.text.style.TextAlign
66+
import androidx.compose.ui.unit.TextUnit
67+
import androidx.compose.ui.unit.TextUnitType
6468
import androidx.lifecycle.asFlow
6569
import androidx.navigation.NavHostController
6670
import ee.ria.DigiDoc.R
@@ -72,9 +76,11 @@ import ee.ria.DigiDoc.smartcardreader.SmartCardReaderStatus
7276
import ee.ria.DigiDoc.ui.component.menu.SettingsMenuBottomSheet
7377
import ee.ria.DigiDoc.ui.component.myeid.mydata.MyEidMyDataView
7478
import ee.ria.DigiDoc.ui.component.myeid.pinandcertificate.MyEidPinAndCertificateView
79+
import ee.ria.DigiDoc.ui.component.shared.HrefDynamicText
7580
import ee.ria.DigiDoc.ui.component.shared.TabView
7681
import ee.ria.DigiDoc.ui.component.shared.TopBar
7782
import ee.ria.DigiDoc.ui.component.shared.dialog.PinGuideDialog
83+
import ee.ria.DigiDoc.ui.theme.Dimensions.LINE_HEIGHT
7884
import ee.ria.DigiDoc.ui.theme.Dimensions.SPadding
7985
import ee.ria.DigiDoc.utils.Route
8086
import ee.ria.DigiDoc.utils.snackbar.SnackBarManager
@@ -112,7 +118,9 @@ fun MyEidScreen(
112118
val isPukBlocked = idCardData?.pukRetryCount == 0
113119
val isPin2Activated = idCardData?.pin2CodeChanged == true
114120

115-
val alphaForBlockedState = if (!isPukBlocked) 1f else 0.7f
121+
val alphaForPin1BlockedState = getAlphaForBlockedState(isPin1Blocked && isPukBlocked)
122+
val alphaForPin2BlockedState = getAlphaForBlockedState(isPin2Blocked && isPukBlocked)
123+
val alphaForPukBlockedState = getAlphaForBlockedState(isPukBlocked)
116124

117125
val selectedMyEidTabIndex = rememberSaveable { mutableIntStateOf(0) }
118126

@@ -136,6 +144,8 @@ fun MyEidScreen(
136144
var changePukContentDescription =
137145
"$changePukText. $changePukSubtitleText. $buttonName"
138146
.lowercase()
147+
var pukBlockedText = stringResource(R.string.myeid_puk_blocked)
148+
var pukBlockedUrl = stringResource(R.string.myeid_puk_blocked_url)
139149
if (idCardData?.personalData?.cardType() == CardType.THALES) {
140150
pukChangeEnabled = false
141151
changePukText =
@@ -157,6 +167,8 @@ fun MyEidScreen(
157167
"$changePukText. $changePukSubtitleText" +
158168
". $additionalInfo. $changePukLinkUrl. $buttonName"
159169
).lowercase()
170+
pukBlockedText = stringResource(R.string.myeid_thales_puk_blocked)
171+
pukBlockedUrl = stringResource(R.string.myeid_thales_puk_blocked_url)
160172
}
161173

162174
val pin1Guidelines =
@@ -355,7 +367,7 @@ fun MyEidScreen(
355367
MyEidPinAndCertificateView(
356368
modifier =
357369
modifier
358-
.alpha(alphaForBlockedState),
370+
.alpha(alphaForPin1BlockedState),
359371
title = stringResource(R.string.myeid_authentication_certificate_title),
360372
subtitle =
361373
stringResource(
@@ -391,7 +403,7 @@ fun MyEidScreen(
391403
},
392404
)
393405

394-
if (isPin1Blocked) {
406+
if (isPin1Blocked && !isPukBlocked) {
395407
Text(
396408
modifier =
397409
modifier
@@ -406,6 +418,21 @@ fun MyEidScreen(
406418
color = MaterialTheme.colorScheme.error,
407419
style = MaterialTheme.typography.bodySmall,
408420
)
421+
} else if (isPin1Blocked) {
422+
Text(
423+
modifier =
424+
modifier
425+
.fillMaxWidth()
426+
.focusable(true)
427+
.testTag("myEidBlockedPin1DescriptionText"),
428+
text =
429+
stringResource(
430+
R.string.myeid_pin_blocked,
431+
CodeType.PIN1,
432+
),
433+
color = MaterialTheme.colorScheme.error,
434+
style = MaterialTheme.typography.bodySmall,
435+
)
409436
}
410437
}
411438
}
@@ -421,7 +448,7 @@ fun MyEidScreen(
421448
MyEidPinAndCertificateView(
422449
modifier =
423450
modifier
424-
.alpha(alphaForBlockedState),
451+
.alpha(alphaForPin2BlockedState),
425452
title = stringResource(R.string.myeid_signing_certificate_title),
426453
subtitle =
427454
stringResource(
@@ -474,7 +501,7 @@ fun MyEidScreen(
474501
)
475502
}
476503

477-
if (isPin2Blocked) {
504+
if (isPin2Blocked && !isPukBlocked) {
478505
Text(
479506
modifier =
480507
modifier
@@ -489,6 +516,21 @@ fun MyEidScreen(
489516
color = MaterialTheme.colorScheme.error,
490517
style = MaterialTheme.typography.bodySmall,
491518
)
519+
} else if (isPin2Blocked) {
520+
Text(
521+
modifier =
522+
modifier
523+
.fillMaxWidth()
524+
.focusable(true)
525+
.testTag("myEidBlockedPin2DescriptionText"),
526+
text =
527+
stringResource(
528+
R.string.myeid_pin_blocked,
529+
CodeType.PIN2,
530+
),
531+
color = MaterialTheme.colorScheme.error,
532+
style = MaterialTheme.typography.bodySmall,
533+
)
492534
}
493535
}
494536
}
@@ -523,7 +565,7 @@ fun MyEidScreen(
523565
MyEidPinAndCertificateView(
524566
modifier =
525567
modifier
526-
.alpha(alphaForBlockedState),
568+
.alpha(alphaForPukBlockedState),
527569
title = changePukText,
528570
isPinBlocked = isPukBlocked,
529571
isPukBlocked = isPukBlocked,
@@ -541,15 +583,24 @@ fun MyEidScreen(
541583
verticalAlignment = Alignment.CenterVertically,
542584
) {
543585
if (isPukBlocked) {
544-
Text(
586+
HrefDynamicText(
545587
modifier =
546588
modifier
547589
.fillMaxWidth()
548590
.focusable(true)
549591
.testTag("myEidBlockedPukDescriptionText"),
550-
text = stringResource(R.string.myeid_puk_blocked),
551-
color = MaterialTheme.colorScheme.error,
552-
style = MaterialTheme.typography.bodySmall,
592+
text1 = pukBlockedText,
593+
text2 = "",
594+
linkText = stringResource(R.string.additional_information),
595+
linkUrl = pukBlockedUrl,
596+
newLineBeforeLink = true,
597+
textStyle =
598+
TextStyle(
599+
color = MaterialTheme.colorScheme.error,
600+
fontSize = MaterialTheme.typography.bodySmall.fontSize,
601+
textAlign = TextAlign.Start,
602+
lineHeight = TextUnit(LINE_HEIGHT, TextUnitType.Sp),
603+
),
553604
)
554605
}
555606
}
@@ -618,3 +669,5 @@ fun MyEidScreen(
618669
onResult = handlePinDialogResult,
619670
)
620671
}
672+
673+
fun getAlphaForBlockedState(isBlocked: Boolean) = if (!isBlocked) 1f else 0.7f

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/myeid/pinandcertificate/MyEidPinAndCertificateView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fun MyEidPinAndCertificateView(
152152
text2 = "",
153153
linkText = linkText,
154154
linkUrl = linkUrl,
155-
showLinkOnOneLine = true,
155+
newLineBeforeLink = true,
156156
textStyle =
157157
TextStyle(
158158
color = MaterialTheme.colorScheme.onSurface,
@@ -214,7 +214,7 @@ fun MyEidPinAndCertificateView(
214214
Spacer(modifier = modifier.size(XSPadding))
215215

216216
Button(
217-
enabled = !isPinBlocked && !isPukBlocked,
217+
enabled = !isPinBlocked,
218218
onClick = onChangePinClick ?: {},
219219
modifier = modifier.align(Alignment.CenterVertically),
220220
colors =

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/shared/HrefDynamicText.kt

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ fun HrefDynamicText(
5757
text2: String?,
5858
linkText: String,
5959
linkUrl: String,
60-
showLinkOnOneLine: Boolean,
60+
newLineBeforeLink: Boolean = false,
61+
newLineBeforeText2: Boolean = false,
6162
textStyle: TextStyle =
6263
TextStyle(
6364
textAlign = TextAlign.Start,
@@ -66,7 +67,15 @@ fun HrefDynamicText(
6667
val uriHandler = LocalUriHandler.current
6768
val linkColor = MaterialTheme.colorScheme.onSecondaryContainer
6869
val annotatedStringWithLinks =
69-
createAnnotatedStringWithLinks(text1, text2, linkText, linkUrl, linkColor, showLinkOnOneLine)
70+
createAnnotatedStringWithLinks(
71+
text1,
72+
text2,
73+
linkText,
74+
linkUrl,
75+
linkColor,
76+
newLineBeforeLink,
77+
newLineBeforeText2,
78+
)
7079

7180
val onClick: (Int) -> Unit = { offset ->
7281
annotatedStringWithLinks
@@ -123,26 +132,35 @@ fun createAnnotatedStringWithLinks(
123132
linkText: String,
124133
linkUrl: String,
125134
linkColor: Color,
126-
showLinkOnOneLine: Boolean,
135+
newLineBeforeLink: Boolean = false,
136+
newLineBeforeText2: Boolean = false,
127137
): AnnotatedString =
128138
buildAnnotatedString {
129-
append("$text1 ")
139+
text1?.let(::append)
140+
141+
if (newLineBeforeLink) {
142+
appendLine()
143+
} else if (!text1.isNullOrBlank()) {
144+
append(" ")
145+
}
130146

131147
pushStringAnnotation(tag = "URL", annotation = linkUrl)
132148
withStyle(
133-
style =
134-
SpanStyle(
135-
color = linkColor,
136-
textDecoration = Underline,
137-
),
149+
SpanStyle(
150+
color = linkColor,
151+
textDecoration = Underline,
152+
),
138153
) {
139154
append(linkText)
140155
}
141156
pop()
142157

143-
if (showLinkOnOneLine) {
144-
append("$text2")
145-
} else {
146-
append("\n$text2")
158+
text2?.let {
159+
if (newLineBeforeText2) {
160+
appendLine()
161+
} else {
162+
append(" ")
163+
}
164+
append(it)
147165
}
148166
}

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/shared/HrefMessageDialog.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fun HrefMessageDialog(
4545
@StringRes text2: Int?,
4646
@StringRes linkText: Int,
4747
@StringRes linkUrl: Int,
48-
showLinkOnOneLine: Boolean = false,
48+
newLineBeforeLink: Boolean = false,
49+
newLineBeforeText2: Boolean = false,
4950
) {
5051
Column(
5152
modifier = modifier.padding(SPadding),
@@ -56,7 +57,8 @@ fun HrefMessageDialog(
5657
text2 = text2?.let { stringResource(it) } ?: "",
5758
linkText = stringResource(linkText),
5859
linkUrl = stringResource(linkUrl),
59-
showLinkOnOneLine = showLinkOnOneLine,
60+
newLineBeforeText2 = newLineBeforeText2,
61+
newLineBeforeLink = newLineBeforeLink,
6062
textStyle =
6163
TextStyle(
6264
color = MaterialTheme.colorScheme.onBackground,

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/shared/dialog/ConfirmationDialog.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fun ConfirmationDialog(
4949
@StringRes text2: Int,
5050
@StringRes linkText: Int,
5151
@StringRes linkUrl: Int,
52-
showLinkOnOneLine: Boolean = true,
52+
newLineBeforeLink: Boolean = true,
53+
newLineBeforeText2: Boolean = true,
5354
modifier: Modifier,
5455
onConfirm: () -> Unit,
5556
onDismiss: () -> Unit,
@@ -83,7 +84,8 @@ fun ConfirmationDialog(
8384
text2 = text2,
8485
linkText = linkText,
8586
linkUrl = linkUrl,
86-
showLinkOnOneLine = showLinkOnOneLine,
87+
newLineBeforeLink = newLineBeforeLink,
88+
newLineBeforeText2 = newLineBeforeText2,
8789
)
8890
}
8991
},

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/shared/dialog/SivaConfirmationDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fun SivaConfirmationDialog(
5353
text2 = R.string.siva_continue_question,
5454
linkText = R.string.siva_read_here,
5555
linkUrl = R.string.siva_info_url,
56-
showLinkOnOneLine = false,
56+
newLineBeforeText2 = true,
5757
onConfirm = {
5858
showDialog.value = false
5959
onResult(true)

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/signing/IdCardView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ fun IdCardView(
507507
text2 = text2,
508508
linkText = linkText,
509509
linkUrl = linkUrl,
510+
newLineBeforeLink = true,
510511
)
511512

512513
CancelAndOkButtonRow(

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/signing/MobileIdView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ fun MobileIdView(
319319
text2 = text2,
320320
linkText = linkText,
321321
linkUrl = linkUrl,
322+
newLineBeforeLink = true,
322323
)
323324

324325
CancelAndOkButtonRow(

0 commit comments

Comments
 (0)