Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ import androidx.compose.ui.platform.testTag
import ee.ria.DigiDoc.ui.component.shared.TagBadge
import ee.ria.DigiDoc.ui.theme.Green_2_50
import ee.ria.DigiDoc.ui.theme.Green_2_700
import ee.ria.DigiDoc.ui.theme.Red50
import ee.ria.DigiDoc.ui.theme.Red800

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun ColoredRecipientStatusText(
text: String,
modifier: Modifier = Modifier,
expired: Boolean = false,
) {
val tagBackgroundColor = Green_2_50
val tagContentColor = Green_2_700
val tagBackgroundColor = if (!expired) Green_2_50 else Red50
val tagContentColor = if (!expired) Green_2_700 else Red800

FlowRow(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ fun EncryptNavigation(
leftActionButtonName = R.string.sign_button,
rightActionButtonName = rightActionButtonName,
leftActionButtonContentDescription = R.string.sign_button,
rightActionButtonContentDescription = R.string.decrypt_button_accessibility,
rightActionButtonContentDescription = rightActionButtonName,
onLeftActionButtonClick = onSignActionClick,
onRightActionButtonClick = {
if (encryptViewModel.isDecryptButtonShown(cryptoContainer, isNestedContainer)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import ee.ria.DigiDoc.utilsLib.container.NameUtil.formatCompanyName
import ee.ria.DigiDoc.utilsLib.container.NameUtil.formatName
import ee.ria.DigiDoc.utilsLib.date.DateUtil.dateFormat
import ee.ria.DigiDoc.utilsLib.validator.PersonalCodeValidator
import java.util.Date

@OptIn(ExperimentalComposeUiApi::class)
@Composable
Expand All @@ -83,7 +84,6 @@ fun RecipientComponent(
onClick: (Addressee) -> Unit,
isCDOC2Container: Boolean = false,
) {
val context = LocalContext.current
val recipientText = stringResource(R.string.crypto_recipient_title)
val buttonName = stringResource(id = R.string.button_name)

Expand Down Expand Up @@ -114,6 +114,7 @@ fun RecipientComponent(
formatCompanyName(recipient.identifier, recipient.serialNumber)
}
val certTypeText = getRecipientCertTypeText(LocalContext.current, recipient.certType)
var expired = false
var certValidTo =
recipient.validTo
?.let {
Expand All @@ -130,17 +131,22 @@ fun RecipientComponent(
val decryptionValidToText =
if (isCDOC2Container) {
certValidTo = ""
recipient.validTo
?.let {
dateFormat.format(
it,

recipient.validTo?.let { validToDate ->
val formattedDate = dateFormat.format(validToDate)
if (validToDate.before(Date())) {
expired = true
stringResource(
R.string.crypto_decryption_expired,
formattedDate,
)
}?.let {
} else {
stringResource(
R.string.crypto_decryption_valid_to,
it,
formattedDate,
)
} ?: ""
}
} ?: ""
} else {
""
}
Expand Down Expand Up @@ -234,6 +240,7 @@ fun RecipientComponent(
if (decryptionValidToText.isNotEmpty()) {
ColoredRecipientStatusText(
text = decryptionValidToText,
expired = expired,
modifier =
modifier
.padding(vertical = SBorder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
Expand Down Expand Up @@ -87,9 +86,12 @@ fun ContainerNameView(
onRightActionButtonClick: () -> Unit = {},
onMoreOptionsActionButtonClick: () -> Unit = {},
) {
val context = LocalContext.current
val leftActionButtonContentDescriptionText = stringResource(leftActionButtonContentDescription)
val rightActionButtonContentDescriptionText = stringResource(rightActionButtonContentDescription)

var rightActionButtonContentDescriptionText = ""
if (showRightActionButton) {
rightActionButtonContentDescriptionText = stringResource(rightActionButtonContentDescription)
}

val containerTitleText = stringResource(R.string.container_title)

Expand Down
16 changes: 15 additions & 1 deletion app/src/main/kotlin/ee/ria/DigiDoc/viewmodel/EncryptViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import ee.ria.DigiDoc.viewmodel.shared.SharedContainerViewModel
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
import java.io.File
import java.util.Date
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -99,7 +100,20 @@ class EncryptViewModel
fun isDecryptButtonShown(
cryptoContainer: CryptoContainer?,
isNestedContainer: Boolean,
): Boolean = isEncryptedContainer(cryptoContainer) && !isNestedContainer
): Boolean {
val base = isEncryptedContainer(cryptoContainer) && !isNestedContainer
if (!base) return false

val now = Date()
val allExpired =
cryptoContainer
?.recipients
?.all { recipient ->
recipient.validTo?.before(now) == true
} ?: false

return !allExpired
}

fun isEncryptButtonShown(
cryptoContainer: CryptoContainer?,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<string name="crypto_container_added_recipients_title">Lisatud adressaadid</string>
<string name="crypto_recipient_title">Adressaat</string>
<string name="crypto_decryption_valid_to">Dekrüpteerimine võimalik kuni %1$s</string>
<string name="crypto_decryption_expired">Dekrüpteerimise võimalus aegus %1$s</string>
<string name="crypto_cert_valid_to">(kehtiv kuni %1$s)</string>
<string name="crypto_documents_title">Ümbriku failid</string>
<string name="crypto_encrypted_documents_title">Krüpteeritud failid</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<string name="crypto_container_added_recipients_title">Added recipients</string>
<string name="crypto_recipient_title">Recipient</string>
<string name="crypto_decryption_valid_to">Decryption until %1$s</string>
<string name="crypto_decryption_expired">Decryption expired %1$s</string>
<string name="crypto_cert_valid_to">(valid to %1$s)</string>
<string name="crypto_documents_title">Container files</string>
<string name="crypto_encrypted_documents_title">Encrypted files</string>
Expand Down
Loading