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-26

- 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.2]

### 2026-06-25
Expand Down
5 changes: 4 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ In your app-level gradle file, import the OSBarcodeLib library like so:

```gradle
dependencies {
implementation("com.github.outsystems:osbarcode-android:2.0.2@aar")
implementation("com.github.outsystems:osbarcode-android:2.1.0@aar")
}
```

Expand Down Expand Up @@ -74,6 +74,9 @@ A method that triggers the barcode reader/scanner, opening a new activity with t
- **scanText**: A string that contains the text to be displayed on the scan button. It will only be shown if **scanButton** is set to true.
- **hint**: An integer that holds a hint to what type of barcode to look for.
- **androidScanningLibrary**: A string which determines what barcode library to use - ML Kit or ZXing.
- **cancelButtonAccessibilityLabel**: A string used as the content description (alternative text) read by screen readers for the cancel button. When null or empty, no content description is set.
- **torchButtonOnAccessibilityLabel**: A string used as the content description read by screen readers for the torch button when the torch is on. When null or empty, no content description is set.
- **torchButtonOffAccessibilityLabel**: A string used as the content description read by screen readers for the torch button when the torch is off. When null or empty, no content description is set.

#### Usage

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.ionic.libs</groupId>
<artifactId>ionbarcode-android</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
</project>
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