Skip to content

Commit a3b81db

Browse files
committed
MOPPAND-1718 Decryption expired check and colored label in RecipientComponent UI.
1 parent 1aba2e6 commit a3b81db

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/crypto/ColoredRecipientStatusText.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ import androidx.compose.ui.platform.testTag
3030
import ee.ria.DigiDoc.ui.component.shared.TagBadge
3131
import ee.ria.DigiDoc.ui.theme.Green_2_50
3232
import ee.ria.DigiDoc.ui.theme.Green_2_700
33+
import ee.ria.DigiDoc.ui.theme.Red50
34+
import ee.ria.DigiDoc.ui.theme.Red800
3335

3436
@OptIn(ExperimentalLayoutApi::class)
3537
@Composable
3638
fun ColoredRecipientStatusText(
3739
text: String,
3840
modifier: Modifier = Modifier,
41+
expired: Boolean = false,
3942
) {
40-
val tagBackgroundColor = Green_2_50
41-
val tagContentColor = Green_2_700
43+
val tagBackgroundColor = if (!expired) Green_2_50 else Red50
44+
val tagContentColor = if (!expired) Green_2_700 else Red800
4245

4346
FlowRow(
4447
modifier = modifier,

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/crypto/RecipientComponent.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import ee.ria.DigiDoc.utilsLib.container.NameUtil.formatCompanyName
7272
import ee.ria.DigiDoc.utilsLib.container.NameUtil.formatName
7373
import ee.ria.DigiDoc.utilsLib.date.DateUtil.dateFormat
7474
import ee.ria.DigiDoc.utilsLib.validator.PersonalCodeValidator
75+
import java.util.Date
7576

7677
@OptIn(ExperimentalComposeUiApi::class)
7778
@Composable
@@ -83,7 +84,6 @@ fun RecipientComponent(
8384
onClick: (Addressee) -> Unit,
8485
isCDOC2Container: Boolean = false,
8586
) {
86-
val context = LocalContext.current
8787
val recipientText = stringResource(R.string.crypto_recipient_title)
8888
val buttonName = stringResource(id = R.string.button_name)
8989

@@ -114,6 +114,7 @@ fun RecipientComponent(
114114
formatCompanyName(recipient.identifier, recipient.serialNumber)
115115
}
116116
val certTypeText = getRecipientCertTypeText(LocalContext.current, recipient.certType)
117+
var expired = false
117118
var certValidTo =
118119
recipient.validTo
119120
?.let {
@@ -130,17 +131,22 @@ fun RecipientComponent(
130131
val decryptionValidToText =
131132
if (isCDOC2Container) {
132133
certValidTo = ""
133-
recipient.validTo
134-
?.let {
135-
dateFormat.format(
136-
it,
134+
135+
recipient.validTo?.let { validToDate ->
136+
val formattedDate = dateFormat.format(validToDate)
137+
if (validToDate.before(Date())) {
138+
expired = true
139+
stringResource(
140+
R.string.crypto_decryption_expired,
141+
formattedDate,
137142
)
138-
}?.let {
143+
} else {
139144
stringResource(
140145
R.string.crypto_decryption_valid_to,
141-
it,
146+
formattedDate,
142147
)
143-
} ?: ""
148+
}
149+
} ?: ""
144150
} else {
145151
""
146152
}
@@ -234,6 +240,7 @@ fun RecipientComponent(
234240
if (decryptionValidToText.isNotEmpty()) {
235241
ColoredRecipientStatusText(
236242
text = decryptionValidToText,
243+
expired = expired,
237244
modifier =
238245
modifier
239246
.padding(vertical = SBorder)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<string name="crypto_container_added_recipients_title">Lisatud adressaadid</string>
164164
<string name="crypto_recipient_title">Adressaat</string>
165165
<string name="crypto_decryption_valid_to">Dekrüpteerimine võimalik kuni %1$s</string>
166+
<string name="crypto_decryption_expired">Dekrüpteerimise võimalus aegus %1$s</string>
166167
<string name="crypto_cert_valid_to">(kehtiv kuni %1$s)</string>
167168
<string name="crypto_documents_title">Ümbriku failid</string>
168169
<string name="crypto_encrypted_documents_title">Krüpteeritud failid</string>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<string name="crypto_container_added_recipients_title">Added recipients</string>
164164
<string name="crypto_recipient_title">Recipient</string>
165165
<string name="crypto_decryption_valid_to">Decryption until %1$s</string>
166+
<string name="crypto_decryption_expired">Decryption expired %1$s</string>
166167
<string name="crypto_cert_valid_to">(valid to %1$s)</string>
167168
<string name="crypto_documents_title">Container files</string>
168169
<string name="crypto_encrypted_documents_title">Encrypted files</string>

0 commit comments

Comments
 (0)