Skip to content

A fully functional Android app built entirely with Kotlin and Jetpack Compose

removed hardcoded strings

magicalmeghan5137cd77776a
diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
index 8a0a04dbf..68196a5af 100644
--- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
+++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
@@ -236,6 +236,8 @@ fun NewsResourceTopics(
// Store the ID of the Topic which has its "following" menu expanded, if any.
// To avoid UI confusion, only one topic can have an expanded menu at a time.
var expandedTopicId by remember { mutableStateOf<String?>(null) }
+ val isFollowed = stringResource(R.string.topic_is_followed)
+ val isNotFollowed = stringResource(R.string.topic_is_not_followed)
Row(
modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips
@@ -255,10 +257,10 @@ fun NewsResourceTopics(
Text(
text = followableTopic.topic.name.uppercase(Locale.getDefault()),
modifier = Modifier.semantics {
+
contentDescription = followableTopic.topic.name +
- if (followableTopic.isFollowed) " is followed"
- else " is not followed"
- // make sure this is the right place to add this - remove hardcoded strings
+ if (followableTopic.isFollowed) isFollowed
+ else isNotFollowed
}
)
}
diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml
index 6d7c98eb1..fff33bf3a 100644
--- a/core/ui/src/main/res/values/strings.xml
+++ b/core/ui/src/main/res/values/strings.xml
@@ -21,4 +21,7 @@
<string name="card_tap_action">Open Resource Link</string>
<string name="card_meta_data_text">%1$s • %2$s</string>
+
+ <string name="topic_is_followed">is followed</string>
+ <string name="topic_is_not_followed">is not followed</string>
</resources>