Skip to content

Commit

Permalink
♿ Add contentDescription where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs committed Jun 13, 2021
1 parent 10edee1 commit 9a0014c
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.svenjacobs.app.leon.R
import com.svenjacobs.app.leon.ui.theme.primaryColor

Expand Down Expand Up @@ -78,7 +79,7 @@ fun BroomIcon(
Image(
modifier = modifier.scale(scale),
painter = painterResource(R.drawable.ic_broom),
contentDescription = null,
contentDescription = stringResource(R.string.a11y_broom_icon),
colorFilter = ColorFilter.tint(color),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ private fun FailureBody() {
.height(300.dp)
.padding(end = 16.dp),
painter = painterResource(R.drawable.howto_pixel_5),
contentDescription = null
contentDescription = stringResource(R.string.a11y_howto)
)

Text(
modifier = Modifier,
textAlign = TextAlign.Justify,
text = stringResource(id = R.string.how_to_text)
text = stringResource(R.string.how_to_text)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ fun MainScreen(

bottomNavItems.forEach { screen ->
BottomNavigationItem(
icon = { Icon(screen.icon, contentDescription = null) },
label = { Text(stringResource(screen.resourceId)) },
icon = {
Icon(
imageVector = screen.icon,
contentDescription = stringResource(screen.iconContentDescription),
)
},
label = { Text(stringResource(screen.label)) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route) {
Expand Down Expand Up @@ -160,7 +165,10 @@ fun MainScreen(
@Composable
private fun NavigationIcon(navController: NavController) {
IconButton(onClick = { navController.popBackStack() }) {
Icon(Icons.Filled.ArrowBack, contentDescription = null)
Icon(
Icons.Filled.ArrowBack,
contentDescription = stringResource(R.string.a11y_back_navigation),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,27 @@ import com.svenjacobs.app.leon.R
sealed class Screen(
val route: String,
val icon: ImageVector,
@StringRes val resourceId: Int,
@StringRes val label: Int,
@StringRes val iconContentDescription: Int,
) {
object Home : Screen("home", Icons.Filled.Home, R.string.screen_home)
object Settings : Screen("settings", Icons.Filled.Settings, R.string.screen_settings)
object SettingsParameters :
Screen("settings_parameters", Icons.Filled.Settings, R.string.screen_settings)
object Home : Screen(
route = "home",
icon = Icons.Filled.Home,
label = R.string.screen_home,
iconContentDescription = R.string.screen_home,
)

object Settings : Screen(
route = "settings",
icon = Icons.Filled.Settings,
label = R.string.screen_settings,
iconContentDescription = R.string.screen_settings,
)

object SettingsParameters : Screen(
route = "settings_parameters",
icon = Icons.Filled.Settings,
label = R.string.screen_settings,
iconContentDescription = R.string.screen_settings,
)
}
23 changes: 23 additions & 0 deletions app/src/main/res/values-de/a11y.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Léon - The URL Cleaner
~ Copyright (C) 2021 Sven Jacobs
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<resources>
<string name="a11y_broom_icon">Darstellung eines Besens</string>
<string name="a11y_howto">Darstellung eines Smartphones, welche die Anwendung erläutert</string>
<string name="a11y_back_navigation">Icon um zurück zu navigieren</string>
</resources>
23 changes: 23 additions & 0 deletions app/src/main/res/values/a11y.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Léon - The URL Cleaner
~ Copyright (C) 2021 Sven Jacobs
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<resources>
<string name="a11y_broom_icon">Depiction of a broom</string>
<string name="a11y_howto">Depiction of a smartphone explaining application</string>
<string name="a11y_back_navigation">Icon which navigates back</string>
</resources>

0 comments on commit 9a0014c

Please sign in to comment.