Skip to content
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

# [2.1.0]

### 2026-06-11

- Add optional `cancelButtonAccessibilityLabel`, `torchButtonOnAccessibilityLabel` and `torchButtonOffAccessibilityLabel` scan parameters to set the alternative text (content description) read by screen readers on the Cancel and Torch buttons. When not provided, no label is set, keeping the previous behavior unchanged. (https://github.com/OutSystems/OSBarcodeLib-Android/issues/54)

# [2.0.1]

### 2025-10-02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ data class OSBARCScanParameters(
@SerializedName("scanButton") val scanButton: Boolean,
@SerializedName("scanText") val scanText: String,
@SerializedName("hint") val hint: OSBARCScannerHint?,
@SerializedName("androidScanningLibrary") val androidScanningLibrary: String?
@SerializedName("androidScanningLibrary") val androidScanningLibrary: String?,
@SerializedName("cancelButtonAccessibilityLabel") val cancelButtonAccessibilityLabel: String? = null,
@SerializedName("torchButtonOnAccessibilityLabel") val torchButtonOnAccessibilityLabel: String? = null,
@SerializedName("torchButtonOffAccessibilityLabel") val torchButtonOffAccessibilityLabel: String? = null
Comment thread
OS-pedrogustavobilro marked this conversation as resolved.
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ class OSBARCScannerActivity : ComponentActivity() {
CloseButton(
modifier = Modifier
.padding(top = ScannerBorderPadding, end = ScannerBorderPadding)
.align(Alignment.TopEnd)
.align(Alignment.TopEnd),
accessibilityLabel = parameters.cancelButtonAccessibilityLabel
)
}

Expand Down Expand Up @@ -595,7 +596,9 @@ class OSBARCScannerActivity : ComponentActivity() {
TorchButton(
modifier = Modifier
.padding(bottom = ScannerBorderPadding, end = ScannerBorderPadding)
.align(Alignment.BottomEnd)
.align(Alignment.BottomEnd),
onAccessibilityLabel = parameters.torchButtonOnAccessibilityLabel,
offAccessibilityLabel = parameters.torchButtonOffAccessibilityLabel
)
}
}
Expand Down Expand Up @@ -684,7 +687,8 @@ class OSBARCScannerActivity : ComponentActivity() {
CloseButton(
modifier = Modifier
.padding(top = ScannerBorderPadding, end = ScannerBorderPadding)
.align(Alignment.TopEnd)
.align(Alignment.TopEnd),
accessibilityLabel = parameters.cancelButtonAccessibilityLabel
)

Column(
Expand All @@ -701,7 +705,9 @@ class OSBARCScannerActivity : ComponentActivity() {
if (showTorch) {
TorchButton(
modifier = Modifier
.align(Alignment.End)
.align(Alignment.End),
onAccessibilityLabel = parameters.torchButtonOnAccessibilityLabel,
offAccessibilityLabel = parameters.torchButtonOffAccessibilityLabel
)
Spacer(modifier = Modifier.height(16.dp))
}
Expand All @@ -724,12 +730,13 @@ class OSBARCScannerActivity : ComponentActivity() {
/**
* Composable function, responsible rendering the close button
* @param modifier the custom modifier for the button
* @param accessibilityLabel optional content description read by screen readers; when null or blank no label is set (default behavior)
*/
@Composable
fun CloseButton(modifier: Modifier) {
fun CloseButton(modifier: Modifier, accessibilityLabel: String? = null) {
Icon(
painter = painterResource(id = R.drawable.close),
contentDescription = null,
contentDescription = accessibilityLabel?.takeIf { it.isNotBlank() },
tint = Color.White,
modifier = modifier
.background(color = CloseButtonBackground, shape = CircleShape)
Expand All @@ -744,17 +751,28 @@ class OSBARCScannerActivity : ComponentActivity() {
/**
* Composable function, responsible rendering the torch button
* @param modifier the custom modifier for the button
* @param onAccessibilityLabel optional content description read by screen readers when the torch is on; when null or blank no label is set (default behavior)
* @param offAccessibilityLabel optional content description read by screen readers when the torch is off; when null or blank no label is set (default behavior)
*/
@Composable
fun TorchButton(modifier: Modifier) {
fun TorchButton(
modifier: Modifier,
onAccessibilityLabel: String? = null,
offAccessibilityLabel: String? = null
) {
var isFlashlightOn by remember { mutableStateOf(false) }
val onIcon = painterResource(id = R.drawable.flash_on)
val offIcon = painterResource(id = R.drawable.flash_off)
val icon = if (isFlashlightOn) onIcon else offIcon
val torchContentDescription = if (isFlashlightOn) {
onAccessibilityLabel?.takeIf { it.isNotBlank() }
} else {
offAccessibilityLabel?.takeIf { it.isNotBlank() }
}

Image(
painter = icon,
contentDescription = null,
contentDescription = torchContentDescription,
modifier = modifier
.clickable {
try {
Expand Down
Loading