diff --git a/CHANGELOG.md b/CHANGELOG.md index b7acdca..1b178c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/README.md b/docs/README.md index e125d53..5234453 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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") } ``` diff --git a/pom.xml b/pom.xml index 777b245..5ae04cd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,5 +7,5 @@ 4.0.0 io.ionic.libs ionbarcode-android - 2.0.2 + 2.1.0 diff --git a/src/main/kotlin/com/outsystems/plugins/barcode/model/OSBARCScanParameters.kt b/src/main/kotlin/com/outsystems/plugins/barcode/model/OSBARCScanParameters.kt index aaee198..280291c 100644 --- a/src/main/kotlin/com/outsystems/plugins/barcode/model/OSBARCScanParameters.kt +++ b/src/main/kotlin/com/outsystems/plugins/barcode/model/OSBARCScanParameters.kt @@ -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 ) : Serializable \ No newline at end of file diff --git a/src/main/kotlin/com/outsystems/plugins/barcode/view/OSBARCScannerActivity.kt b/src/main/kotlin/com/outsystems/plugins/barcode/view/OSBARCScannerActivity.kt index 6d48d90..b8adab2 100644 --- a/src/main/kotlin/com/outsystems/plugins/barcode/view/OSBARCScannerActivity.kt +++ b/src/main/kotlin/com/outsystems/plugins/barcode/view/OSBARCScannerActivity.kt @@ -534,7 +534,8 @@ class OSBARCScannerActivity : ComponentActivity() { CloseButton( modifier = Modifier .padding(top = ScannerBorderPadding, end = ScannerBorderPadding) - .align(Alignment.TopEnd) + .align(Alignment.TopEnd), + accessibilityLabel = parameters.cancelButtonAccessibilityLabel ) } @@ -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 ) } } @@ -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( @@ -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)) } @@ -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) @@ -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 {