From f97c8e6908b5a4a5d975cee1bfbd967a4fbcd972 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sat, 6 Jan 2024 19:36:45 +0200 Subject: [PATCH] Move Expiried/Expires soon strings to text resources --- .../home/vault/component/VaultViewInfoItem.kt | 2 +- .../feature/home/vault/model/VaultViewItem.kt | 1 - .../vault/screen/VaultViewStateProducer.kt | 27 ++++++++++++------- .../send/view/SendViewStateProducer.kt | 1 - .../commonMain/resources/MR/base/strings.xml | 7 +++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewInfoItem.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewInfoItem.kt index 9906047c..041c127d 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewInfoItem.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewInfoItem.kt @@ -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) } diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/model/VaultViewItem.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/model/VaultViewItem.kt index eefb6056..84694fd5 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/model/VaultViewItem.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/model/VaultViewItem.kt @@ -122,7 +122,6 @@ sealed interface VaultViewItem { override val id: String, val name: String, val message: String? = null, - val long: Boolean, ) : VaultViewItem { companion object; } diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/screen/VaultViewStateProducer.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/screen/VaultViewStateProducer.kt index e70a11f2..2faa8dc7 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/screen/VaultViewStateProducer.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/screen/VaultViewStateProducer.kt @@ -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) } diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/send/view/SendViewStateProducer.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/send/view/SendViewStateProducer.kt index f202f181..9d42f9e6 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/send/view/SendViewStateProducer.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/send/view/SendViewStateProducer.kt @@ -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) } diff --git a/common/src/commonMain/resources/MR/base/strings.xml b/common/src/commonMain/resources/MR/base/strings.xml index f45afe23..3acbfcac 100644 --- a/common/src/commonMain/resources/MR/base/strings.xml +++ b/common/src/commonMain/resources/MR/base/strings.xml @@ -61,6 +61,7 @@ Notes Attachments No attachments + Expired Expiring soon Incomplete data This item is missing some of the important information. @@ -373,6 +374,12 @@ Authenticate WebAuthn Return to app + This item expires on %1$s. + This card expires on %1$s. There are a few things you can do to ensure a smooth transition: + 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. + 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. + 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. +