mirror of
https://github.com/bitwarden/android.git
synced 2026-03-21 22:00:42 -05:00
PM-14333 fix case of crowdin translation not adding annotations on string with format args (#4505)
This commit is contained in:
@@ -151,7 +151,7 @@ fun Intent.getTotpCopyIntentOrNull(): AutofillTotpCopyData? =
|
||||
|
||||
/**
|
||||
* Checks if the given [Activity] was created for Autofill. This is useful to avoid locking the
|
||||
* vault if one of the Autofill services starts the only only instance of the [MainActivity].
|
||||
* vault if one of the Autofill services starts the only instance of the [MainActivity].
|
||||
*/
|
||||
val Activity.createdForAutofill: Boolean
|
||||
get() = intent.getAutofillSelectionDataOrNull() != null ||
|
||||
|
||||
@@ -61,7 +61,7 @@ fun @receiver:StringRes Int.toAnnotatedString(
|
||||
SpannableStringBuilder(resources.getText(this) as SpannedString)
|
||||
} catch (e: ClassCastException) {
|
||||
// the resource did not contain and valid spans so we just return the raw string.
|
||||
return stringResource(id = this).toAnnotatedString()
|
||||
return stringResource(id = this, *args).toAnnotatedString()
|
||||
}
|
||||
// Replace any format arguments with the provided arguments.
|
||||
spannableBuilder.applyArgAnnotations(args = args)
|
||||
|
||||
@@ -100,4 +100,20 @@ class StringRestExtensionsTest : BaseComposeTest() {
|
||||
.onNodeWithText("On your computer, open a new browser tab and go to ")
|
||||
.assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `string with no annotations with args should just be handled as normal annotated string`() {
|
||||
composeTestRule.setContent {
|
||||
Text(
|
||||
text = R.string.test_for_string_with_no_annotations_with_format_arg.toAnnotatedString(
|
||||
args = arrayOf("this"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Nothing special here, except this.")
|
||||
.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<string name="test_for_single_link_annotation">Get emails from Bitwarden for announcements, advice, and research opportunities. <annotation link="unsubscribe">Unsubscribe</annotation> at any time.</string>
|
||||
<string name="test_for_multi_link_annotation">By continuing, you agree to the <annotation link="termsOfService">Terms of Service</annotation> and <annotation link="privacyPolicy">Privacy Policy</annotation></string>
|
||||
<string name="test_for_string_with_no_annotations">Nothing special here.</string>
|
||||
<string name="test_for_string_with_no_annotations_with_format_arg">Nothing special here, except %1$s.</string>
|
||||
<string name="test_for_string_with_annotation_and_arg_annotation">On your computer, open a new browser tab and <annotation emphasis="bold">go to <annotation arg="0">%1$s</annotation></annotation></string>
|
||||
<!-- /StringResExtensions Test value -->
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user