Skip to content

Commit f39a6ed

Browse files
authored
Merge pull request #69 from android/anomis/a11y-improvements
Add a11y improvements
2 parents 9ccdf88 + 4f9c6d4 commit f39a6ed

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
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>

0 commit comments

Comments
 (0)