Skip to content

Commit

Permalink
[#506] The number of search results is now vocalized
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmaitre committed Aug 7, 2023
1 parent 75c4820 commit c0fb62a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
27 changes: 27 additions & 0 deletions app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ package com.orange.ods.app.ui.search

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.LiveRegionMode
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.liveRegion
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import com.orange.ods.app.R
import com.orange.ods.app.ui.LocalOdsGuideline
import com.orange.ods.app.ui.MainDestinations
Expand Down Expand Up @@ -132,6 +140,25 @@ fun SearchScreen(
modifier = Modifier
.fillMaxWidth()
) {
item {
// The aim of this item is to vocalize the number of search results
// This should be done on LazyColumn with liveRegion and contentDescription, but doing so vocalizes the entire content of the column
// Thus we add the text below in order to vocalize the number of search results only
// The text is not empty with a 1dp height otherwise it is not vocalized, and alpha is set to 0 to make it invisible when navigating with TalkBack
Text(" ", modifier = Modifier
.height(1.dp)
.alpha(0f)
.semantics {
liveRegion = LiveRegionMode.Polite
contentDescription = with(context.resources) {
if (searchResults.isNotEmpty()) {
getQuantityString(R.plurals.search_result_count_content_description, searchResults.count(), searchResults.count())
} else {
getString(R.string.search_no_result_content_description)
}
}
})
}
items(searchResults) { item ->
val openDialog = remember { mutableStateOf(false) }
val guidelineColor = filteredGuidelineColors.firstOrNull { guidelineColor ->
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,10 @@
<!-- Search -->
<string name="search_text_field_hint">Search</string>
<string name="search_content_description">Search icon</string>
<plurals name="search_result_count_content_description">
<item quantity="one">There is %1$d result</item>
<item quantity="other">There are %1$d results</item>
</plurals>
<string name="search_no_result_content_description">There are no results</string>

</resources>
7 changes: 4 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [\All\] Use Compose BOM and update Kotlin and Gradle versions ([#578](https://github.com/Orange-OpenSource/ods-android/issues/578))
- \[All\] Use Compose BOM and update Kotlin and Gradle versions ([#578](https://github.com/Orange-OpenSource/ods-android/issues/578))
- \[Lib\] Replace composable parameter of `OdsDropdownMenu` with a list of `OdsDropdownMenuItem` ([#572](https://github.com/Orange-OpenSource/ods-android/issues/572))
- \[Lib\] Update `OdsTopAppBar` and `OdsLargeTopAppBar` APIs ([#572](https://github.com/Orange-OpenSource/ods-android/issues/572))
- \[Lib\] Update `OdsBottomNavigation` API ([#588](https://github.com/Orange-OpenSource/ods-android/issues/588))

### Fixed

- [\App\] Screen displayed on filter chip variant click was not the good one ([#580](https://github.com/Orange-OpenSource/ods-android/issues/580))
- [\App\] Fix a bug where `OdsListItem` text color did not update when switching between light and dark modes in text field demo ([#578](https://github.com/Orange-OpenSource/ods-android/issues/578))
- \[App\] Screen displayed on filter chip variant click was not the good one ([#580](https://github.com/Orange-OpenSource/ods-android/issues/580))
- \[App\] Fix a bug where `OdsListItem` text color did not update when switching between light and dark modes in text field demo ([#578](https://github.com/Orange-OpenSource/ods-android/issues/578))
- \[App\] The number of search results is now vocalized ([#506](https://github.com/Orange-OpenSource/ods-android/issues/506))

## [0.14.0](https://github.com/Orange-OpenSource/ods-android/compare/0.13.0...0.14.0) - 2023-07-12

Expand Down

0 comments on commit c0fb62a

Please sign in to comment.