google-developer-training / basic-android-kotlin-compose-training-mars-photos

Solution code for Android Basics in Kotlin course
https://developer.android.com/courses/android-basics-kotlin/course?gclid=CjwKCAjw4c-ZBhAEEiwAZ105RTyT-iaLHzrhMBUXdMhO230ZDwOwxxI2x4RgK8DwBxK8t1h0wmU_QxoCi4YQAvD_BwE
Apache License 2.0
74 stars 68 forks source link

Get Data from the Internet - contentDescription of image should be null #70

Open fe60 opened 1 year ago

fe60 commented 1 year ago

URL of codelab: Android Basics with Compose Unit 5: Connect to the internet Activity 5: Get data from the internet Get data from the internet 7- Add Internet permission and Exception Handling

In which task and step of the codelab can this issue be found? Section: Add State UI step 10

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding

@Composable
fun ErrorScreen(modifier: Modifier = Modifier) {
    Column(
        modifier = modifier,
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Image(
            painter = painterResource(id = R.drawable.ic_connection_error), contentDescription = ""
        )
        Text(text = stringResource(R.string.loading_failed), modifier = Modifier.padding(16.dp))
    }
}

Describe the problem The content description of Image should be null instead of an empty string. Alternatively it can provide a meaningful description. This is not required, as the Text exposes the same information about the current status.

Compose Accessibility guide

Some visual elements are purely decorative and you might not want to communicate them to the user. When you set the contentDescription parameter to null, you indicate to the Android framework that this element does not have associated actions or state.