Move Expiried/Expires soon strings to text resources

This commit is contained in:
Artem Chepurnoy 2024-01-06 19:36:45 +02:00
parent 28c4aeaa96
commit f97c8e6908
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
5 changed files with 25 additions and 13 deletions

View File

@ -59,7 +59,7 @@ fun VaultViewInfoItem(
modifier: Modifier = Modifier,
item: VaultViewItem.Info,
) {
val expandable = item.long
val expandable = item.message.orEmpty().length >= 200
val expandedState = remember(expandable) {
mutableStateOf(!expandable)
}

View File

@ -122,7 +122,6 @@ sealed interface VaultViewItem {
override val id: String,
val name: String,
val message: String? = null,
val long: Boolean,
) : VaultViewItem {
companion object;
}

View File

@ -812,28 +812,35 @@ private fun RememberStateFlowScope.oh(
id = "info.incomplete",
name = translate(Res.strings.item_incomplete_title),
message = translate(Res.strings.item_incomplete_text),
long = false,
)
emit(model)
}
val expiring = cipherExpiringCheck.invoke(cipher, Clock.System.now())
val now = Clock.System.now()
val expiring = cipherExpiringCheck.invoke(cipher, now)
if (expiring != null) {
val expired = expiring <= now
val expiringTitle = if (expired) {
translate(Res.strings.expired)
} else {
translate(Res.strings.expiring_soon)
}
val expiringDate = dateFormatter.formatDate(expiring)
val expiringMessage = when (cipher.type) {
DSecret.Type.Card ->
"This card expires on $expiringDate. There are a few things you can do to ensure a smooth transition:\n" +
"1. Get a new card: Your card issuer may have already sent you a replacement card with a new expiration date. If not, contact your card issuer to see if they plan to send you a new card and when to expect it.\n" +
"2. Update automatic payments: If you have any automatic payments set up with your card, such as a monthly gym membership or Netflix subscription, make sure to update the information with the new card number and expiration date.\n" +
"3. Destroy the old card: Once your new card arrives and you have updated any necessary information, be sure to securely dispose of the old, expired card to prevent identity theft."
DSecret.Type.Card -> listOf(
translate(Res.strings.expiry_tips_card_line1, expiringDate),
translate(Res.strings.expiry_tips_card_line2, expiringDate),
translate(Res.strings.expiry_tips_card_line3, expiringDate),
translate(Res.strings.expiry_tips_card_line4, expiringDate),
).joinToString(separator = "\n")
else -> "This item expires on $expiringDate."
else -> translate(Res.strings.expiry_tips_item_line1, expiringDate)
}
val model = VaultViewItem.Info(
id = "info.expiring",
name = translate(Res.strings.expiring_soon),
name = expiringTitle,
message = expiringMessage,
long = true,
)
emit(model)
}

View File

@ -347,7 +347,6 @@ private fun RememberStateFlowScope.oh(
id = "disabled",
name = "Deactivated",
message = "This share is deactivated, no one can access it.",
long = false,
)
emit(model)
}

View File

@ -61,6 +61,7 @@
<string name="notes">Notes</string>
<string name="attachments">Attachments</string>
<string name="attachments_empty_label">No attachments</string>
<string name="expired">Expired</string>
<string name="expiring_soon">Expiring soon</string>
<string name="item_incomplete_title">Incomplete data</string>
<string name="item_incomplete_text">This item is missing some of the important information.</string>
@ -373,6 +374,12 @@
<string name="fido2webauthn_action_go_title">Authenticate WebAuthn</string>
<string name="fido2webauthn_action_return_title">Return to app</string>
<string name="expiry_tips_item_line1">This item expires on <xliff:g id="date" example="15 May 2024">%1$s</xliff:g>.</string>
<string name="expiry_tips_card_line1">This card expires on <xliff:g id="date" example="15 May 2024">%1$s</xliff:g>. There are a few things you can do to ensure a smooth transition:</string>
<string name="expiry_tips_card_line2">1. Get a new card: Your card issuer may have already sent you a replacement card with a new expiration date. If not, contact your card issuer to see if they plan to send you a new card and when to expect it.</string>
<string name="expiry_tips_card_line3">2. Update automatic payments: If you have any automatic payments set up with your card, such as a monthly gym membership or Netflix subscription, make sure to update the information with the new card number and expiration date.</string>
<string name="expiry_tips_card_line4">3. Destroy the old card: Once your new card arrives and you have updated any necessary information, be sure to securely dispose of the old, expired card to prevent identity theft.</string>
<!--
Empty string is a string that contains zero symbols in it,
e.g. "" is an empty string -->