improvement: Localize Failed open a URI error message

This commit is contained in:
Artem Chepurnoy 2024-03-29 12:58:01 +02:00
parent 7670a040e3
commit 70411332af
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
2 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import com.artemchep.keyguard.common.model.ToastMessage
import com.artemchep.keyguard.common.usecase.ShowMessage
import com.artemchep.keyguard.feature.localization.textResource
import com.artemchep.keyguard.platform.LocalLeContext
import com.artemchep.keyguard.res.Res
import com.halilibo.richtext.commonmark.Markdown
import com.halilibo.richtext.markdown.BasicMarkdown
import com.halilibo.richtext.markdown.node.AstNode
@ -52,16 +55,18 @@ fun MarkdownText(
@Composable
private fun rememberGracefulLinkClickHandler(): LinkClickHandler {
val showMessage by rememberInstance<ShowMessage>()
val updatedContext by rememberUpdatedState(LocalLeContext)
val updatedUriHandler by rememberUpdatedState(LocalUriHandler.current)
return remember {
LinkClickHandler { uri ->
try {
updatedUriHandler.openUri(uri)
} catch (e: Exception) {
val title = e.message
?: "Could not open a URI"
val title = textResource(Res.strings.error_failed_open_uri, updatedContext)
val msg = ToastMessage(
title = title,
text = e.message,
type = ToastMessage.Type.ERROR,
)
showMessage.copy(msg)

View File

@ -455,6 +455,7 @@
<string name="error_failed_generate_otp_code">Failed to generate OTP code</string>
<string name="error_failed_create_passkey">Failed to create a passkey</string>
<string name="error_failed_use_passkey">Failed to authorize a request</string>
<string name="error_failed_open_uri">Failed to open a URI</string>
<string name="error_failed_format_placeholder">Failed to format the placeholder</string>
<!-- Title of the 'Show as Barcode' dialog -->