Skip to content

Commit 756ccb7

Browse files
committed
Add a11y improvements
1 parent 9ccdf88 commit 756ccb7

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

feature/camera/src/main/java/com/android/developers/androidify/camera/CameraCaptureButton.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import androidx.compose.ui.graphics.drawscope.Stroke
4040
import androidx.compose.ui.platform.LocalDensity
4141
import androidx.compose.ui.res.stringResource
4242
import androidx.compose.ui.semantics.Role
43+
import androidx.compose.ui.semantics.contentDescription
44+
import androidx.compose.ui.semantics.semantics
4345
import androidx.compose.ui.tooling.preview.Preview
4446
import androidx.compose.ui.unit.dp
4547
import com.android.developers.androidify.theme.AndroidifyTheme
@@ -78,6 +80,13 @@ internal fun CameraCaptureButton(
7880
val disabledColor = MaterialTheme.colorScheme.surfaceContainer
7981
val interactionSource = remember { MutableInteractionSource() }
8082
val animationSpec = MaterialTheme.motionScheme.defaultSpatialSpec<Float>()
83+
84+
val semanticsDescription = if (enabled) {
85+
stringResource(R.string.capture_image_button_enabled_content_description)
86+
} else {
87+
stringResource(R.string.capture_image_button_disabled_content_description)
88+
}
89+
8190
Spacer(
8291
modifier
8392
.indication(interactionSource, ScaleIndicationNodeFactory(animationSpec))
@@ -90,6 +99,9 @@ internal fun CameraCaptureButton(
9099
role = Role.Button,
91100
onClickLabel = stringResource(R.string.cd_capture_button),
92101
)
102+
.semantics {
103+
contentDescription = semanticsDescription
104+
}
93105
.size(size)
94106
.drawWithCache {
95107
val outerPath = path.copy().apply {

feature/camera/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<string name="flip_camera_direction">Flip camera direction</string>
2626
<string name="rear_camera_description">Enable Rear Camera</string>
2727
<string name="camera_guide_text_label">Use guides to frame yourself for the perfect Bot</string>
28+
<string name="capture_image_button_enabled_content_description">Capture image</string>
29+
<string name="capture_image_button_disabled_content_description">Image capture disabled. Make sure your face is clearly visible in the frame.</string>
2830

2931
<string-array name="camera_result_compliments">
3032
<item>Great shot!</item>

feature/home/src/main/java/com/android/developers/androidify/home/HomeScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private fun VideoPlayerRotatedCard(
301301
modifier: Modifier = Modifier,
302302
) {
303303
val aspectRatio = 280f / 380f
304-
val videoInstructionText = stringResource(R.string.instruction_video_transcript)
304+
val videoInstructionText = stringResource(R.string.video_card_content_description)
305305
Box(
306306
modifier = modifier
307307
.focusable()
@@ -457,7 +457,7 @@ private fun DancingBot(
457457
AsyncImage(
458458
model = dancingBotLink,
459459
modifier = modifier,
460-
contentDescription = null,
460+
contentDescription = stringResource(R.string.dancing_android_bot),
461461
)
462462
}
463463

feature/home/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@
3737
<string name="terms">Terms</string>
3838
<string name="privacy">Privacy</string>
3939
<string name="oss_license">Licenses</string>
40+
<string name="video_card_content_description">A video showcasing the creation of an Android bot.</string>
41+
<string name="dancing_android_bot">A dancing Android bot.</string>
4042
</resources>

0 commit comments

Comments
 (0)