Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ class SettingsUtilTest {
fun testGetLocalizedLanguageName_Undeclared() {
val result = SettingsUtil.getLocalizedLanguageName("Yoruba")

assertEquals("Language", context.getString(result))
assertEquals("App language", context.getString(result))
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/be/scri/helpers/AnnotationTextUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object AnnotationTextUtils {
"Prepositional case" to Pair(color, processValuesForPreposition(language, "Pre")),
"Instrumental case" to Pair(color, processValuesForPreposition(language, "Ins")),
)
return suggestionMap[nounType] ?: Pair(R.color.transparent, context.getString(R.string.suggestion))
return suggestionMap[nounType] ?: Pair(R.color.transparent, context.getString(R.string.i18n_app_keyboard_suggestion))
}

/**
Expand All @@ -61,7 +61,7 @@ object AnnotationTextUtils {
"masculine" to Pair(R.color.annotateBlue, processValueForNouns(language, "M")),
"feminine" to Pair(R.color.annotateRed, processValueForNouns(language, "F")),
)
return suggestionMap[nounType] ?: Pair(R.color.transparent, context.getString(R.string.suggestion))
return suggestionMap[nounType] ?: Pair(R.color.transparent, context.getString(R.string.i18n_app_keyboard_suggestion))
}

/**
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/be/scri/ui/common/bottombar/BottomBarScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ import be.scri.navigation.Screen
sealed class BottomBarScreen(
val route: String,
@DrawableRes val icon: Int,
val label: String,
val labelRes: Int,
val altTextRes: Int,
) {
/**
* Represents the Installation screen and its associated route.
*/
data object Installation : BottomBarScreen(
Screen.Installation.route,
R.drawable.material_keyboard,
"Installation",
R.string.i18n_app_installation_title,
R.string.i18n_app_installation_title_alt_text,
)

/**
Expand All @@ -31,7 +33,8 @@ sealed class BottomBarScreen(
data object Conjugate : BottomBarScreen(
Screen.Conjugate.route,
R.drawable.material_keyboard,
"Conjugate",
R.string.i18n_app_conjugate_title,
R.string.i18n_app_conjugate_title_alt_text,
)

/**
Expand All @@ -40,7 +43,8 @@ sealed class BottomBarScreen(
data object Settings : BottomBarScreen(
Screen.Settings.route,
R.drawable.material_settings,
"Settings",
R.string.i18n_app_settings_title,
R.string.i18n_app_settings_title_alt_text,
)

/**
Expand All @@ -49,7 +53,8 @@ sealed class BottomBarScreen(
data object About : BottomBarScreen(
Screen.About.route,
R.drawable.material_info,
"About",
R.string.i18n_app_about_title,
R.string.i18n_app_about_title_alt_text,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import be.scri.R
Expand Down Expand Up @@ -65,13 +66,13 @@ fun ScribeBottomBar(
id = item.icon,
),
tint = color,
contentDescription = item.label,
contentDescription = stringResource(id = item.altTextRes),
modifier = Modifier.size(iconSize),
)
},
label = {
Text(
text = item.label,
text = stringResource(id = item.labelRes),
style =
MaterialTheme.typography.labelSmall.copy(
fontWeight = if (isSelected) FontWeight.ExtraBold else FontWeight.W600,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import be.scri.R

Expand All @@ -34,12 +36,19 @@ fun AboutPageItemComp(
trailingIcon: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
altText: String? = null,
) {
val semanticsModifier =
altText?.let { text ->
Modifier.semantics(mergeDescendants = true) { contentDescription = text }
} ?: Modifier

Box(
modifier =
modifier
.fillMaxWidth()
.clickable(onClick = onClick),
.clickable(onClick = onClick)
.then(semanticsModifier),
) {
Row(
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import be.scri.R

Expand All @@ -31,12 +34,19 @@ fun ClickableItemComp(
onClick: () -> Unit,
modifier: Modifier = Modifier,
desc: String? = null,
altText: String? = null,
) {
val semanticsModifier =
altText?.let { text ->
Modifier.semantics(mergeDescendants = true) { contentDescription = text }
} ?: Modifier

Box(
modifier =
modifier
.fillMaxWidth()
.clickable(onClick = onClick),
.clickable(onClick = onClick)
.then(semanticsModifier),
) {
Column(
modifier =
Expand Down Expand Up @@ -64,7 +74,7 @@ fun ClickableItemComp(
.padding(start = 6.dp)
.size(17.dp),
tint = MaterialTheme.colorScheme.onSurface,
contentDescription = "Right Arrow",
contentDescription = stringResource(R.string.i18n_app_accessibility_right_arrow),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fun ItemsCardContainer(
ClickableItemComp(
title = stringResource(item.title),
desc = item.desc?.let { stringResource(it) },
altText = item.altText?.let { stringResource(it) },
onClick = item.action,
)
}
Expand All @@ -51,6 +52,7 @@ fun ItemsCardContainer(
SwitchableItemComp(
title = stringResource(item.title),
desc = stringResource(item.desc),
altText = item.altText?.let { stringResource(it) },
isChecked = item.state,
onCheckedChange = item.onToggle,
)
Expand All @@ -62,6 +64,7 @@ fun ItemsCardContainer(
is ScribeItem.ExternalLinkItem -> {
AboutPageItemComp(
title = stringResource(item.title),
altText = item.altText?.let { stringResource(it) },
leadingIcon = item.leadingIcon,
trailingIcon = item.trailingIcon,
onClick = item.onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import be.scri.ui.screens.Alpha

Expand All @@ -34,20 +36,27 @@ fun SwitchableItemComp(
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
desc: String? = null,
altText: String? = null,
) {
val checkedThumbColor = MaterialTheme.colorScheme.primary
val uncheckedThumbColor = MaterialTheme.colorScheme.tertiaryContainer
val checkedTrackColor = MaterialTheme.colorScheme.tertiary
val uncheckedTrackColor = MaterialTheme.colorScheme.outlineVariant

val semanticsModifier =
altText?.let { text ->
Modifier.semantics(mergeDescendants = true) { contentDescription = text }
} ?: Modifier

Column(
modifier =
modifier
.toggleable(
value = isChecked,
onValueChange = onCheckedChange,
role = Role.Switch,
).padding(horizontal = 12.dp, vertical = 10.dp),
).padding(horizontal = 12.dp, vertical = 10.dp)
.then(semanticsModifier),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/be/scri/ui/models/ScribeItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.annotation.DrawableRes
sealed class ScribeItem(
open val title: Int,
open val desc: Int?,
open val altText: Int? = null,
) {
/**
* Represents a clickable item in the Scribe UI, typically used for actions like navigation or
Expand All @@ -23,8 +24,9 @@ sealed class ScribeItem(
data class ClickableItem(
override val title: Int,
override val desc: Int? = null,
override val altText: Int? = null,
val action: () -> Unit,
) : ScribeItem(title, desc)
) : ScribeItem(title, desc, altText)

/**
* Represents a toggleable switch item in the Scribe UI.
Expand All @@ -41,9 +43,10 @@ sealed class ScribeItem(
data class SwitchItem(
override val title: Int,
override val desc: Int,
override val altText: Int? = null,
val state: Boolean,
val onToggle: (Boolean) -> Unit,
) : ScribeItem(title, desc)
) : ScribeItem(title, desc, altText)

/**
* Represents an external link item in the Scribe UI.
Expand All @@ -61,11 +64,12 @@ sealed class ScribeItem(
data class ExternalLinkItem(
override val title: Int,
override val desc: Int? = null,
override val altText: Int? = null,
@DrawableRes val leadingIcon: Int,
@DrawableRes val trailingIcon: Int,
val url: String?,
val onClick: () -> Unit,
) : ScribeItem(title, desc)
) : ScribeItem(title, desc, altText)

/**
* Represents a custom item in the Scribe UI.
Expand All @@ -79,6 +83,7 @@ sealed class ScribeItem(
data class CustomItem(
override val title: Int,
override val desc: Int,
override val altText: Int? = null,
val customAction: (Any?) -> Unit,
) : ScribeItem(title, desc)
) : ScribeItem(title, desc, altText)
}
14 changes: 7 additions & 7 deletions app/src/main/java/be/scri/ui/screens/ConjugateScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fun ConjugateScreen(
) {
Image(
painter = painterResource(id = R.drawable.ic_search_vector),
contentDescription = "Search",
contentDescription = stringResource(R.string.i18n_app_accessibility_search),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimary),
modifier = Modifier.size(Dimensions.IconSize),
)
Expand Down Expand Up @@ -183,7 +183,7 @@ fun ConjugateScreen(
if (searchQuery.isNotEmpty()) {
Image(
painter = painterResource(id = R.drawable.close),
contentDescription = "Clear",
contentDescription = stringResource(R.string.i18n_app_accessibility_clear),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimary),
modifier =
Modifier
Expand All @@ -195,7 +195,7 @@ fun ConjugateScreen(

Image(
painter = painterResource(id = R.drawable.play_button),
contentDescription = "Play button",
contentDescription = stringResource(R.string.i18n_app_accessibility_play_button),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimary),
modifier =
Modifier
Expand Down Expand Up @@ -242,7 +242,7 @@ fun ConjugateScreen(
)
Image(
painter = painterResource(id = R.drawable.right_arrow),
contentDescription = "Right Arrow",
contentDescription = stringResource(R.string.i18n_app_accessibility_right_arrow),
modifier =
Modifier
.size(Dimensions.IconSize)
Expand Down Expand Up @@ -339,7 +339,7 @@ fun ConjugateScreen(
)
Image(
painter = painterResource(R.drawable.right_arrow),
contentDescription = "Right Arrow",
contentDescription = stringResource(R.string.i18n_app_accessibility_right_arrow),
modifier =
Modifier
.size(Dimensions.IconSize)
Expand Down Expand Up @@ -398,7 +398,7 @@ fun ConjugateScreen(
)
Image(
painter = painterResource(R.drawable.right_arrow),
contentDescription = "Right Arrow",
contentDescription = stringResource(R.string.i18n_app_accessibility_right_arrow),
modifier =
Modifier
.size(Dimensions.IconSize)
Expand Down Expand Up @@ -471,7 +471,7 @@ fun ConjugateScreen(
)
Image(
painter = painterResource(id = R.drawable.right_arrow),
contentDescription = "Right Arrow",
contentDescription = stringResource(R.string.i18n_app_accessibility_right_arrow),
modifier =
Modifier
.size(Dimensions.IconSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fun ConjugationSelectionScreen(
)
Image(
painter = painterResource(id = R.drawable.ic_tab_rounded),
contentDescription = "Expand tenses",
contentDescription = stringResource(R.string.i18n_app_accessibility_expand_tenses),
colorFilter = ColorFilter.tint(Color.Black),
modifier = Modifier.size(18.dp),
)
Expand Down Expand Up @@ -234,7 +234,7 @@ fun ConjugationSelectionScreen(
contentAlignment = Alignment.Center,
) {
Text(
text = "Data not present in Wikidata",
text = stringResource(R.string.i18n_app_conjugate_data_not_present_in_wikidata),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
)
Expand Down Expand Up @@ -269,7 +269,7 @@ fun ConjugationSelectionScreen(
contentAlignment = Alignment.Center,
) {
Text(
text = "Loading conjugation tables...",
text = stringResource(R.string.i18n_app_conjugate_loading_tables),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
)
Expand Down Expand Up @@ -467,7 +467,7 @@ private fun ConjugationCell(
)
Image(
painter = painterResource(id = R.drawable.ic_clipboard_vector),
contentDescription = "Copy conjugation",
contentDescription = stringResource(R.string.i18n_app_accessibility_copy_conjugation),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface.copy(alpha = 0.4f)),
modifier =
Modifier
Expand Down
Loading
Loading